ROSE  0.9.10.89
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Sawyer::Container::BitVector Class Reference

Description

Bit vectors.

This class implements bit vectors with run-time sizes and a rich set of operations that can be restricted to a contiguous subset of bits. The primary goal of this class is not to provide the utmost performance, but rather a rich, easy-to-use interface. For example,

BitVector bv(128); // a 128-bit vector with all bits cleared
bv.set(BitRange(6,27)); // set (make true) bits 6 through 27, inclusive
bv.fromHex(BitRange::baseSize(32,64), "deadbeef"); // initialize 64 bits beginning at bit 32
bool carry = bv.add(BitRange(5,8), BitRange(5,8)); // double the integer represented by bits 5 through 8
std::cout <<bv.toBinary(BitRange(5,8)) <<"\n"; // print bits 5-8 as a binary string

In general, each method has a number of overloaded varieties: if a BitRange is not specified it generally means the entire bit vector; if a second bit vector is not specified for binary operations it generally means use this vector for both operands. Non-const operations modify this vector in place, and most of them also return a reference so that they can be easily chained:

bv.clear().set(BitRange(24,31)); // clear all bits, then set bits 24-31

When performing an operation that has two operands, the operands are generally permitted to both refer to the same vector, and the range arguments are permitted to overlap in that vector. When this occurs, the semantics are as if a temporary copy was made, then the operation was performed on the temporary copy, then the result was written back to the destination.

BitVector objects manage their own data, but if one needs to operate on an array that is already allocated then the function templates in the BitVectorSupport name space can be used.

Definition at line 64 of file BitVector.h.

#include <BitVector.h>

Public Types

typedef unsigned Word
 Base storage type. More...
 
typedef BitVectorSupport::BitRange BitRange
 Describes an inclusive interval of bit indices. More...
 

Public Member Functions

 BitVector ()
 Default construct an empty vector. More...
 
 BitVector (const BitVector &other)
 Copy constructor. More...
 
 BitVector (size_t nbits, bool newBits=false)
 Create a vector of specified size. More...
 
BitVectoroperator= (const BitVector &other)
 Assignment. More...
 
bool isEmpty () const
 Determines if the vector is empty. More...
 
size_t size () const
 Size of vector in bits. More...
 
BitVectorresize (size_t newSize, bool newBits=false)
 Change vector size. More...
 
size_t capacity () const
 Maximum size before reallocation. More...
 
BitRange hull () const
 Interval representing the entire vector. More...
 
bool get (size_t idx) const
 Retrieve one bit. More...
 
BitVectorclear (const BitRange &range)
 Assign zero to some bits. More...
 
BitVectorclear ()
 Assign zero to all bits. More...
 
BitVectorset (const BitRange &range)
 Assign true to some bits. More...
 
BitVectorset ()
 Assign true to all bits. More...
 
BitVectorsetValue (const BitRange &range, bool value)
 Assign true/false to some bits. More...
 
BitVectorsetValue (bool value)
 Assign true/false to all bits. More...
 
BitVectorcopy (const BitRange &to, const BitVector &other, const BitRange &from)
 Copy some bits. More...
 
BitVectorcopy (const BitRange &to, const BitRange &from)
 Copy some bits. More...
 
BitVectorswap (const BitRange &range1, BitVector &other, const BitRange &range2)
 Swap some bits. More...
 
BitVectorswap (const BitRange &range1, const BitRange &range2)
 Swap some bits. More...
 
Optional< size_t > leastSignificantSetBit (const BitRange &range) const
 Find the least significant set bit. More...
 
Optional< size_t > leastSignificantSetBit () const
 Find the least significant set bit. More...
 
Optional< size_t > leastSignificantClearBit (const BitRange &range) const
 Find the least significant clear bit. More...
 
Optional< size_t > leastSignificantClearBit () const
 Find the least significant clear bit. More...
 
Optional< size_t > mostSignificantSetBit (const BitRange &range) const
 Find the most significant set bit. More...
 
Optional< size_t > mostSignificantSetBit () const
 Find the most significant set bit. More...
 
Optional< size_t > mostSignificantClearBit (const BitRange &range) const
 Find the most significant clear bit. More...
 
Optional< size_t > mostSignificantClearBit () const
 Find the most significant clear bit. More...
 
bool isAllSet (const BitRange &range) const
 True if all bits are set. More...
 
bool isAllSet () const
 True if all bits are set. More...
 
bool isAllClear (const BitRange &range) const
 True if all bits are clear. More...
 
bool isAllClear () const
 True if all bits are clear. More...
 
size_t nSet (const BitRange &range) const
 Number of set bits. More...
 
size_t nSet () const
 Number of set bits. More...
 
size_t nClear (const BitRange &range) const
 Number of clear bits. More...
 
size_t nClear () const
 Number of clear bits. More...
 
Optional< size_t > mostSignificantDifference (const BitRange &range1, const BitVector &other, const BitRange &range2) const
 Find most significant difference. More...
 
Optional< size_t > mostSignificantDifference (const BitRange &range1, const BitRange &range2) const
 Find most significant difference. More...
 
Optional< size_t > mostSignificantDifference (const BitVector &other) const
 Find most significant difference. More...
 
Optional< size_t > leastSignificantDifference (const BitRange &range1, const BitVector &other, const BitRange &range2) const
 Find least significant difference. More...
 
Optional< size_t > leastSignificantDifference (const BitRange &range1, const BitRange &range2) const
 Find least significant difference. More...
 
Optional< size_t > leastSignificantDifference (const BitVector &other) const
 Find least significant difference. More...
 
BitVectorshiftLeft (const BitRange &range, size_t nShift, bool newBits=0)
 Shift bits left. More...
 
BitVectorshiftLeft (size_t nShift, bool newBits=0)
 Shift bits left. More...
 
BitVectorshiftRight (const BitRange &range, size_t nShift, bool newBits=0)
 Shift bits right. More...
 
BitVectorshiftRight (size_t nShift, bool newBits=0)
 Shift bits right. More...
 
BitVectorshiftRightArithmetic (const BitRange &range, size_t nShift)
 Shift bits right. More...
 
BitVectorshiftRightArithmetic (size_t nShift)
 Shift bits right. More...
 
BitVectorrotateRight (const BitRange &range, size_t nShift)
 Rotate bits right. More...
 
BitVectorrotateRight (size_t nShift)
 Rotate bits right. More...
 
BitVectorrotateLeft (const BitRange &range, size_t nShift)
 Rotate bits left. More...
 
BitVectorrotateLeft (size_t nShift)
 Rotate bits left. More...
 
BitVectornegate (const BitRange &range1)
 Negates bits as integer. More...
 
BitVectornegate ()
 Negates bits as integer. More...
 
bool increment (const BitRange &range1)
 Increment bits as integer. More...
 
bool increment ()
 Increment bits as integer. More...
 
bool decrement (const BitRange &range1)
 Decrement bits as integer. More...
 
bool decrement ()
 Decrement bits as integer. More...
 
bool add (const BitRange &range1, const BitVector &other, const BitRange &range2)
 Add bits as integers. More...
 
bool add (const BitRange &range1, const BitRange &range2)
 Add bits as integers. More...
 
bool add (const BitVector &other)
 Add bits as integers. More...
 
bool subtract (const BitRange &range1, const BitVector &other, const BitRange &range2)
 Subtract bits as integers. More...
 
bool subtract (const BitRange &range1, const BitRange &range2)
 Subtract bits as integers. More...
 
bool subtract (const BitVector &other)
 Subtract bits as integers. More...
 
BitVectorsignExtend (const BitRange &range1, const BitVector &other, const BitRange &range2)
 Copy bits and sign extend. More...
 
BitVectorsignExtend (const BitRange &range1, const BitRange &range2)
 Copy bits and sign extend. More...
 
BitVectorsignExtend (const BitVector &other)
 Copy bits and sign extend. More...
 
BitVectormultiply10 ()
 Multiply by 10. More...
 
BitVectormultiply10 (const BitRange &range)
 Multiply by 10. More...
 
BitVectorinvert (const BitRange &range)
 Invert bits. More...
 
BitVectorinvert ()
 Invert bits. More...
 
BitVectorbitwiseAnd (const BitRange &range1, const BitVector &other, const BitRange &range2)
 Bit-wise AND. More...
 
BitVectorbitwiseAnd (const BitRange &range1, const BitRange &range2)
 Bit-wise AND. More...
 
BitVectorbitwiseAnd (const BitVector &other)
 Bit-wise AND. More...
 
BitVectorbitwiseOr (const BitRange &range1, const BitVector &other, const BitRange &range2)
 Bit-wise OR. More...
 
BitVectorbitwiseOr (const BitRange &range1, const BitRange &range2)
 Bit-wise OR. More...
 
BitVectorbitwiseOr (const BitVector &other)
 Bit-wise OR. More...
 
BitVectorbitwiseXor (const BitRange &range1, const BitVector &other, const BitRange &range2)
 Bit-wise XOR. More...
 
BitVectorbitwiseXor (const BitRange &range1, const BitRange &range2)
 Bit-wise XOR. More...
 
BitVectorbitwiseXor (const BitVector &other)
 Bit-wise XOR. More...
 
bool isEqualToZero (const BitRange &range) const
 Compare to zero. More...
 
bool isEqualToZero () const
 Compare to zero. More...
 
int compare (const BitRange &range1, const BitVector &other, const BitRange &range2) const
 Compare bits as integers. More...
 
int compare (const BitRange &range1, const BitRange &range2) const
 Compare bits as integers. More...
 
int compare (const BitVector &other) const
 Compare bits as integers. More...
 
int compareSigned (const BitRange &range1, const BitVector &other, const BitRange &range2) const
 Compare bits as signed integers. More...
 
int compareSigned (const BitRange &range1, const BitRange &range2) const
 Compare bits as signed integers. More...
 
int compareSigned (const BitVector &other) const
 Compare bits as signed integers. More...
 
boost::uint64_t toInteger (const BitRange &range) const
 Interpret bits as an unsigned integer. More...
 
boost::uint64_t toInteger () const
 Interpret bits as an unsigned integer. More...
 
std::string toHex (const BitRange &range) const
 Convert to a hexadecimal string. More...
 
std::string toHex () const
 Convert to a hexadecimal string. More...
 
std::string toOctal (const BitRange &range) const
 Convert to an octal string. More...
 
std::string toOctal () const
 Convert to an octal string. More...
 
std::string toBinary (const BitRange &range) const
 Convert to a binary string. More...
 
std::string toBinary () const
 Convert to an binary string. More...
 
BitVectorfromInteger (const BitRange &range, boost::uint64_t value)
 Obtain bits from an integer. More...
 
BitVectorfromInteger (boost::uint64_t value)
 Obtain bits from an integer. More...
 
BitVectorfromDecimal (const BitRange &range, const std::string &input)
 Obtains bits from a decimal representation. More...
 
BitVectorfromDecimal (const std::string &input)
 Obtain bits from a decimal representation. More...
 
BitVectorfromHex (const BitRange &range, const std::string &input)
 Obtain bits from a hexadecimal representation. More...
 
BitVectorfromHex (const std::string &input)
 Obtain bits from a hexadecimal representation. More...
 
BitVectorfromOctal (const BitRange &range, const std::string &input)
 Obtain bits from an octal representation. More...
 
BitVectorfromOctal (const std::string &input)
 Obtain bits from an octal representation. More...
 
BitVectorfromBinary (const BitRange &range, const std::string &input)
 Obtain bits from a binary representation. More...
 
BitVectorfromBinary (const std::string &input)
 Obtain bits from a binary representation. More...
 
void checkRange (const BitRange &range) const
 Assert valid range. More...
 
size_t dataSize () const
 Raw data size. More...
 
Worddata ()
 Raw data for vector. More...
 
const Worddata () const
 Raw data for vector. More...
 

Static Public Member Functions

static BitVector parse (std::string str)
 Create a bit vector by reading a string. More...
 
static BitRange baseSize (size_t base, size_t size)
 Create a bit range from a starting offset and size. More...
 
static BitRange hull (size_t minOffset, size_t maxOffset)
 Create a bit range from min and max positions. More...
 

Member Typedef Documentation

Base storage type.

Definition at line 66 of file BitVector.h.

Describes an inclusive interval of bit indices.

Definition at line 67 of file BitVector.h.

Constructor & Destructor Documentation

Sawyer::Container::BitVector::BitVector ( )
inline

Default construct an empty vector.

Definition at line 83 of file BitVector.h.

Sawyer::Container::BitVector::BitVector ( const BitVector other)
inline

Copy constructor.

Definition at line 86 of file BitVector.h.

Sawyer::Container::BitVector::BitVector ( size_t  nbits,
bool  newBits = false 
)
inlineexplicit

Create a vector of specified size.

All bits in this vector will be set to the newBits value.

Definition at line 91 of file BitVector.h.

References resize().

Member Function Documentation

static BitVector Sawyer::Container::BitVector::parse ( std::string  str)
inlinestatic

Create a bit vector by reading a string.

Reads a bit vector from the string and returns the result. The input string has an optional suffix ("h" for hexadecimal) or optioanl prefix ("0x" for hexadecimal, "0b" or binary, or "0" for octal). It does not have both; if a suffix is present then the parser does not search for a prefix. Lack of both prefix and suffix implies decimal format. Any recognized suffix or prefix is stripped from the value, and the number of valid digits is counted and used to calculate the width of the resulting bit vector. For instance, if three octal digits are found (not counting the "0" prefix) then the resulting bit vector will have nine bits – three per digit. The string is then passed to fromBinary, fromOctal, fromDecimal, or fromHex for parsing.

Definition at line 106 of file BitVector.h.

References fromBinary(), fromDecimal(), fromHex(), and fromOctal().

BitVector& Sawyer::Container::BitVector::operator= ( const BitVector other)
inline

Assignment.

Makes this bit vector an exact copy of the other vector.

See also
The copy method is similar but does not change the size of the destination vector.

Definition at line 175 of file BitVector.h.

bool Sawyer::Container::BitVector::isEmpty ( ) const
inline

Determines if the vector is empty.

Returns true if this vector contains no data.

Definition at line 184 of file BitVector.h.

size_t Sawyer::Container::BitVector::size ( void  ) const
inline

Size of vector in bits.

Returns the size of this vector in bits.

Definition at line 189 of file BitVector.h.

Referenced by toInteger().

BitVector& Sawyer::Container::BitVector::resize ( size_t  newSize,
bool  newBits = false 
)
inline

Change vector size.

Changes the size of a vector, measured in bits, by either adding or removing bits from the most-significant side of this vector. If new bits are added they are each given the value newBits. Increasing the size of a vector may cause it to reallocate and copy its internal data structures.

