vg
tools for working with variation graphs
Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
vg::BitString Class Reference

#include <stream_index.hpp>

Public Member Functions

 BitString (uint64_t bits, size_t length)
 Make a new BitString representing the low length bits of the given number. More...
 
 BitString ()
 Make an empty BitString. More...
 
BitStringoperator= (const BitString &other)=default
 
BitStringoperator= (BitString &&other)=default
 
 BitString (const BitString &other)=default
 
 BitString (BitString &&other)=default
 
uint64_t to_number () const
 Convert the BitString back to a number. More...
 
BitString drop_prefix (size_t prefix_length) const
 
pair< BitString, BitStringsplit (size_t prefix_length) const
 Split into a prefix of the given length and a suffix of the rest. More...
 
bool operator== (const BitString &other) const
 Determine if two BitStrings are equal. More...
 
bool operator!= (const BitString &other) const
 Determine if two BitStrings are unequal. More...
 
size_t common_prefix_length (const BitString &other) const
 
bool at_or_before (const BitString &other) const
 Return true if one BitString is a prefix of the other, or if this BitString has the 0 at the first differing bit. More...
 
bool at_or_after (const BitString &other) const
 Return true if one BitString is a prefix of the other, or if the other BitString has the 0 at the first differing bit. More...
 
bool peek () const
 
size_t length () const
 Get the length of the BitString. More...
 
bool empty () const
 Return true if the bit string is empty. More...
 

Protected Attributes

uint64_t bits
 
uint8_t bit_length
 Holds the number of bits that are used. More...
 

Static Protected Attributes

const static size_t TOTAL_BITS = numeric_limits<uint64_t>::digits
 How many total bits are possible? More...
 

Detailed Description

Represents a string of up to 64 bits.

Constructor & Destructor Documentation

◆ BitString() [1/4]

vg::BitString::BitString ( uint64_t  bits,
size_t  length 
)

Make a new BitString representing the low length bits of the given number.

◆ BitString() [2/4]

vg::BitString::BitString ( )

Make an empty BitString.

◆ BitString() [3/4]

vg::BitString::BitString ( const BitString other)
default

◆ BitString() [4/4]

vg::BitString::BitString ( BitString &&  other)
default

Member Function Documentation

◆ at_or_after()

auto vg::BitString::at_or_after ( const BitString other) const

Return true if one BitString is a prefix of the other, or if the other BitString has the 0 at the first differing bit.

◆ at_or_before()

auto vg::BitString::at_or_before ( const BitString other) const

Return true if one BitString is a prefix of the other, or if this BitString has the 0 at the first differing bit.

◆ common_prefix_length()

auto vg::BitString::common_prefix_length ( const BitString other) const

Get the length of the longest common prefix (index of the first mismatching bit) between this BitString and another.

◆ drop_prefix()

auto vg::BitString::drop_prefix ( size_t  prefix_length) const

Get a suffix of a BitString by dropping the specified number of bits. If we drop all the bits or more, get an empty BitString.

◆ empty()

auto vg::BitString::empty ( ) const

Return true if the bit string is empty.

◆ length()

auto vg::BitString::length ( ) const

Get the length of the BitString.

◆ operator!=()

auto vg::BitString::operator!= ( const BitString other) const

Determine if two BitStrings are unequal.

◆ operator=() [1/2]

BitString& vg::BitString::operator= ( BitString &&  other)
default

◆ operator=() [2/2]

BitString& vg::BitString::operator= ( const BitString other)
default

◆ operator==()

auto vg::BitString::operator== ( const BitString other) const

Determine if two BitStrings are equal.

◆ peek()

auto vg::BitString::peek ( ) const

Peek at the top bit and see if it is a 1 (true) or 0 (false). Empty bit strings get false.

◆ split()

auto vg::BitString::split ( size_t  prefix_length) const

Split into a prefix of the given length and a suffix of the rest.

◆ to_number()

auto vg::BitString::to_number ( ) const

Convert the BitString back to a number.

Member Data Documentation

◆ bit_length

uint8_t vg::BitString::bit_length
protected

Holds the number of bits that are used.

◆ bits

uint64_t vg::BitString::bits
protected

Holds the actual bits of the bit string. We store the bits aligned to the left to make finding the first mismatch easier. All bits below the last used bit are 0.

◆ TOTAL_BITS

const static size_t vg::BitString::TOTAL_BITS = numeric_limits<uint64_t>::digits
staticprotected

How many total bits are possible?


The documentation for this class was generated from the following files: