PHPackages                             adagio/bitset - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. adagio/bitset

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

adagio/bitset
=============

Pure PHP drop-in replacement for 'bitset' extension.

0.3.0(9y ago)69.1kCC-BY-NC-SA-4.0PHPPHP ^5.5 || ^7.0

Since Sep 6Pushed 9y agoCompare

[ Source](https://github.com/kevengodet/bitset)[ Packagist](https://packagist.org/packages/adagio/bitset)[ Docs](https://github.com/adagio/bitset)[ RSS](/packages/adagio-bitset/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (4)Used By (0)

BitSet [![Build Status](https://camo.githubusercontent.com/dd2843e3712db82f4e0537b815f1ed2986edc7b90031bfa16ce6a76bfd11faca/68747470733a2f2f7472617669732d63692e6f72672f61646167696f6c6162732f6269747365742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/adagiolabs/bitset)
=========================================================================================================================================================================================================================================================================================

[](#bitset-)

Drop in replacement for bitset extension.

Also try to reproduce the implementation details of the extension.

API
---

[](#api)

The API is the same as in the extension, with the addition of a Factory to use the best available implementation.

Factory:

```
Factory::create($bits = 64): BitSet
Factory::fromArray(array $array): BitSet
Factory::fromRawValue(string $raw): BitSet
Factory::fromString(string $str): BitSet
```

BitSet adapters:

```
BitSet::set($from = -1, $to = 0): void
BitSet::get($index): boolean
BitSet::clear($from = -1, $to = 0): void
BitSet::size(): int
BitSet::cardinality(): int
BitSet::isEmpty(): boolean
BitSet::length(): int
BitSet::andNotOp(BitSet $set): void
BitSet::andOp(BitSet $set): void
BitSet::orOp(BitSet $set): void
BitSet::xorOp(BitSet $set): void
BitSet::nextClearBit($index): int|false
BitSet::nextSetBit($index): int|false
BitSet::previousClearBit($index): int|false
BitSet::previousSetBit($index): int|false
BitSet::getRawValue(): string
BitSet::toArray(): array
```

Usage
-----

[](#usage)

Factory:

```