Definition at line 196 of file BitVector.h.

References data(), Sawyer::Container::Interval< size_t >::hull(), and Sawyer::Container::BitVectorSupport::setValue().

Referenced by BitVector().

size_t Sawyer::Container::BitVector::capacity ( ) const
inline

Maximum size before reallocation.

Returns the maximum number of bits to which this vector could be resized via resize before it becomes necessary to reallocate its internal data structures.

Definition at line 217 of file BitVector.h.

BitRange Sawyer::Container::BitVector::hull ( ) const
inline
static BitRange Sawyer::Container::BitVector::baseSize ( size_t  base,
size_t  size 
)
inlinestatic

Create a bit range from a starting offset and size.

This is just a convenience wrapper around BitRange::baseSize() so that name qualification can be avoided when "using namespace" directives are not employed.

Definition at line 232 of file BitVector.h.

References Sawyer::Container::Interval< size_t >::baseSize().

static BitRange Sawyer::Container::BitVector::hull ( size_t  minOffset,
size_t  maxOffset 
)
inlinestatic

Create a bit range from min and max positions.

This is just a convenience wrapper around BitRange::hull(size_t,size_t) so that name qualification can be avoided when "using namespace" directives are not employed.

Definition at line 240 of file BitVector.h.

References Sawyer::Container::Interval< size_t >::hull().

bool Sawyer::Container::BitVector::get ( size_t  idx) const
inline

Retrieve one bit.

Returns the value of the bit at the specified index in constant time. The index must be a valid index for this vector.

Definition at line 252 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::get().

Referenced by Sawyer::Container::Algorithm::GraphTraversal< Graph, BreadthFirstTraversalTag, ForwardTraversalTag >::isDiscovered(), and Sawyer::Container::Algorithm::GraphTraversal< Graph, BreadthFirstTraversalTag, ForwardTraversalTag >::isVisited().

BitVector& Sawyer::Container::BitVector::clear ( const BitRange range)
inline

Assign zero to some bits.

Clears bits by assigning false to each bit in the specified range. The convention is that "clear" means to assign false to a bit and should not be confused with the STL usage of the word, namely to erase all values from a container. To erase all bits from a vector, use resize(0).

Definition at line 262 of file BitVector.h.

References checkRange(), Sawyer::Container::BitVectorSupport::clear(), and data().

BitVector& Sawyer::Container::BitVector::clear ( )
inline

Assign zero to all bits.

Clears bits by assigning false to all bits in this vector. The convention is that "clear" means to assign false to to a bit and should not be confused with the STL usage of the word, namely to erase all values from a container. To erase all bits from a vector, use resize(0).

Definition at line 273 of file BitVector.h.

References Sawyer::Container::BitVectorSupport::clear(), data(), and hull().

BitVector& Sawyer::Container::BitVector::set ( const BitRange range)
inline

Assign true to some bits.

Sets bits by assigning true (or newBits) to each bit in the specified range. The convention is that "set" means to assign true to a bit; to assign a specific value use setValue.

Definition at line 282 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::set().

BitVector& Sawyer::Container::BitVector::set ( )
inline

Assign true to all bits.

Sets bits by assigning true (or newBits) to all bits in this vector. The convention is that "set" means to assign true to a bit; to assign a specific value use setValue.

Definition at line 292 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::set().

BitVector& Sawyer::Container::BitVector::setValue ( const BitRange range,
bool  value 
)
inline

Assign true/false to some bits.

Sets the bits in the specified range to the specified value.

Definition at line 300 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::setValue().

BitVector& Sawyer::Container::BitVector::setValue ( bool  value)
inline

Assign true/false to all bits.

Sets all bits to the specified value.

Definition at line 309 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::setValue().

BitVector& Sawyer::Container::BitVector::copy ( const BitRange to,
const BitVector other,
const BitRange from 
)
inline

Copy some bits.

Copies bits from other specified by from into this vector specified by to. The ranges must be the same size and must be valid for their respective vectors. The other vector is permitted to be the same vector as this, in which case from is also permitted to overlap with to.

See also
Copy constructor and assignment operator.

Definition at line 321 of file BitVector.h.

References checkRange(), Sawyer::Container::BitVectorSupport::copy(), and data().

BitVector& Sawyer::Container::BitVector::copy ( const BitRange to,
const BitRange from 
)
inline

Copy some bits.

Copies bits from the range from to the range to. Both ranges must be the same size, and they may overlap.

See also
Copy constructor and assignment operator.

Definition at line 333 of file BitVector.h.

References checkRange(), Sawyer::Container::BitVectorSupport::copy(), and data().

BitVector& Sawyer::Container::BitVector::swap ( const BitRange range1,
BitVector other,
const BitRange range2 
)
inline

Swap some bits.

Swaps bits between range1 of this vector and range2 of the other vector. Both ranges must be the same size and must be valid for their respective vectors. The other vector is permitted to be the same vector as this, but range1 and range2 are not permitted to overlap.

Definition at line 345 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::swap().

BitVector& Sawyer::Container::BitVector::swap ( const BitRange range1,
const BitRange range2 
)
inline

Swap some bits.

Swaps bits between range1 and range2 of this vector. Both ranges must be the same size, and must be valid for this vector, and must not overlap.

Definition at line 356 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::swap().

Optional<size_t> Sawyer::Container::BitVector::leastSignificantSetBit ( const BitRange range) const
inline

Find the least significant set bit.

Returns the index for the least significant bit that has the value true in the specified range. The range must be valid for this vector. If the range has no such bits, including the case when the range is empty, then nothing is returned.

Definition at line 372 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::leastSignificantSetBit().

Optional<size_t> Sawyer::Container::BitVector::leastSignificantSetBit ( ) const
inline

Find the least significant set bit.

Returns the index for the least significant bit that has the value true. If no bit is true, including the case when the vector is empty, then nothing is returned.

Definition at line 381 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::leastSignificantSetBit().

Optional<size_t> Sawyer::Container::BitVector::leastSignificantClearBit ( const BitRange range) const
inline

Find the least significant clear bit.

Returns the index for the least significant bit that has the value false in the specified range. The range must be valid for this vector. If the range has no such bits, including the case when the range is empty, then nothing is returned.

Definition at line 390 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::leastSignificantClearBit().

Optional<size_t> Sawyer::Container::BitVector::leastSignificantClearBit ( ) const
inline

Find the least significant clear bit.

Returns the index for the least significant bit that has the value false. If no bit is false, including the case when the vector is empty, then nothing is returned.

Definition at line 399 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::leastSignificantClearBit().

Optional<size_t> Sawyer::Container::BitVector::mostSignificantSetBit ( const BitRange range) const
inline

Find the most significant set bit.

Returns the index for the most significant bit that has the value true in the specified range. The range must be valid for this vector. If the range has no such bits, including the case when the range is empty, then nothing is returned.

Definition at line 408 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::mostSignificantSetBit().

Optional<size_t> Sawyer::Container::BitVector::mostSignificantSetBit ( ) const
inline

Find the most significant set bit.

Returns the index for the most significant bit that has the value true. If no bit is true, including the case when the vector is empty, then nothing is returned.

Definition at line 417 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::mostSignificantSetBit().

Optional<size_t> Sawyer::Container::BitVector::mostSignificantClearBit ( const BitRange range) const
inline

Find the most significant clear bit.

Returns the index for the most significant bit that has the value false in the specified range. The range must be valid for this vector. If the range has no such bits, including the case when the range is empty, then nothing is returned.

Definition at line 426 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::mostSignificantClearBit().

Optional<size_t> Sawyer::Container::BitVector::mostSignificantClearBit ( ) const
inline

Find the most significant clear bit.

Returns the index for the most significant bit that has the value false. If no bit is false, including the case when the vector is empty, then nothing is returned.

Definition at line 435 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::mostSignificantClearBit().

bool Sawyer::Container::BitVector::isAllSet ( const BitRange range) const
inline

True if all bits are set.

Returns true if all bits are set within the specified range, or if the range is empty. The range must be valid for this vector.

Definition at line 443 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::isAllSet().

bool Sawyer::Container::BitVector::isAllSet ( ) const
inline

True if all bits are set.

Returns true if all bits are set, or if the vector is empty.

Definition at line 451 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::isAllSet().

bool Sawyer::Container::BitVector::isAllClear ( const BitRange range) const
inline

True if all bits are clear.

Returns true if all bits are clear within the specified range, or if the range is empty. The range must be valid for this vector.

See also
isEqualToZero

Definition at line 461 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::isAllClear().

bool Sawyer::Container::BitVector::isAllClear ( ) const
inline

True if all bits are clear.

Returns true if all bits are clear, or if the vector is empty.

See also
isEqualToZero

Definition at line 471 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::isAllClear().

size_t Sawyer::Container::BitVector::nSet ( const BitRange range) const
inline

Number of set bits.

Returns the number of bits that are set in the specified range. The range must be valid for this vector.

Definition at line 478 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::nSet().

size_t Sawyer::Container::BitVector::nSet ( ) const
inline

Number of set bits.

Returns the number of bits that are set.

Definition at line 486 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::nSet().

size_t Sawyer::Container::BitVector::nClear ( const BitRange range) const
inline

Number of clear bits.

Returns the number of bits that are clear in the specified range. The range must be valid for this vector.

Definition at line 493 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::nClear().

size_t Sawyer::Container::BitVector::nClear ( ) const
inline

Number of clear bits.

Returns the number of bits that are clear.

Definition at line 501 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::nClear().

Optional<size_t> Sawyer::Container::BitVector::mostSignificantDifference ( const BitRange range1,
const BitVector other,
const BitRange range2 
) const
inline

Find most significant difference.

Finds the most significant bit that differs between range1 of this vector and range2 of the other vector and returns its offset from the beginning of the ranges. Both ranges must be the same size and must be valid for their respective vectors. If no bits differ, including the case when both ranges are empty, then nothing is returned. The other vector is permitted to be the same as this vector, in which case the ranges are also permitted to overlap.

Note that the return value is not a vector index, but rather an offset with respect to the starting index in each of the ranges.

Definition at line 515 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::mostSignificantDifference().

Optional<size_t> Sawyer::Container::BitVector::mostSignificantDifference ( const BitRange range1,
const BitRange range2 
) const
inline

Find most significant difference.

Finds the most significant bit that differs between the two specified ranges of this vector and returns its offset from the beginning of the ranges. Both ranges must be the same size and must be valid for this vector. If no bits differ, including the case when both ranges are empty, then nothing is returned. The ranges are permitted to overlap.

Note that the return value is not a vector index, but rather an offset with respect to the starting index in each of the ranges.

Definition at line 530 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::mostSignificantDifference().

Optional<size_t> Sawyer::Container::BitVector::mostSignificantDifference ( const BitVector other) const
inline

Find most significant difference.

Finds the most significant bit that differs between this vector and the other vector and return its index. Both vectors must be the same size. If no bits differ, including the case when this vector is empty, then nothing is returned.

Definition at line 541 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::mostSignificantDifference().

Optional<size_t> Sawyer::Container::BitVector::leastSignificantDifference ( const BitRange range1,
const BitVector other,
const BitRange range2 
) const
inline

Find least significant difference.

Finds the least significant bit that differs between range1 of this vector and range2 of the other vector and returns its offset from the beginning of the ranges. Both ranges must be the same size and must be valid for their respective vectors. If no bits differ, including the case when both ranges are empty, then nothing is returned. The other vector is permitted to be the same as this vector, in which case the ranges are also permitted to overlap.

Note that the return value is not a vector index, but rather an offset with respect to the starting index in each of the ranges.

Definition at line 555 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::leastSignificantDifference().

Optional<size_t> Sawyer::Container::BitVector::leastSignificantDifference ( const BitRange range1,
const BitRange range2 
) const
inline

Find least significant difference.

Finds the least significant bit that differs between the two specified ranges of this vector and returns its offset from the beginning of the ranges. Both ranges must be the same size and must be valid for this vector. If no bits differ, including the case when both ranges are empty, then nothing is returned. The ranges are permitted to overlap.

Note that the return value is not a vector index, but rather an offset with respect to the starting index in each of the ranges.

Definition at line 570 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::leastSignificantDifference().

Optional<size_t> Sawyer::Container::BitVector::leastSignificantDifference ( const BitVector other) const
inline

Find least significant difference.

Finds the least significant bit that differs between this vector and the other vector and return its index. Both vectors must be the same size. If no bits differ, including the case when this vector is empty, then nothing is returned.

Definition at line 581 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::leastSignificantDifference().

BitVector& Sawyer::Container::BitVector::shiftLeft ( const BitRange range,
size_t  nShift,
bool  newBits = 0 
)
inline

Shift bits left.

Shifts the bits in the specified range of this vector left (to more significant positions) by nShift bits. Bits shifted off the left of the range are discarded; new bits shifted into the right of the range are introduced with the value newBits. The range must be valid for this vector. If nShift is zero or the range is empty then no operation is performed. Specifying an nShift value equal to or greater than the size of the range has the same effect as filling the range with newBits (see also, set and clear, which are probably more efficient).

Definition at line 596 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::shiftLeft().

BitVector& Sawyer::Container::BitVector::shiftLeft ( size_t  nShift,
bool  newBits = 0 
)
inline

Shift bits left.

Shifts all bits of this vector left (to more significant positions) by nShift bits. Bits shifted off the left of this vector are discarded; new bits shifted into the right of this vector are introduced with the value newBits. If nShift is zero or the vector is empty then no operation is performed. Specifying an nShift value equal to or greater than the size of this vector has the same effect as filling the vector with newBits (see also, set and clear, which are probably more efficient).

Definition at line 609 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::shiftLeft().

BitVector& Sawyer::Container::BitVector::shiftRight ( const BitRange range,
size_t  nShift,
bool  newBits = 0 
)
inline

Shift bits right.

Shifts the bits in the specified range of this vector right (to less significant positions) by nShift bits. Bits shifted off the right of the range are discarded; new bits shifted into the left of the range are introduced with the value newBits. The range must be valid for this vector. If nShift is zero or the range is empty then no operation is performed. Specifying an nShift value equal to or greater than the size of the range has the same effect as filling the range with newBits (see also, set and clear, which are probably more efficient).

Definition at line 621 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::shiftRight().

BitVector& Sawyer::Container::BitVector::shiftRight ( size_t  nShift,
bool  newBits = 0 
)
inline

Shift bits right.

