Stefan Scholz / ETL
Embed: (wiki syntax)

« Back to documentation index

bitset< MAXN > Class Template Reference

The class emulates an array of bool elements, but optimized for space allocation. More...

#include <bitset.h>

Inherits etl::ibitset.

Public Member Functions

 bitset ()
 Default constructor.
 bitset (const bitset< MAXN > &other)
 Copy constructor.
 bitset (unsigned long long value)
 Construct from a value.
 bitset (const char *text)
 Construct from a string.
bitset< MAXN > & set ()
 Set all of the bits.
bitset< MAXN > & set (size_t position, bool value=true)
 Set the bit at the position.
bitset< MAXN > & set (const char *text)
 Set from a string.
bitset< MAXN > & reset ()
 Reset all of the bits.
bitset< MAXN > & reset (size_t position)
 Reset the bit at the position.
bitset< MAXN > & flip ()
 Flip all of the bits.
bitset< MAXN > & flip (size_t position)
 Flip the bit at the position.
bitset< MAXN > & operator= (const bitset< MAXN > &other)
 operator =
bitset< MAXN > & operator&= (const bitset< MAXN > &other)
 operator &=
bitset< MAXN > & operator|= (const bitset< MAXN > &other)
 operator |=
bitset< MAXN > & operator^= (const bitset< MAXN > &other)
 operator ^=
bitset< MAXN > operator~ () const
 operator ~
bitset< MAXN > operator<< (size_t shift) const
 operator <<
bitset< MAXN > & operator<<= (size_t shift)
 operator <<=
bitset< MAXN > operator>> (size_t shift) const
 operator >>
bitset< MAXN > & operator>>= (size_t shift)
 operator >>=
size_t size () const
 The size of the bitset.
size_t count () const
 Count the number of bits set.
bool test (size_t position) const
 Tests a bit at a position.
bool any () const
 Are any of the bits set?
bool none () const
 Are none of the bits set?
size_t find_first (bool state) const
 Finds the first bit in the specified state.
size_t find_next (bool state, size_t position) const
 Finds the next bit in the specified state.
bool operator[] (size_t position) const
 Read [] operator.
bit_reference operator[] (size_t position)
 Write [] operator.
ibitsetoperator&= (const ibitset &other)
 operator &=
ibitsetoperator|= (const ibitset &other)
 operator |=
ibitsetoperator^= (const ibitset &other)
 operator ^=
void swap (ibitset &other)
 swap

Protected Member Functions

ibitsetinitialise (unsigned long long value)
 Initialise from an unsigned long long.
void invert ()
 Invert.
bit_reference get_bit_reference (size_t position)
 Gets a reference to the specified bit.

Static Protected Member Functions

static bool is_equal (const ibitset &lhs, const ibitset &rhs)
 Compare bitsets.

Friends

bool operator== (const bitset< MAXN > &lhs, const bitset< MAXN > &rhs)
 operator ==

Detailed Description

template<const size_t MAXN>
class etl::bitset< MAXN >

The class emulates an array of bool elements, but optimized for space allocation.

Will accommodate any number of bits. Does not use std::string.

Template Parameters:
NThe number of bits.

Definition at line 731 of file bitset.h.


Constructor & Destructor Documentation

bitset (  )

Default constructor.

Definition at line 745 of file bitset.h.

bitset ( const bitset< MAXN > &  other )

Copy constructor.

Definition at line 754 of file bitset.h.

bitset ( unsigned long long  value )

Construct from a value.

Definition at line 763 of file bitset.h.

bitset ( const char *  text )

Construct from a string.

Definition at line 772 of file bitset.h.


Member Function Documentation

bool any (  ) const [inherited]

Are any of the bits set?

Definition at line 412 of file bitset.h.

size_t count (  ) const [inherited]

Count the number of bits set.

Definition at line 209 of file bitset.h.

size_t find_first ( bool  state ) const [inherited]

Finds the first bit in the specified state.

Parameters:
stateThe state to search for.
Returns:
The position of the bit or SIZE if none were found.

Definition at line 438 of file bitset.h.

size_t find_next ( bool  state,
size_t  position 
) const [inherited]

Finds the next bit in the specified state.

Parameters:
stateThe state to search for.
positionThe position to start from.
Returns:
The position of the bit or SIZE if none were found.

Definition at line 449 of file bitset.h.

bitset<MAXN>& flip (  )

Flip all of the bits.

Reimplemented from ibitset.

Definition at line 828 of file bitset.h.

bitset<MAXN>& flip ( size_t  position )

Flip the bit at the position.

Reimplemented from ibitset.

Definition at line 837 of file bitset.h.

bit_reference get_bit_reference ( size_t  position ) [protected, inherited]

Gets a reference to the specified bit.

Definition at line 685 of file bitset.h.

ibitset& initialise ( unsigned long long  value ) [protected, inherited]

Initialise from an unsigned long long.

Definition at line 644 of file bitset.h.

void invert (  ) [protected, inherited]

Invert.

Definition at line 674 of file bitset.h.

static bool is_equal ( const ibitset lhs,
const ibitset rhs 
) [static, protected, inherited]

Compare bitsets.

Definition at line 706 of file bitset.h.

bool none (  ) const [inherited]

Are none of the bits set?

Definition at line 420 of file bitset.h.

bitset<MAXN>& operator&= ( const bitset< MAXN > &  other )

operator &=

Definition at line 859 of file bitset.h.

ibitset& operator&= ( const ibitset other ) [inherited]

operator &=

Definition at line 526 of file bitset.h.

bitset<MAXN> operator<< ( size_t  shift ) const

operator <<

Definition at line 898 of file bitset.h.

bitset<MAXN>& operator<<= ( size_t  shift )

operator <<=

Reimplemented from ibitset.

Definition at line 910 of file bitset.h.

bitset<MAXN>& operator= ( const bitset< MAXN > &  other )

operator =

Definition at line 846 of file bitset.h.

bitset<MAXN> operator>> ( size_t  shift ) const

operator >>

Definition at line 919 of file bitset.h.

bitset<MAXN>& operator>>= ( size_t  shift )

operator >>=

Reimplemented from ibitset.

Definition at line 931 of file bitset.h.

bool operator[] ( size_t  position ) const [inherited]

Read [] operator.

Definition at line 510 of file bitset.h.

bit_reference operator[] ( size_t  position ) [inherited]

Write [] operator.

Definition at line 518 of file bitset.h.

bitset<MAXN>& operator^= ( const bitset< MAXN > &  other )

operator ^=

Definition at line 877 of file bitset.h.

ibitset& operator^= ( const ibitset other ) [inherited]

operator ^=

Definition at line 552 of file bitset.h.

bitset<MAXN>& operator|= ( const bitset< MAXN > &  other )

operator |=

Definition at line 868 of file bitset.h.

ibitset& operator|= ( const ibitset other ) [inherited]

operator |=

Definition at line 539 of file bitset.h.

bitset<MAXN> operator~ (  ) const

operator ~

Definition at line 886 of file bitset.h.

bitset<MAXN>& reset (  )

Reset all of the bits.

Reimplemented from ibitset.

Definition at line 810 of file bitset.h.

bitset<MAXN>& reset ( size_t  position )

Reset the bit at the position.

Reimplemented from ibitset.

Definition at line 819 of file bitset.h.

bitset<MAXN>& set ( size_t  position,
bool  value = true 
)

Set the bit at the position.

Reimplemented from ibitset.

Definition at line 790 of file bitset.h.

bitset<MAXN>& set (  )

Set all of the bits.

Reimplemented from ibitset.

Definition at line 781 of file bitset.h.

bitset<MAXN>& set ( const char *  text )

Set from a string.

Reimplemented from ibitset.

Definition at line 799 of file bitset.h.

size_t size (  ) const [inherited]

The size of the bitset.

Definition at line 201 of file bitset.h.

void swap ( ibitset other ) [inherited]

swap

Definition at line 634 of file bitset.h.

bool test ( size_t  position ) const [inherited]

Tests a bit at a position.

Positions greater than the number of configured bits will return false.

Definition at line 225 of file bitset.h.


Friends And Related Function Documentation

bool operator== ( const bitset< MAXN > &  lhs,
const bitset< MAXN > &  rhs 
) [friend]

operator ==

Definition at line 940 of file bitset.h.