PHP Classes

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    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 71 This week: 1All time: 10,230 This week: 571Up
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
Picture of Jelle Sebreghts
  Performance   Level  
Name: Jelle Sebreghts <contact>
Classes: 7 packages by
Country: United States United States
Age: 34
All time rank: 1485223 in United States United States
Week rank: 420 Up49 in United States United States Up
Innovation award
Innovation award
Nominee: 4x

Documentation

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

Downloadbitmask-generator-2017-01-12.zip 16KB
Downloadbitmask-generator-2017-01-12.tar.gz 15KB
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
Lexographical PHP Permutations Generator Download .zip .tar.gz Composer dependency. Required
 Version Control Reuses Unique User Downloads Download Rankings  
 100%1
Total:71
This week:1
All time:10,230
This week:571Up