Shifts all bits of this vector right (to less significant positions) by nShift bits. Bits shifted off the right of this vector are discarded; new bits shifted into the left of this vector are introduced with the value newBits. If nShift is zero or the vector is empty then no operation is performed. Specifying an nShift value equal to or greater than the size of this vector has the same effect as filling the vector with newBits (see also, set and clear, which are probably more efficient).

Definition at line 634 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::shiftRight().

BitVector& Sawyer::Container::BitVector::shiftRightArithmetic ( const BitRange range,
size_t  nShift 
)
inline

Shift bits right.

Shifts the bits in the specified range of this vector right (to less significant positions) by nShift bits. Bits shifted off the right of the range are discarded; new bits shifted into the left of the range are introduced with the same value as the original most-significant bit of the range. The range must be valid for this vector. If nShift is zero or the range is empty or a singleton then no operation is performed. Specifying an nShift value equal to or greater than the size of the range has the same effect as filling the range with its original most-significant bit (see also, set and clear, which are probably more efficient).

Definition at line 647 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::shiftRightArithmetic().

BitVector& Sawyer::Container::BitVector::shiftRightArithmetic ( size_t  nShift)
inline

Shift bits right.

Shifts the bits in this vector right (to less significant positions) by nShift bits. Bits shifted off the right of this vector are discarded; new bits shifted into the left of this vector are introduced with the same value as the original most-significant bit of this vector. If nShift is zero or the vector is empty or only a single bit then no operation is performed. Specifying an nShift value equal to or greater than the size of this vector has the same effect as filling the vector with its original most-significant bit (see also, set and clear, which are probably more efficient).

Definition at line 661 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::shiftRightArithmetic().

BitVector& Sawyer::Container::BitVector::rotateRight ( const BitRange range,
size_t  nShift 
)
inline

Rotate bits right.

Rotates the bits in the specified range to the right (to less significant positions) by shifting right and reintroducing the bits shifted off the right end into the left end. The range must be valid for this vector. If nShift is zero modulo the range size, or the range is empty, then no operation is performed.

Definition at line 671 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::rotateRight().

BitVector& Sawyer::Container::BitVector::rotateRight ( size_t  nShift)
inline

Rotate bits right.

Rotates all bits in this vector to the right (to less significant positions) by shifting right and reintroducing the bits shifted off the right end into the left end. If nShift is zero modulo this vector size, or this vector is empty, then no operation is performed.

Definition at line 682 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::rotateRight().

BitVector& Sawyer::Container::BitVector::rotateLeft ( const BitRange range,
size_t  nShift 
)
inline

Rotate bits left.

Rotates the bits in the specified range to the left (to more significant positions) by shifting left and reintroducing the bits shifted off the left end into the right end. The range must be valid for this vector. If nShift is zero modulo the range size, or the range is empty, then no operation is performed.

Definition at line 692 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::rotateLeft().

BitVector& Sawyer::Container::BitVector::rotateLeft ( size_t  nShift)
inline

Rotate bits left.

Rotates all bits in this vector to the left (to more significant positions) by shifting left and reintroducing the bits shifted off the left end into the right end. If nShift is zero modulo this vector size, or this vector is empty, then no operation is performed.

Definition at line 703 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::rotateLeft().

BitVector& Sawyer::Container::BitVector::negate ( const BitRange range1)
inline

Negates bits as integer.

Treats range1 of this vector as a two's complement integer and negates it, storing the result back into the same range of bits. The range must be valid for this vector.

Definition at line 716 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::negate().

BitVector& Sawyer::Container::BitVector::negate ( )
inline

Negates bits as integer.

Treats all bits of this vector as a two's complement integer and negates it, storing the result back into this vector.

Definition at line 726 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::negate().

bool Sawyer::Container::BitVector::increment ( const BitRange range1)
inline

Increment bits as integer.

Treats range1 of this vector as an integer and adds one to it, storing the result back into this vector. The range must be valid for this vector. Returns true if all bits were originally set and the result is all clear (i.e., returns the carry-out value) .

Definition at line 736 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::increment().

bool Sawyer::Container::BitVector::increment ( )
inline

Increment bits as integer.

Treats the entire vector as an integer and adds one to it, storing the result back into the vector. Returns true if all bits were originally set and the result is all clear (i.e., returns the carry-out value).

Definition at line 745 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::increment().

bool Sawyer::Container::BitVector::decrement ( const BitRange range1)
inline

Decrement bits as integer.

Treats range1 of this vector as an integer and subtracts one from it, storing the result back into this vector. The range must be valid for this vector. Returns true if all bits were originally clear and the result is all set (i.e., returns the overflow bit) .

Definition at line 754 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::decrement().

bool Sawyer::Container::BitVector::decrement ( )
inline

Decrement bits as integer.

Treats the entire vector as an integer and subtracts one from it, storing the result back into the vector. Returns true if all bits were originally clear and the result is all set (i.e., returns the overflow bit).

Definition at line 763 of file BitVector.h.

References data(), Sawyer::Container::BitVectorSupport::decrement(), and hull().

bool Sawyer::Container::BitVector::add ( const BitRange range1,
const BitVector other,
const BitRange range2 
)
inline

Add bits as integers.

Treats range1 of this vector and range2 of the other vector as integers, sums them, and stores the result in range1 of this vector. The ranges must be valid for their respective vectors, and both ranges must be the same size. The other vector is permitted to be the same vector as this, in which case the ranges are also permitted to overlap. Returns the final carry-out value which is not stored in the result.

Definition at line 773 of file BitVector.h.

References Sawyer::Container::BitVectorSupport::add(), checkRange(), and data().

bool Sawyer::Container::BitVector::add ( const BitRange range1,
const BitRange range2 
)
inline

Add bits as integers.

Treats range1 and range2 of this vector as integers, sums them, and stores the result in range1. The ranges must be valid for this vector and both ranges must be the same size. The are permitted to overlap. Returns the final carry-out value which is not stored in the result.

Definition at line 784 of file BitVector.h.

References Sawyer::Container::BitVectorSupport::add(), checkRange(), and data().

bool Sawyer::Container::BitVector::add ( const BitVector other)
inline

Add bits as integers.

Treats this vector and the other vector as integers, sums them, and stores the result in this vector. Both vectors must be the same size. The other vector is permitted to be the same as this vector, in which case it numerically doubles the value (like a left shift by one bit). Returns the final carry-out value which is not stored in the result.

Definition at line 796 of file BitVector.h.

References Sawyer::Container::BitVectorSupport::add(), data(), and hull().

bool Sawyer::Container::BitVector::subtract ( const BitRange range1,
const BitVector other,
const BitRange range2 
)
inline

Subtract bits as integers.

Treats range1 of this vector and range2 of the other vector as integers, subtracts other from this, and stores the result in range1 of this vector. The ranges must be valid for their respective vectors, and both ranges must be the same size. The other vector is permitted to be the same vector as this, in which case the ranges are also permitted to overlap. Returns false only when an overflow occurs (i.e., the integer interpretation of this vector is unsigned-greater-than the integer from the other vector). If the vectors are interpreted as two's complement signed integers then an overflow is indicated when both operands have the same sign and the result has a different sign.

Definition at line 809 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::subtract().

bool Sawyer::Container::BitVector::subtract ( const BitRange range1,
const BitRange range2 
)
inline

Subtract bits as integers.

Treats range1 and range2 of this vector as integers, subtracts the integer in range2 from the integer in range1, and stores the result in range1 of this vector. The ranges must be valid for this vector, and both ranges must be the same size. The ranges are permitted to overlap. Returns false only when an overflow occurs (i.e., the integer interpretation of range1 is unsigned-greater-than the integer from range2). If the ranges are interpreted as containing two's complement signed integers then an overflow is indicated when both operands have the same sign and the result has a different sign.

Definition at line 823 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::subtract().

bool Sawyer::Container::BitVector::subtract ( const BitVector other)
inline

Subtract bits as integers.

Treats this vector and the other vector as integers, subtracts other from this, and stores the result in this vector. Both vectors must be the same size. The other vector is permitted to be the same as this vector, in which case this vector is filled with zero.

Definition at line 834 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::subtract().

BitVector& Sawyer::Container::BitVector::signExtend ( const BitRange range1,
const BitVector other,
const BitRange range2 
)
inline

Copy bits and sign extend.

Copies bits from range2 of the other vector to range1 of this vector while sign extending. That is, if the destination is larger than the source, the most significant bit of the source is repeated to fill the high order bits of the destination. Both ranges must be valid for their respective vectors. The other vector is permitted to be the same as this vector, in which case the ranges are also permitted to overlap.

Definition at line 844 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::signExtend().

BitVector& Sawyer::Container::BitVector::signExtend ( const BitRange range1,
const BitRange range2 
)
inline

Copy bits and sign extend.

Copies bits from range2 of this vector to range1 of this vector while sign extending. That is, if the destination is larger than the source, the most significant bit of the source is repeated to fill the high order bits of the destination. Both ranges must be valid for this vector, and are permitted to overlap.

Definition at line 856 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::signExtend().

BitVector& Sawyer::Container::BitVector::signExtend ( const BitVector other)
inline

Copy bits and sign extend.

Copies bits from the other vector to this vector while sign extending. That is, if the destination is larger than the source, the most significant bit of the source is repeated to fill the high order bits of the destination.

Definition at line 867 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::signExtend().

BitVector& Sawyer::Container::BitVector::multiply10 ( )
inline

Multiply by 10.

Threats this vector as an unsigned integer and multiplies it by 10. If the product doesn't fit in the same vector then the high order bits of the product are truncated.

Definition at line 876 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::multiply10().

BitVector& Sawyer::Container::BitVector::multiply10 ( const BitRange range)
inline

Multiply by 10.

Treats range of this vector as an unsigned integer and multiplies it by 10, storing the result back into the same range, possibly truncating the result in the process.

Definition at line 885 of file BitVector.h.

References data(), and Sawyer::Container::BitVectorSupport::multiply10().

BitVector& Sawyer::Container::BitVector::invert ( const BitRange range)
inline

Invert bits.

Each bit in the specified range is inverted. The range must be valid for this vector.

Definition at line 901 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::invert().

BitVector& Sawyer::Container::BitVector::invert ( )
inline

Invert bits.

Each bit in this vector is inverted.

Definition at line 910 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::invert().

BitVector& Sawyer::Container::BitVector::bitwiseAnd ( const BitRange range1,
const BitVector other,
const BitRange range2 
)
inline

Bit-wise AND.

Computes the bit-wise AND of range1 from this vector and range2 of the other vector, storing the result in range1. The ranges must be valid for their respective vectors and must be the same size. The other vector is permitted to refer to this vector, in which case the ranges are also permitted to overlap.

Definition at line 920 of file BitVector.h.

References Sawyer::Container::BitVectorSupport::bitwiseAnd(), checkRange(), and data().

BitVector& Sawyer::Container::BitVector::bitwiseAnd ( const BitRange range1,
const BitRange range2 
)
inline

Bit-wise AND.

Computes the bit-wise AND of range1 and range2 of this vector, storing the result in range1. The ranges must be valid for this vector and must be the same size. They are permitted to overlap.

Definition at line 931 of file BitVector.h.

References Sawyer::Container::BitVectorSupport::bitwiseAnd(), checkRange(), and data().

BitVector& Sawyer::Container::BitVector::bitwiseAnd ( const BitVector other)
inline

Bit-wise AND.

Computes the bit-wise AND of this vector and the other vector, storing the result in this vector. The vectors must be the same size.

Definition at line 942 of file BitVector.h.

References Sawyer::Container::BitVectorSupport::bitwiseAnd(), data(), and hull().

BitVector& Sawyer::Container::BitVector::bitwiseOr ( const BitRange range1,
const BitVector other,
const BitRange range2 
)
inline

Bit-wise OR.

Computes the bit-wise OR of range1 from this vector and range2 of the other vector, storing the result in range1. The ranges must be valid for their respective vectors and must be the same size. The other vector is permitted to refer to this vector, in which case the ranges are also permitted to overlap.

Definition at line 952 of file BitVector.h.

References Sawyer::Container::BitVectorSupport::bitwiseOr(), checkRange(), and data().

BitVector& Sawyer::Container::BitVector::bitwiseOr ( const BitRange range1,
const BitRange range2 
)
inline

Bit-wise OR.

Computes the bit-wise OR of range1 and range2 of this vector, storing the result in range1. The ranges must be valid for this vector and must be the same size. They are permitted to overlap.

Definition at line 963 of file BitVector.h.

References Sawyer::Container::BitVectorSupport::bitwiseOr(), checkRange(), and data().

BitVector& Sawyer::Container::BitVector::bitwiseOr ( const BitVector other)
inline

Bit-wise OR.

Computes the bit-wise OR of this vector and the other vector, storing the result in this vector. The vectors must be the same size.

Definition at line 974 of file BitVector.h.

References Sawyer::Container::BitVectorSupport::bitwiseOr(), data(), and hull().

BitVector& Sawyer::Container::BitVector::bitwiseXor ( const BitRange range1,
const BitVector other,
const BitRange range2 
)
inline

Bit-wise XOR.

Computes the bit-wise XOR of range1 from this vector and range2 of the other vector, storing the result in range1. The ranges must be valid for their respective vectors and must be the same size. The other vector is permitted to refer to this vector, in which case the ranges are also permitted to overlap.

Definition at line 984 of file BitVector.h.

References Sawyer::Container::BitVectorSupport::bitwiseXor(), checkRange(), and data().

BitVector& Sawyer::Container::BitVector::bitwiseXor ( const BitRange range1,
const BitRange range2 
)
inline

Bit-wise XOR.

Computes the bit-wise XOR of range1 and range2 of this vector, storing the result in range1. The ranges must be valid for this vector and must be the same size. They are permitted to overlap.

Definition at line 995 of file BitVector.h.

References Sawyer::Container::BitVectorSupport::bitwiseXor(), checkRange(), and data().

BitVector& Sawyer::Container::BitVector::bitwiseXor ( const BitVector other)
inline

Bit-wise XOR.

Computes the bit-wise XOR of this vector and the other vector, storing the result in this vector. The vectors must be the same size.

Definition at line 1006 of file BitVector.h.

References Sawyer::Container::BitVectorSupport::bitwiseXor(), data(), and hull().

bool Sawyer::Container::BitVector::isEqualToZero ( const BitRange range) const
inline

Compare to zero.

Compares the integer value referred to by the specified range with zero. Returns true if the value is equal to zero the range is empty.

See also
isAllClear

Definition at line 1021 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::isEqualToZero().

bool Sawyer::Container::BitVector::isEqualToZero ( ) const
inline

Compare to zero.

Returns true if this vector is empty all bits are false.

See also
isAllClear

