teo-tsirpanis / BitCollections

A .NET library with collections that store bits.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Licensed under the MIT License NuGet

BitCollections

BitCollections is a library that provides efficient collections storing bit values. It provides two types:

  • BitSet: An immutable struct, allocation-free when small bit indices are stored.

  • BitArrayNeo: A mutable class, has a similar API with System.Collections.BitArray, its modification methods return whether the collection changed.

These two types can be converted and checked for equality against each other. Both implement IEnumerable<int>, returning the indices of their active bits.

Missing features

BitArrayNeo is not a drop-in replacement for BitArray. In particular, it is missing features like:

  • The LeftShift/RightShift methods
  • Some additional constructors (such as accepting an array of bytes or booleans)
  • SIMD acceleration

BitSet is missing some set-relational operators (such as IsSubsetOf) that might come in handy. They will be added in a future release.

About

A .NET library with collections that store bits.

License:MIT License


Languages

Language:C# 79.8%Language:F# 20.2%