TiledArray  0.7.0
TiledArray::detail::Bitset< Block > Class Template Reference

Fixed size bitset. More...

#include <bitset.h>

Classes

class  reference
 

Public Types

typedef Bitset< Block > Bitset_
 This object type. More...
 
typedef Block block_type
 The type used to store the data. More...
 
typedef Block value_type
 The value type. More...
 
typedef Block const_reference
 Constant reference to a bit. More...
 
typedef std::size_t size_type
 indexing size type More...
 
typedef UnaryTransformIterator< Block, ConstTransformOp > const_iterator
 Const iterator type. More...
 
typedef UnaryTransformIterator< Block, TransformOp > iterator
 Iterator type. More...
 

Public Member Functions

 Bitset (size_type s)
 Construct a bitset that contains s bits. More...
 
template<typename InIter >
 Bitset (InIter first, InIter last)
 Construct a bitset that contains s bits. More...
 
 Bitset (const Bitset< Block > &other)
 Copy constructor for bitset. More...
 
 ~Bitset ()
 Destructor. More...
 
Bitset< Block > & operator= (const Bitset< Block > &other)
 Assignment operator. More...
 
Bitset< Block > & operator|= (const Bitset< Block > &other)
 Or-assignment operator. More...
 
Bitset< Block > & operator &= (const Bitset< Block > &other)
 And-assignment operator. More...
 
Bitset< Block > & operator^= (const Bitset< Block > &other)
 And-assignment operator. More...
 
Bitset< Block > & operator<<= (size_type n)
 
Bitset< Block > operator<< (size_type n)
 
Bitset< Block > & operator>>= (size_type n)
 
Bitset< Block > operator>> (size_type n)
 
const_reference operator[] (size_type i) const
 Bit accessor operator. More...
 
reference operator[] (size_type i)
 
 operator bool () const
 
bool operator! () const
 
const_iterator begin () const
 
iterator begin ()
 
const_iterator end () const
 
iterator end ()
 
void set (size_type i, bool value=true)
 Set a bit value. More...
 
void set ()
 Set all bits. More...
 
void set_range (size_type first, size_type last)
 Set all bits from first to last. More...
 
void set_stride (size_type first, size_type stride)
 Set elements separated by stride. More...
 
void reset (size_type i)
 Reset a bit. More...
 
void reset ()
 Set all bits. More...
 
void flip (size_type i)
 Flip a bit. More...
 
void flip ()
 Flip all bits. More...
 
size_type count () const
 Count the number of non-zero bits. More...
 
const block_typeget () const
 Data pointer accessor. More...
 
block_typeget ()
 Data pointer accessor. More...
 
size_type size () const
 Bitset size. More...
 
size_type num_blocks () const
 Bitset block size. More...
 
void swap (Bitset_ &other)
 

Detailed Description

template<typename Block = unsigned long>
class TiledArray::detail::Bitset< Block >

Fixed size bitset.

Bitset is similar to std::bitset except the size is set at runtime. This bit set has very limited functionality, because it is only intended to fit the needs of SparseShape. The block type may be an integral or char type.

Template Parameters
BlockThe type used to store the data [ default = unsigned long ]

Definition at line 40 of file bitset.h.

Member Typedef Documentation

◆ Bitset_

template<typename Block = unsigned long>
typedef Bitset<Block> TiledArray::detail::Bitset< Block >::Bitset_

This object type.

Definition at line 157 of file bitset.h.

◆ block_type

template<typename Block = unsigned long>
typedef Block TiledArray::detail::Bitset< Block >::block_type

The type used to store the data.

Definition at line 158 of file bitset.h.

◆ const_iterator

template<typename Block = unsigned long>
typedef UnaryTransformIterator<Block, ConstTransformOp> TiledArray::detail::Bitset< Block >::const_iterator

Const iterator type.

Definition at line 162 of file bitset.h.

◆ const_reference

template<typename Block = unsigned long>
typedef Block TiledArray::detail::Bitset< Block >::const_reference

Constant reference to a bit.

Definition at line 160 of file bitset.h.

◆ iterator

template<typename Block = unsigned long>
typedef UnaryTransformIterator<Block, TransformOp> TiledArray::detail::Bitset< Block >::iterator

Iterator type.

Definition at line 163 of file bitset.h.

◆ size_type

template<typename Block = unsigned long>
typedef std::size_t TiledArray::detail::Bitset< Block >::size_type

indexing size type

Definition at line 161 of file bitset.h.

◆ value_type

template<typename Block = unsigned long>
typedef Block TiledArray::detail::Bitset< Block >::value_type

The value type.

Definition at line 159 of file bitset.h.

Constructor & Destructor Documentation

◆ Bitset() [1/3]

template<typename Block = unsigned long>
TiledArray::detail::Bitset< Block >::Bitset ( size_type  s)
inline

Construct a bitset that contains s bits.

Parameters
sThe number of bits
Exceptions
std::bad_allocIf bitset allocation fails.

Definition at line 169 of file bitset.h.

Here is the call graph for this function:

◆ Bitset() [2/3]

template<typename Block = unsigned long>
template<typename InIter >
TiledArray::detail::Bitset< Block >::Bitset ( InIter  first,
InIter  last 
)
inline

Construct a bitset that contains s bits.

Template Parameters
InIterThe input iterator type
Parameters
firstThe first element of a set of bits to be set
lastThe last element of a set of bits to be set
Exceptions
std::bad_allocIf bitset allocation fails.

Definition at line 184 of file bitset.h.

Here is the call graph for this function:

◆ Bitset() [3/3]

template<typename Block = unsigned long>
TiledArray::detail::Bitset< Block >::Bitset ( const Bitset< Block > &  other)
inline

Copy constructor for bitset.

Parameters
otherThe bitset to copy
Exceptions
std::bad_allocIf bitset allocation fails.

Definition at line 201 of file bitset.h.

Here is the call graph for this function:

◆ ~Bitset()

template<typename Block = unsigned long>
TiledArray::detail::Bitset< Block >::~Bitset ( )
inline

Destructor.

Definition at line 210 of file bitset.h.

Member Function Documentation

◆ begin() [1/2]

template<typename Block = unsigned long>
const_iterator TiledArray::detail::Bitset< Block >::begin ( ) const
inline

Definition at line 406 of file bitset.h.

◆ begin() [2/2]

template<typename Block = unsigned long>
iterator TiledArray::detail::Bitset< Block >::begin ( )
inline

Definition at line 410 of file bitset.h.

◆ count()

template<typename Block = unsigned long>
size_type TiledArray::detail::Bitset< Block >::count ( ) const
inline

Count the number of non-zero bits.

Returns
The number of non-zero bits

Definition at line 520 of file bitset.h.

◆ end() [1/2]

template<typename Block = unsigned long>
const_iterator TiledArray::detail::Bitset< Block >::end ( ) const
inline

Definition at line 414 of file bitset.h.

Here is the caller graph for this function:

◆ end() [2/2]

template<typename Block = unsigned long>
iterator TiledArray::detail::Bitset< Block >::end ( )
inline

Definition at line 418 of file bitset.h.

◆ flip() [1/2]

template<typename Block = unsigned long>
void TiledArray::detail::Bitset< Block >::flip ( size_type  i)
inline

Flip a bit.

Parameters
iThe bit to be flipped
Exceptions
std::out_of_rangeWhen i is >= size.

Definition at line 504 of file bitset.h.

◆ flip() [2/2]

template<typename Block = unsigned long>
void TiledArray::detail::Bitset< Block >::flip ( )
inline

Flip all bits.

Exceptions
nothing

Definition at line 512 of file bitset.h.

◆ get() [1/2]

template<typename Block = unsigned long>
const block_type* TiledArray::detail::Bitset< Block >::get ( ) const
inline

Data pointer accessor.

The pointer to the data points to a contiguous block of memory of type block_type that contains num_blocks() elements.

Returns
A pointer to the first element of the bitset data
Exceptions
nothing

Definition at line 538 of file bitset.h.

Here is the caller graph for this function:

◆ get() [2/2]

template<typename Block = unsigned long>
block_type* TiledArray::detail::Bitset< Block >::get ( )
inline

Data pointer accessor.

The pointer to the data points to a contiguous block of memory of type block_type that contains num_blocks() elements.

Returns
A pointer to the first element of the bitset data
Exceptions
nothing

Definition at line 547 of file bitset.h.

◆ num_blocks()

template<typename Block = unsigned long>
size_type TiledArray::detail::Bitset< Block >::num_blocks ( ) const
inline

Bitset block size.

Returns
Number of block_type elements used to store the bitset array.
Exceptions
nothing

Definition at line 559 of file bitset.h.

◆ operator &=()

template<typename Block = unsigned long>
Bitset<Block>& TiledArray::detail::Bitset< Block >::operator&= ( const Bitset< Block > &  other)
inline

And-assignment operator.

And-assign all bits from the two ranges

Parameters
otherThe bitset to be and-assigned to this bitset
Exceptions
std::range_errorIf the bitset sizes are not equal.

Definition at line 249 of file bitset.h.

◆ operator bool()

template<typename Block = unsigned long>
TiledArray::detail::Bitset< Block >::operator bool ( ) const
inline

Definition at line 388 of file bitset.h.

Here is the call graph for this function:

◆ operator!()

template<typename Block = unsigned long>
bool TiledArray::detail::Bitset< Block >::operator! ( ) const
inline

Definition at line 397 of file bitset.h.

Here is the call graph for this function:

◆ operator<<()

template<typename Block = unsigned long>
Bitset<Block> TiledArray::detail::Bitset< Block >::operator<< ( size_type  n)
inline

Definition at line 351 of file bitset.h.

◆ operator<<=()

template<typename Block = unsigned long>
Bitset<Block>& TiledArray::detail::Bitset< Block >::operator<<= ( size_type  n)
inline

Definition at line 343 of file bitset.h.

Here is the call graph for this function:

◆ operator=()

template<typename Block = unsigned long>
Bitset<Block>& TiledArray::detail::Bitset< Block >::operator= ( const Bitset< Block > &  other)
inline

Assignment operator.

This will only copy the data from other. It will not change the size of the bitset.

Parameters
otherThe bitset to copy
Exceptions
std::runtime_errorIf the bitset sizes are not equal.

Definition at line 218 of file bitset.h.

Here is the call graph for this function:

◆ operator>>()

template<typename Block = unsigned long>
Bitset<Block> TiledArray::detail::Bitset< Block >::operator>> ( size_type  n)
inline

Definition at line 366 of file bitset.h.

◆ operator>>=()

template<typename Block = unsigned long>
Bitset<Block>& TiledArray::detail::Bitset< Block >::operator>>= ( size_type  n)
inline

Definition at line 358 of file bitset.h.

Here is the call graph for this function:

◆ operator[]() [1/2]

template<typename Block = unsigned long>
const_reference TiledArray::detail::Bitset< Block >::operator[] ( size_type  i) const
inline

Bit accessor operator.

Parameters
iThe bit to access
Returns
The value of i-th bit of the bit set
Exceptions
std::out_of_rangeIf i is greater than or equal to the size

Definition at line 378 of file bitset.h.

◆ operator[]() [2/2]

template<typename Block = unsigned long>
reference TiledArray::detail::Bitset< Block >::operator[] ( size_type  i)
inline

Definition at line 383 of file bitset.h.

◆ operator^=()

template<typename Block = unsigned long>
Bitset<Block>& TiledArray::detail::Bitset< Block >::operator^= ( const Bitset< Block > &  other)
inline

And-assignment operator.

And-assign all bits from the two ranges

Parameters
otherThe bitset to be and-assigned to this bitset
Exceptions
std::range_errorIf the bitset sizes are not equal.

Definition at line 263 of file bitset.h.

◆ operator|=()

template<typename Block = unsigned long>
Bitset<Block>& TiledArray::detail::Bitset< Block >::operator|= ( const Bitset< Block > &  other)
inline

Or-assignment operator.

Or-assign all bits from the two ranges

Parameters
otherThe bitset to be or-assigned to this bitset
Exceptions
std::range_errorIf the bitset sizes are not equal.

Definition at line 236 of file bitset.h.

◆ reset() [1/2]

template<typename Block = unsigned long>
void TiledArray::detail::Bitset< Block >::reset ( size_type  i)
inline

Reset a bit.

Parameters
iThe bit to be reset
Exceptions
std::out_of_rangeWhen i is >= size.

Definition at line 488 of file bitset.h.

◆ reset() [2/2]

template<typename Block = unsigned long>
void TiledArray::detail::Bitset< Block >::reset ( )
inline

Set all bits.

Exceptions
nothing

Definition at line 496 of file bitset.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set() [1/2]

template<typename Block = unsigned long>
void TiledArray::detail::Bitset< Block >::set ( size_type  i,
bool  value = true 
)
inline

Set a bit value.

Parameters
iThe bit to be set
valueThe new value of the bit
Exceptions
std::out_of_rangeWhen i is >= size.

Definition at line 427 of file bitset.h.

Here is the call graph for this function:

◆ set() [2/2]

template<typename Block = unsigned long>
void TiledArray::detail::Bitset< Block >::set ( )
inline

Set all bits.

Exceptions
nothing

Definition at line 438 of file bitset.h.

◆ set_range()

template<typename Block = unsigned long>
void TiledArray::detail::Bitset< Block >::set_range ( size_type  first,
size_type  last 
)
inline

Set all bits from first to last.

Parameters
firstThe first bit in the range to set
lastThe last bit in the range to set

Definition at line 451 of file bitset.h.

◆ set_stride()

template<typename Block = unsigned long>
void TiledArray::detail::Bitset< Block >::set_stride ( size_type  first,
size_type  stride 
)
inline

Set elements separated by stride.

Parameters
firstThe first bit to set
strideThe distance between each set bit

Definition at line 479 of file bitset.h.

◆ size()

template<typename Block = unsigned long>
size_type TiledArray::detail::Bitset< Block >::size ( ) const
inline

Bitset size.

Returns
Number of bits in the bitset
Exceptions
nothing

Definition at line 553 of file bitset.h.

◆ swap()

template<typename Block = unsigned long>
void TiledArray::detail::Bitset< Block >::swap ( Bitset_ other)
inline

Definition at line 561 of file bitset.h.

Here is the call graph for this function:
Here is the caller graph for this function:

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