Definition at line 1031 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::isEqualToZero().

int Sawyer::Container::BitVector::compare ( const BitRange range1,
const BitVector other,
const BitRange range2 
) const
inline

Compare bits as integers.

Compares range1 from this vector with range2 from the other vector as integers and returns a value whose sign indicates the ordering relationship between the two ranges. Returns negative if the range1 value is less than the range2 value, returns zero if they are equal, and returns positive if the range1 value is greater than the range2 value. The ranges must be valid for their respective vectors, and need not be the same size (the smaller range will be temporarily zero extended on its most significant end). An empty range is treated as zero. The other vector is permitted to refer to this vector, in which case the ranges are also permitted to overlap.

Definition at line 1043 of file BitVector.h.

References checkRange(), Sawyer::Container::BitVectorSupport::compare(), and data().

int Sawyer::Container::BitVector::compare ( const BitRange range1,
const BitRange range2 
) const
inline

Compare bits as integers.

Compares range1 and range2 from this vector as integers and returns a value whose sign indicates the ordering relationship between the two ranges. Returns negative if the range1 value is less than the range2 value, returns zero if they are equal, and returns positive if the range1 value is greater than the range2 value. The ranges must be valid for this vector, and need not be the same size (the smaller range will be temporarily zero extended on its most significant end). An empty range is interpreted as zero. The ranges are permitted to overlap.

Definition at line 1056 of file BitVector.h.

References checkRange(), Sawyer::Container::BitVectorSupport::compare(), and data().

int Sawyer::Container::BitVector::compare ( const BitVector other) const
inline

Compare bits as integers.

Compares the bits of this vector with the bits of other as integers and returns a value whose sign indicates the ordering relationship between the two ranges. Returns negative if this value is less than the other value, returns zero if they are equal, and returns positive if this value is greater than the other value. The vectors need not be the same size (the smaller vector will be temporarily zero extended on its most significant end). An empty vector is treated as zero.

Definition at line 1069 of file BitVector.h.

References Sawyer::Container::BitVectorSupport::compare(), data(), and hull().

int Sawyer::Container::BitVector::compareSigned ( const BitRange range1,
const BitVector other,
const BitRange range2 
) const
inline

Compare bits as signed integers.

Compares range1 from this vector with range2 from the other vector as signed, two's complement integers and returns a value whose sign indicates the ordering relationship between the two ranges. Returns negative if the range1 value is less than the range2 value, returns zero if they are equal, and returns positive if the range1 value is greater than the range2 value. The ranges must be valid for their respective vectors, and need not be the same size (the smaller range will be temporarily zero extended on its most significant end). An empty range is treated as zero. The other vector is permitted to refer to this vector, in which case the ranges are also permitted to overlap.

Definition at line 1082 of file BitVector.h.

References checkRange(), Sawyer::Container::BitVectorSupport::compareSigned(), and data().

int Sawyer::Container::BitVector::compareSigned ( const BitRange range1,
const BitRange range2 
) const
inline

Compare bits as signed integers.

Compares range1 and range2 from this vector as signed, two's complement integers and returns a value whose sign indicates the ordering relationship between the two ranges. Returns negative if the range1 value is less than the range2 value, returns zero if they are equal, and returns positive if the range1 value is greater than the range2 value. The ranges must be valid for this vector, and need not be the same size (the smaller range will be temporarily zero extended on its most significant end). An empty range is interpreted as zero. The ranges are permitted to overlap.

Definition at line 1096 of file BitVector.h.

References checkRange(), Sawyer::Container::BitVectorSupport::compareSigned(), and data().

int Sawyer::Container::BitVector::compareSigned ( const BitVector other) const
inline

Compare bits as signed integers.

Compares the bits of this vector with the bits of other as signed, two's complement integers and returns a value whose sign indicates the ordering relationship between the two ranges. Returns negative if this value is less than the other value, returns zero if they are equal, and returns positive if this value is greater than the other value. The vectors need not be the same size (the smaller vector will be temporarily zero extended on its most significant end). An empty vector is treated as zero.

Definition at line 1109 of file BitVector.h.

References Sawyer::Container::BitVectorSupport::compareSigned(), data(), and hull().

boost::uint64_t Sawyer::Container::BitVector::toInteger ( const BitRange range) const
inline

Interpret bits as an unsigned integer.

Returns the bits of the specified range by interpreting them as an unsigned integer. The range must be valid for this vector. If the range contains more than 64 bits then only the low-order 64 bits are considered.

Definition at line 1121 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::toInteger().

boost::uint64_t Sawyer::Container::BitVector::toInteger ( ) const
inline

Interpret bits as an unsigned integer.

Returns the bits of this vector by interpreting them as an unsigned integer. If this vector contains more than 64 bits then only the low-order 64 bits are considered.

Definition at line 1130 of file BitVector.h.

References data(), hull(), size(), and Sawyer::Container::BitVectorSupport::toInteger().

std::string Sawyer::Container::BitVector::toHex ( const BitRange range) const
inline

Convert to a hexadecimal string.

Returns a string which is the hexadecimal representation of the bits in the specified range. The range must be valid for this vector. No prefix or suffix is added (e.g., no leading "0x" or trailing "h"). The number of digits in the return value is the minimum required to explicitly represent each bit of the range, including leading zeros; an empty range will return an empty string. The returned string is lower case.

Definition at line 1142 of file BitVector.h.

References data(), and Sawyer::Container::BitVectorSupport::toHex().

Referenced by Sawyer::Container::AddressMapConstraints< AddressMap >::print().

std::string Sawyer::Container::BitVector::toHex ( ) const
inline

Convert to a hexadecimal string.

Returns a string which is the hexadecimal representation of the bits in this vector. No prefix or suffix is added (e.g., no leading "0x" or trailing "h"). The number of digits in the return value is the minimum required to explicitly represent each bit of the vector, including leading zeros; an empty vector will return an empty string. The returned string is lower case.

Definition at line 1152 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::toHex().

std::string Sawyer::Container::BitVector::toOctal ( const BitRange range) const
inline

Convert to an octal string.

Returns a string which is the octal representation of the bits in the specified range. The range must be valid for this vector. No prefix or suffix is added (e.g., no extra leading "0" or trailing "o"). The number of digits in the return value is the minimum required to explicitly represent each bit of the range, including leading zeros; an empty range will return an empty string.

Definition at line 1162 of file BitVector.h.

References data(), and Sawyer::Container::BitVectorSupport::toOctal().

std::string Sawyer::Container::BitVector::toOctal ( ) const
inline

Convert to an octal string.

Returns a string which is the octal representation of the bits in this vector. No prefix or suffix is added (e.g., no leading "0" or trailing "o"). The number of digits in the return value is the minimum required to explicitly represent each bit of the vector, including leading zeros; an empty vector will return an empty string.

Definition at line 1171 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::toOctal().

std::string Sawyer::Container::BitVector::toBinary ( const BitRange range) const
inline

Convert to a binary string.

Returns a string which is the binary representation of the bits in the specified range. The range must be valid for this vector. No prefix or suffix is added (e.g., no extra leading or trailing "b"). The number of digits in the return value is the minimum required to explicitly represent each bit of the range, including leading zeros; an empty range will return an empty string.

Definition at line 1181 of file BitVector.h.

References data(), and Sawyer::Container::BitVectorSupport::toBinary().

std::string Sawyer::Container::BitVector::toBinary ( ) const
inline

