Skip to content

gausby/bit_field_set

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bit Field Set

Hex.pm Hex version

Store and manipulate a set of bit flags, mostly used for syncing the state over the wire between peers in a peer to peer network, such as BitTorrent.

Usage

# Create a new bit field set with the new command.
# (initial content, and size in bits)
bitfield = BitFieldSet.new!(<<0b00110001>>, 8)
# => #BitFieldSet<[2, 3, 7]>

# set the first bit
bitfield = BitFieldSet.put(bitfield, 0)
# => #BitFieldSet<[0, 2, 3, 7]>

bitfield = BitFieldSet.delete(bitfield, 3)
# => #BitFieldSet<[0, 2, 7]>

BitFieldSet.to_binary(bitfield)
# => <<161>>

Installation

Bit Field Set is available in Hex, the package can be installed by adding bit_field_set to your list of dependencies in mix.exs:

def deps do
  [{:bit_field_set, "~> 1.2.0"}]
end

This module does not need to be started as an application, just use it as is.

Development

Fork the project and fetch the dependencies.

  • The project uses QuickCheck for Elixir from Quviq to test its behavior. Please download an follow the install instructions for QuickCheck Mini to run the property tests.

  • Benchmarks are performed by Benchfella, a project by Alexei Sholik. Nothing special is needed besides fetching the mix dependencies.

License

Copyright 2016 Martin Gausby

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

Store and manipulate a set of bit flags, mostly used for syncing the state over the wire between peers in a peer to peer network, such as BitTorrent.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages