PHP Classes
elePHPant
Icontem

PHP BitMask Generator: Generate all bitmasks with a minimum amount of 1s

Recommend this page to a friend!
  Info   View files Documentation   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-01-12 (2 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 47 All time: 8,775 This week: 802Up
Version License PHP version Categories
bitmask-generator 1.0.0GNU General Publi...5Algorithms, PHP 5, Text processing
Description Author

This class can generate all bitmasks with a minimum amount of 1s.

It can take a given length and generates string sequences of bitmask that have a given minimum of bits set to one.

Calling an iterator returns the next bitmask in the sequence.

Innovation Award
PHP Programming Innovation award nominee
January 2017
Number 12
Bitmasks are used to represent numbers as binary digits (1 and 0). These are useful to perform logical operations with numbers bit by bit.

This class can generate sequences of bitmask numbers with a given limit of bits set to 1, thus enforcing that the generated binary numbers has certain characteristics.

Manuel Lemos
  Performance   Level  
Name: Jelle Sebreghts <contact>
Classes: 7 packages by
Country: Belgium Belgium
Innovation award
Innovation award
Nominee: 4x

Details

BitMaskGenerator

Build Status Code Climate Test Coverage Issue Count

Usage:

use Jelle_S\Util\BitMask\BitMaskGenerator;
$length = 5;
$minPositives = 2;
// BitMaskGenerator that generates bitmasks with a length of 5 and at least two
// positives (1's).
$generator = new BitMaskGenerator($length, $minPositives);
while ($mask = $generator->getNextMask()) {
  print $mask . "\n";
}

Output:

00011
00101
00110
01001
01010
01100
10001
10010
10100
11000
00111
01011
01101
01110
10011
10101
10110
11001
11010
11100
01111
10111
11011
11101
11110
11111
  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Files folder imagetests (1 file)
Accessible without login Plain text file .codeclimate.yml Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file BitMaskGenerator.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Plain text file BitMaskGeneratorTest.php Class Class source

 Version Control Reuses Unique User Downloads Download Rankings  
 100%1
Total:47
This week:0
All time:8,775
This week:802Up