Convert to an binary string.

Returns a string which is the binary representation of the bits in this vector. No prefix or suffix is added (e.g., no leading or trailing "b"). The number of digits in the return value is the minimum required to explicitly represent each bit of the vector, including leading zeros; an empty vector will return an empty string.

Definition at line 1190 of file BitVector.h.

References data(), hull(), and Sawyer::Container::BitVectorSupport::toBinary().

BitVector& Sawyer::Container::BitVector::fromInteger ( const BitRange range,
boost::uint64_t  value 
)
inline

Obtain bits from an integer.

Assigns the specified value to the bits indicated by range of this vector. If the range contains fewer than 64 bits then only the low order bits of value are used; if the range contains more than 64 bits then the high-order bits are cleared. The range must be a valid range for this vector.

Definition at line 1199 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::fromInteger().

Referenced by Sawyer::Container::AddressMapConstraints< AddressMap >::print().

BitVector& Sawyer::Container::BitVector::fromInteger ( boost::uint64_t  value)
inline

Obtain bits from an integer.

Assigns the specified value to this vector. If this vector contains fewer than 64 bits then only the low order bits of value are used; if this vector contains more than 64 bits then the high-order bits are cleared. The size of this vector is not changed by this operation.

See also
The assignment operator.

Definition at line 1212 of file BitVector.h.

References data(), Sawyer::Container::BitVectorSupport::fromInteger(), and hull().

BitVector& Sawyer::Container::BitVector::fromDecimal ( const BitRange range,
const std::string &  input 
)
inline

Obtains bits from a decimal representation.

Assigns the specified value, represented in decimal, to the specified range of this vector. The input string must contain only valid decimal digits '0' through '9' or the underscore character (to make long strings more readable), or else an std::runtime_error is thrown. The range must be valid for this vector. If the number of supplied digits is larger than what is required to initialize the specified range then the extra data is discarded. On the other hand, if the length of the string is insufficient to initialize the entire range then the high order bits of the range are cleared.

Definition at line 1226 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::fromDecimal().

Referenced by parse().

BitVector& Sawyer::Container::BitVector::fromDecimal ( const std::string &  input)
inline

Obtain bits from a decimal representation.

Assigns the specified value, represented in decimal, to this vector. The input string must contain only valid decimal digits '0' through '9' or the underscore character (to make long strings more readable), or else an std::runtime_error is thrown. If the number of supplied digits is larger than what is required to initialize this vector then the extra data is discarded. On the other hand, if the length of the string is insufficient to initialize the entire vector then the high order bits of the vector are cleared. The size of this vector is not changed by this operation.

Definition at line 1240 of file BitVector.h.

References data(), Sawyer::Container::BitVectorSupport::fromDecimal(), and hull().

BitVector& Sawyer::Container::BitVector::fromHex ( const BitRange range,
const std::string &  input 
)
inline

Obtain bits from a hexadecimal representation.

Assigns the specified value, represented in hexadecimal, to the specified range of this vector. The input string must contain only valid hexadecimal digits '0' through '9', 'a' through 'f', and 'A' through 'F', or the underscore character (to make long strings more readable), or else an std::runtime_error is thrown. The range must be valid for this vector. If the number of supplied digits is larger than what is required to initialize the specified range then the extra data is discarded. On the other hand, if the length of the string is insufficient to initialize the entire range then the high order bits of the range are cleared.

Definition at line 1253 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::fromHex().

Referenced by parse().

BitVector& Sawyer::Container::BitVector::fromHex ( const std::string &  input)
inline

Obtain bits from a hexadecimal representation.

Assigns the specified value, represented in hexadecimal, to this vector. The input string must contain only valid hexadecimal digits '0' through '9', 'a' through 'f', and 'A' through 'F', or the underscore character (to make long strings more readable), or else an std::runtime_error is thrown. If the number of supplied digits is larger than what is required to initialize this vector then the extra data is discarded. On the other hand, if the length of the string is insufficient to initialize the entire vector then the high order bits of the vector are cleared. The size of this vector is not changed by this operation.

Definition at line 1267 of file BitVector.h.

References data(), Sawyer::Container::BitVectorSupport::fromHex(), and hull().

BitVector& Sawyer::Container::BitVector::fromOctal ( const BitRange range,
const std::string &  input 
)
inline

Obtain bits from an octal representation.

Assigns the specified value, represented in octal, to the specified range of this vector. The input string must contain only valid octal digits '0' through '7' or the underscore character (to make long strings more readable), or else an std::runtime_error is thrown. The range must be valid for this vector. If the number of supplied digits is larger than what is required to initialize the specified range then the extra data is discarded. On the other hand, if the length of the string is insufficient to initialize the entire range then the high order bits of the range are cleared.

Definition at line 1280 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::fromOctal().

Referenced by parse().

BitVector& Sawyer::Container::BitVector::fromOctal ( const std::string &  input)
inline

Obtain bits from an octal representation.

Assigns the specified value, represented in octal, to this vector. The input string must contain only valid octal digits '0' through '7' or the underscore character (to make long strings more readable), or else an std::runtime_error is thrown. If the number of supplied digits is larger than what is required to initialize this vector then the extra data is discarded. On the other hand, if the length of the string is insufficient to initialize the entire vector then the high order bits of the vector are cleared. The size of this vector is not changed by this operation.

Definition at line 1294 of file BitVector.h.

References data(), Sawyer::Container::BitVectorSupport::fromOctal(), and hull().

BitVector& Sawyer::Container::BitVector::fromBinary ( const BitRange range,
const std::string &  input 
)
inline

Obtain bits from a binary representation.

Assigns the specified value, represented in binary, to the specified range of this vector. The input string must contain only valid binary digits '0' and '1' or the underscore character (to make long strings more readable), or else an std::runtime_error is thrown. The range must be valid for this vector. If the number of supplied digits is larger than what is required to initialize the specified range then the extra data is discarded. On the other hand, if the length of the string is insufficient to initialize the entire range then the high order bits of the range are cleared.

Definition at line 1307 of file BitVector.h.

References checkRange(), data(), and Sawyer::Container::BitVectorSupport::fromBinary().

Referenced by parse().

BitVector& Sawyer::Container::BitVector::fromBinary ( const std::string &  input)
inline

Obtain bits from a binary representation.

Assigns the specified value, represented in binary, to this vector. The input string must contain only valid binary digits '0' and '1' or the underscore character (to make long strings more readable), or else an std::runtime_error is thrown. If the number of supplied digits is larger than what is required to initialize this vector then the extra data is discarded. On the other hand, if the length of the string is insufficient to initialize the entire vector then the high order bits of the vector are cleared. The size of this vector is not changed by this operation.

Definition at line 1321 of file BitVector.h.

References data(), Sawyer::Container::BitVectorSupport::fromBinary(), and hull().

void Sawyer::Container::BitVector::checkRange ( const BitRange range) const
inline
Word* Sawyer::Container::BitVector::data ( )
inline
const Word* Sawyer::Container::BitVector::data ( ) const
inline

Raw data for vector.

Returns a pointer to the raw data for the vector. This is mostly for internal use so that the raw data can be passed to the BitVectorSupport functions.

Definition at line 1348 of file BitVector.h.

size_t Sawyer::Container::BitVector::dataSize ( ) const
inline

Raw data size.

Returns the number of elements of type Word in the array returned by the data method.

Definition at line 1356 of file BitVector.h.


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