Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::BitArray Class Reference

Contiguous array of bits. More...

#include <bitArray.H>

Inheritance diagram for Aleph::BitArray:
[legend]
Collaboration diagram for Aleph::BitArray:
[legend]

Classes

class  BitProxy
 
class  Iterator
 

Public Types

using Item_Type = unsigned int
 Type returned by Iterator::get_curr() - individual bits as unsigned int.
 
using iterator = __iterator< BitArray >
 
using const_iterator = __const_iterator< BitArray >
 

Public Member Functions

 BitArray (const size_t dim=0)
 Bit array constructor.
 
 BitArray (const size_t dim, const unsigned int value)
 Build a BitArray of size dim with all bits set to value.
 
void reserve (const size_t dim)
 Reserve memory in advance for the bit array dim dimension.
 
constexpr size_t size () const noexcept
 Returns the dimension of the bit array.
 
void set_size (const size_t sz)
 Resets the dimension of the array.
 
int operator[] (const size_t i) const
 
BitProxy operator[] (const size_t i) noexcept
 
int read_bit_ne (const size_t i) const noexcept
 
int read_bit (const size_t i) const
 Read bit i.
 
int operator() (const size_t i) const
 
void write_bit (const size_t i, const unsigned int value)
 Write bit i with the value.
 
int read (const size_t i) const
 Quick read of bit i.
 
void write (const size_t i, const unsigned int value)
 Writes bit i with value without memory check.
 
int fast_read (const size_t i) const noexcept
 
void fast_write (const size_t i, const unsigned int value)
 
void push (const unsigned int value)
 Inserts the value at the end of the array.
 
void pop ()
 Removes the last bit of the array.
 
void empty () noexcept
 Delete all inserted bits.
 
 BitArray (const BitArray &array)
 Copy constructor.
 
void swap (BitArray &array) noexcept
 
 BitArray (BitArray &&array) noexcept
 
BitArrayoperator= (BitArray &&array) noexcept
 
DynList< charbits_list () const
 Converts it to a list.
 
BitArrayoperator= (const BitArray &array)
 Bit array allocation.
 
void save (std::ostream &output) const
 Saves the bit sequence in a text file.
 
void load (std::istream &input)
 Loads an array of bits from a file.
 
 BitArray (std::ifstream &input)
 Build a new array of bits from a file constructed using the save() method.
 
void save_in_array_of_chars (const std::string &name, std::ostream &output) const
 Saves a static string declaration to a text file.
 
void load_from_array_of_chars (const unsigned char str[], const size_t num_bits)
 Reads an array of bits saved in a character array.
 
void left_shift (const size_t n=1)
 Shifts the bits n positions to the left.
 
void right_shift (const size_t n=1)
 Shifts the bits n positions to the right.
 
void dyn_left_shift (const size_t n=1)
 Shifts bits n positions to the left dynamically.
 
void dyn_right_shift (const size_t n=1)
 Shifts bits n positions to the right dynamically.
 
void circular_left_shift (const size_t n=1)
 Shifts the bits n positions to the left circularly.
 
void circular_right_shift (const size_t n=1)
 Shifts the bits n positions to the right circularly.
 
template<typename T >
void set_num (T n)
 
void set_num (const char &c)
 
void set_num (const short &c)
 
void set_num (const int &c)
 
void set_num (const long &c)
 
unsigned long get_unum () const noexcept
 
long get_num () const noexcept
 
void set_bit_str (const std::string &str)
 
std::string get_bit_str () const
 
std::string to_string () const
 
 BitArray (const unsigned char str[], const size_t num_bits)
 Constructs a new array of bits from an array of characters previously generated with load_from_array_of_chars.
 
BitArrayoperator|= (const BitArray &rhs)
 
BitArrayoperator&= (const BitArray &rhs)
 
bool operator== (const BitArray &rhs) const
 
auto get_it () const noexcept
 
template<class Operation >
bool traverse (Operation &operation) const
 
template<class Operation >
bool traverse (Operation &operation)
 
template<class Operation >
bool traverse (Operation &&operation=Operation()) const
 
template<class Operation >
bool traverse (Operation &&operation=Operation())
 
template<template< typename > class Container = DynList>
Container< unsigned intitems () const
 
iterator begin () noexcept
 
iterator end () noexcept
 
const_iterator begin () const noexcept
 
const_iterator end () const noexcept
 
const_iterator cbegin () const noexcept
 
const_iterator cend () const noexcept
 
const_iterator cbegin () noexcept
 
const_iterator cend () noexcept
 
int count_ones () const noexcept
 
int count_zeros () const noexcept
 
- Public Member Functions inherited from Aleph::FunctionalMixin< BitArray, unsigned int >
auto for_each (Operation &operation) const -> decltype(self())
 Apply an operation to each element (read-only).
 
auto for_each (Operation &operation) -> decltype(self())
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
auto for_each (Operation &&operation=Operation()) const -> decltype(self())
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
auto for_each (Operation &&operation=Operation()) -> decltype(self())
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
auto mutable_for_each (Operation &operation) -> decltype(self())
 Apply an operation to each element (mutable).
 
auto mutable_for_each (Operation &&operation=Operation()) -> decltype(self())
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool all (Operation &operation) const
 Test if all elements satisfy a predicate.
 
bool all (Operation &&operation=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool forall (Operation &operation) const
 Alias for all().
 
bool forall (Operation &&operation=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool exists (Operation &operation) const
 Test if any element satisfies a predicate.
 
bool exists (Operation &&operation=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
Container< __Type > maps (Operation &operation) const
 Transform elements using a mapping function.
 
Container< __Type > maps (Operation &&operation=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
__Type foldl (const __Type &init, std::function< __Type(const __Type &, const unsigned int &)> operation) const
 Left fold (reduce) with initial value.
 
__Type fold_left (std::function< __Type(const __Type &, const unsigned int &)> operation, const __Type &init) const
 Left fold with operation first (alternative signature).
 
unsigned int fold (const unsigned int &init, Operation &operation) const
 Simple fold with same type for accumulator and elements.
 
unsigned int fold (const unsigned int &init, Operation &&operation=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
DynList< unsigned int > filter (Operation &operation) const
 Filter elements by a predicate.
 
DynList< unsigned int > filter (Operation &&operation=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
DynList< std::tuple< unsigned int, size_t > > pfilter (Operation &operation) const
 Filter with position information.
 
DynList< std::tuple< unsigned int, size_t > > pfilter (Operation &&operation=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
std::pair< DynList< unsigned int >, DynList< unsigned int > > partition (Operation &op) const
 Partition elements by a predicate.
 
std::pair< DynList< unsigned int >, DynList< unsigned int > > partition (Operation &&op=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
std::tuple< DynList< unsigned int >, DynList< unsigned int > > tpartition (Operation &op) const
 Partition returning tuple instead of pair.
 
std::tuple< DynList< unsigned int >, DynList< unsigned int > > tpartition (Operation &&op=Operation()) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
size_t length () const noexcept
 Count the number of elements.
 
Container< unsigned int > rev () const
 Create a reversed copy.
 
Container< unsigned int > take (const size_t n) const
 Take the first n elements.
 
Container< unsigned int > drop (const size_t n) const
 Skip the first n elements.
 
unsigned int sum (const unsigned int &init=unsigned int {}) const
 Compute the sum of all elements.
 
unsigned int product (const unsigned int &init) const
 Compute the product of all elements.
 
const unsigned int * min () const
 Find the minimum element.
 
const unsigned int * max () const
 Find the maximum element.
 
const unsigned int * min_by (Compare cmp) const
 Find the minimum element using a custom comparator.
 
const unsigned int * max_by (Compare cmp) const
 Find the maximum element using a custom comparator.
 
bool has_value (const unsigned int &val) const
 Check if container has a value.
 
bool none (Predicate &pred) const
 Check if no element satisfies a predicate.
 
bool none (Predicate &&pred) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
size_t count_if (Predicate pred) const
 Count elements satisfying a predicate.
 
const unsigned int * first () const
 Get the first element.
 
unsigned int first_or (const unsigned int &default_val) const
 Get the first element or a default value.
 
const unsigned int * last () const
 Get the last element.
 
unsigned int last_or (const unsigned int &default_val) const
 Get the last element or a default value.
 
Container< std::pair< size_t, unsigned int > > enumerate () const
 Enumerate elements with their indices.
 
size_t find_index (Predicate pred) const
 Find the index of the first element satisfying a predicate.
 
size_t index_of (const unsigned int &val) const
 Find the index of a specific value.
 
Container< unsigned int > unique () const
 Remove consecutive duplicate elements.
 
Container< unsigned int > unique_by (EqPred eq) const
 Remove consecutive duplicates using a custom equality predicate.
 
Container< unsigned int > intersperse (const unsigned int &sep) const
 Intersperse a separator between elements.
 
Container< Container< unsigned int > > chunk (size_t n) const
 Split into chunks of fixed size.
 
Container< Container< unsigned int > > sliding (size_t size, size_t step=1) const
 Create sliding windows of fixed size.
 
std::vector< unsigned int > to_vector () const
 Convert to std::vector.
 
DynListType to_dynlist () const
 Convert container to DynList.
 
StringType join (const StringType &sep=StringType{", "}) const
 Join elements into a string with separator.
 
std::string join_str (const std::string &sep=", ") const
 Join string elements with separator.
 
Container< std::pair< unsigned int, typename Other::Item_Type > > zip_with (const Other &other) const
 Zip with another container.
 

Private Member Functions

void clear_unused_bits_in_last_byte () noexcept
 
void ensure_num_bytes (const size_t num_bytes)
 
size_t get_num_bytes () const noexcept
 
template<class Operation >
bool __traverse (Operation &operation)
 

Private Attributes

size_t current_size
 
DynArray< Bytearray_of_bytes
 

Friends

std::ostream & operator<< (std::ostream &out, const BitArray &array)
 
BitArray operator| (const BitArray &op1, const BitArray &op2)
 
BitArray operator& (const BitArray &op1, const BitArray &op2)
 
const_iterator cbegin (const BitArray &s) noexcept
 
const_iterator cend (const BitArray &s) noexcept
 
const_iterator begin (const BitArray &s) noexcept
 
const_iterator end (const BitArray &s) noexcept
 
iterator begin (BitArray &s) noexcept
 
iterator end (BitArray &s) noexcept
 

Additional Inherited Members

- Protected Member Functions inherited from Aleph::FunctionalMixin< BitArray, unsigned int >
const BitArrayself () const noexcept
 
BitArrayself () noexcept
 

Detailed Description

Contiguous array of bits.

BitArray defines a contiguous array of bits. The consumption of memory is proportional to n/8; where n is the number of bits that you want to manage.

The array is dynamic, which means it can expand dynamically according to need.

Access to the ith bit can be done using the operator []. However, since this kind of access is implemented using a proxy class, access may fail in some expressions where the compiler cannot carry out the appropriate type transformations.

Author
Alejandro Mujica
Leandro Rabindranath Leon

Definition at line 188 of file bitArray.H.

Member Typedef Documentation

◆ const_iterator

◆ Item_Type

Type returned by Iterator::get_curr() - individual bits as unsigned int.

Definition at line 295 of file bitArray.H.

◆ iterator

Constructor & Destructor Documentation

◆ BitArray() [1/6]

Aleph::BitArray::BitArray ( const size_t  dim = 0)
inline

Bit array constructor.

Parameters
[in]dimnumber of bits. By default, it is 256.
Exceptions
bad_allocif there is not enough memory for a block continuous dim/8 bytes.

Definition at line 303 of file bitArray.H.

References array_of_bytes.

◆ BitArray() [2/6]

Aleph::BitArray::BitArray ( const size_t  dim,
const unsigned int  value 
)
inline

Build a BitArray of size dim with all bits set to value.

Definition at line 310 of file bitArray.H.

References dim(), Aleph::FunctionalMixin< BitArray, unsigned int >::maps(), and write_bit().

◆ BitArray() [3/6]

Aleph::BitArray::BitArray ( const BitArray array)
inline

Copy constructor.

Instantiates an array of bits exact copy of array.

Parameters
[in]arraythe array of bits to be copied.
Exceptions
bad_allocif there is not enough memory for a block continuous dim/8 bytes.

Definition at line 479 of file bitArray.H.

◆ BitArray() [4/6]

Aleph::BitArray::BitArray ( BitArray &&  array)
inlinenoexcept

Definition at line 491 of file bitArray.H.

References swap().

◆ BitArray() [5/6]

Aleph::BitArray::BitArray ( std::ifstream &  input)
inline

Build a new array of bits from a file constructed using the save() method.

Definition at line 623 of file bitArray.H.

References load(), and Aleph::FunctionalMixin< BitArray, unsigned int >::maps().

◆ BitArray() [6/6]

Aleph::BitArray::BitArray ( const unsigned char  str[],
const size_t  num_bits 
)
inline

Constructs a new array of bits from an array of characters previously generated with load_from_array_of_chars.

Definition at line 929 of file bitArray.H.

References load_from_array_of_chars().

Member Function Documentation

◆ __traverse()

template<class Operation >
bool Aleph::BitArray::__traverse ( Operation operation)
inlineprivate

◆ begin() [1/2]

const_iterator Aleph::BitArray::begin ( ) const
inlinenoexcept

Definition at line 1135 of file bitArray.H.

◆ begin() [2/2]

iterator Aleph::BitArray::begin ( )
inlinenoexcept

Definition at line 1135 of file bitArray.H.

◆ bits_list()

DynList< char > Aleph::BitArray::bits_list ( ) const
inline

◆ cbegin() [1/2]

const_iterator Aleph::BitArray::cbegin ( ) const
inlinenoexcept

Definition at line 1135 of file bitArray.H.

◆ cbegin() [2/2]

const_iterator Aleph::BitArray::cbegin ( )
inlinenoexcept

Definition at line 1135 of file bitArray.H.

◆ cend() [1/2]

const_iterator Aleph::BitArray::cend ( ) const
inlinenoexcept

Definition at line 1135 of file bitArray.H.

◆ cend() [2/2]

const_iterator Aleph::BitArray::cend ( )
inlinenoexcept

Definition at line 1135 of file bitArray.H.

◆ circular_left_shift()

void Aleph::BitArray::circular_left_shift ( const size_t  n = 1)
inline

Shifts the bits n positions to the left circularly.

The bits are shifted without losing any, the first n bits They begin to occupy the last n positions in the arrangement.

Parameters
[in]nthe number of positions to shift the bits.

Definition at line 788 of file bitArray.H.

References current_size, Aleph::FunctionalMixin< BitArray, unsigned int >::maps(), read_bit(), and write_bit().

◆ circular_right_shift()

void Aleph::BitArray::circular_right_shift ( const size_t  n = 1)
inline

Shifts the bits n positions to the right circularly.

The bits are shifted without losing any, the last n bits They come to occupy the first n positions in the arrangement.

Parameters
[in]nthe number of positions to shift the bits.

Definition at line 817 of file bitArray.H.

References current_size, Aleph::FunctionalMixin< BitArray, unsigned int >::maps(), read_bit(), and write_bit().

◆ clear_unused_bits_in_last_byte()

◆ count_ones()

int Aleph::BitArray::count_ones ( ) const
inlinenoexcept

◆ count_zeros()

int Aleph::BitArray::count_zeros ( ) const
inlinenoexcept

◆ dyn_left_shift()

void Aleph::BitArray::dyn_left_shift ( const size_t  n = 1)
inline

Shifts bits n positions to the left dynamically.

The bits are shifted without losing any and the array grows adding n zeros to the right.

Parameters
[in]nthe number of positions to shift the bits.

Definition at line 747 of file bitArray.H.

References push().

◆ dyn_right_shift()

void Aleph::BitArray::dyn_right_shift ( const size_t  n = 1)
inline

Shifts bits n positions to the right dynamically.

The bits are shifted without losing any and the array is decremented. eliminating the n zeros that would be on the left

Parameters
[in]nthe number of positions to shift the bits.

Definition at line 760 of file bitArray.H.

References clear_unused_bits_in_last_byte(), current_size, read_bit(), set_size(), and write_bit().

◆ empty()

void Aleph::BitArray::empty ( )
inlinenoexcept

Delete all inserted bits.

Definition at line 465 of file bitArray.H.

References array_of_bytes, and current_size.

Referenced by set_bit_str(), and set_num().

◆ end() [1/2]

const_iterator Aleph::BitArray::end ( ) const
inlinenoexcept

Definition at line 1135 of file bitArray.H.

◆ end() [2/2]

iterator Aleph::BitArray::end ( )
inlinenoexcept

Definition at line 1135 of file bitArray.H.

◆ ensure_num_bytes()

void Aleph::BitArray::ensure_num_bytes ( const size_t  num_bytes)
inlineprivate

Definition at line 211 of file bitArray.H.

References array_of_bytes.

Referenced by operator|=().

◆ fast_read()

int Aleph::BitArray::fast_read ( const size_t  i) const
inlinenoexcept

Definition at line 438 of file bitArray.H.

References array_of_bytes.

Referenced by Aleph::Bloom_Filter< T >::contains().

◆ fast_write()

void Aleph::BitArray::fast_write ( const size_t  i,
const unsigned int  value 
)
inline

Definition at line 443 of file bitArray.H.

References ah_out_of_range_error_if, and array_of_bytes.

Referenced by Aleph::Bloom_Filter< T >::insert().

◆ get_bit_str()

std::string Aleph::BitArray::get_bit_str ( ) const
inline

Definition at line 906 of file bitArray.H.

References current_size, Aleph::FunctionalMixin< BitArray, unsigned int >::maps(), and read_bit().

Referenced by to_string().

◆ get_it()

auto Aleph::BitArray::get_it ( ) const
inlinenoexcept

Definition at line 1105 of file bitArray.H.

◆ get_num()

long Aleph::BitArray::get_num ( ) const
inlinenoexcept

Definition at line 886 of file bitArray.H.

References get_unum().

◆ get_num_bytes()

size_t Aleph::BitArray::get_num_bytes ( ) const
inlineprivatenoexcept

Definition at line 223 of file bitArray.H.

References current_size.

Referenced by operator&=(), operator|=(), pop(), save(), and save_in_array_of_chars().

◆ get_unum()

unsigned long Aleph::BitArray::get_unum ( ) const
inlinenoexcept

◆ items()

template<template< typename > class Container = DynList>
Container< unsigned int > Aleph::BitArray::items ( ) const
inline

Definition at line 1133 of file bitArray.H.

◆ left_shift()

void Aleph::BitArray::left_shift ( const size_t  n = 1)
inline

Shifts the bits n positions to the left.

The bits are shifted and the array is considered a fixed size, that is, the first n bits are lost.

Parameters
[in]nthe number of positions to shift the bits.

Definition at line 711 of file bitArray.H.

References current_size, Aleph::FunctionalMixin< BitArray, unsigned int >::maps(), read_bit(), and write_bit().

◆ load()

void Aleph::BitArray::load ( std::istream &  input)
inline

Loads an array of bits from a file.

load(input) takes the file opened in input, previously saved with the load() method, and restores the array to the value saved.

Parameters
[in]inputstream where the arrangement and that must have been previously saved with save().

Definition at line 590 of file bitArray.H.

References ah_runtime_error_if, current_size, Aleph::FunctionalMixin< BitArray, unsigned int >::maps(), and swap().

Referenced by BitArray(), Aleph::Huffman_Encoder_Engine::load_tree(), and Aleph::load_tree().

◆ load_from_array_of_chars()

void Aleph::BitArray::load_from_array_of_chars ( const unsigned char  str[],
const size_t  num_bits 
)
inline

Reads an array of bits saved in a character array.

load_from_array_of_chars(str, num_bits) takes an array str, previously generated with save_in_array_of_chars, of num_bits long, and loads it.

Parameters
[in]strthe character array where the of is located bits.
[in]num_bitsthe number of bits in the array. Note that not is the same as the number of bytes.

Definition at line 687 of file bitArray.H.

References array_of_bytes, clear_unused_bits_in_last_byte(), and current_size.

Referenced by BitArray(), and Aleph::load_tree_from_array().

◆ operator&=()

◆ operator()()

int Aleph::BitArray::operator() ( const size_t  i) const
inline

Definition at line 383 of file bitArray.H.

References read_bit().

◆ operator=() [1/2]

BitArray & Aleph::BitArray::operator= ( BitArray &&  array)
inlinenoexcept

Definition at line 497 of file bitArray.H.

References array_of_bytes, current_size, and swap().

◆ operator=() [2/2]

Bit array allocation.

Release all memory of this, set aside new memory for host array and exactly copies the bits of array to this.

Parameters
[in]arraythe array of bits to be copied.
Exceptions
bad_allocif there is not enough memory for a block continuous dim/8 bytes.
Note
If this exception occurs, the state of this remains the same prior to assignment.

Definition at line 525 of file bitArray.H.

References array_of_bytes, and current_size.

◆ operator==()

◆ operator[]() [1/2]

int Aleph::BitArray::operator[] ( const size_t  i) const
inline

Definition at line 356 of file bitArray.H.

References read_bit().

◆ operator[]() [2/2]

Definition at line 358 of file bitArray.H.

◆ operator|=()

◆ pop()

void Aleph::BitArray::pop ( )
inline

◆ push()

void Aleph::BitArray::push ( const unsigned int  value)
inline

Inserts the value at the end of the array.

Definition at line 450 of file bitArray.H.

References current_size, and write_bit().

Referenced by Aleph::Huffman_Encoder_Engine::build_prefix_encoding(), dyn_left_shift(), TEST(), and Aleph::tree_to_bits().

◆ read()

int Aleph::BitArray::read ( const size_t  i) const
inline

Quick read of bit i.

Read bit i without checking memory

Parameters
[in]iindex of the bit to be read.
Returns
the value of bit i
Note
No checking out of range.

Definition at line 411 of file bitArray.H.

References ah_out_of_range_error_if, array_of_bytes, and current_size.

◆ read_bit()

int Aleph::BitArray::read_bit ( const size_t  i) const
inline

◆ read_bit_ne()

int Aleph::BitArray::read_bit_ne ( const size_t  i) const
inlinenoexcept

Definition at line 360 of file bitArray.H.

References array_of_bytes, and Aleph::Byte::read_bit().

Referenced by Aleph::BitArray::Iterator::get_curr_ne(), get_unum(), and read_bit().

◆ reserve()

void Aleph::BitArray::reserve ( const size_t  dim)
inline

Reserve memory in advance for the bit array dim dimension.

reserve() sets aside enough memory in advance to save dim bits. In this way, write or read accesses can be done directly and more quickly using the read() and write().

Exceptions
bad_allocif not enough memory

Definition at line 328 of file bitArray.H.

References dim(), and set_size().

Referenced by Aleph::Bloom_Filter< T >::Bloom_Filter(), set_bit_str(), and set_num().

◆ right_shift()

void Aleph::BitArray::right_shift ( const size_t  n = 1)
inline

Shifts the bits n positions to the right.

The bits are shifted and the array is considered a fixed size, that is, the last n bits are lost.

Parameters
[in]nthe number of positions to shift the bits.

Definition at line 729 of file bitArray.H.

References current_size, Aleph::FunctionalMixin< BitArray, unsigned int >::maps(), read_bit(), and write_bit().

◆ save()

void Aleph::BitArray::save ( std::ostream &  output) const
inline

Saves the bit sequence in a text file.

save() stores the sequence in the output text file, already opened, of bits in decimal format.

The first line always saves the size in bytes and in bits. The sequential bytes are then saved as a decimal value. corresponding to the arrangement.

Parameters
[in]outputopen output stream where the arrangement.

Definition at line 548 of file bitArray.H.

References ah_runtime_error_if, array_of_bytes, current_size, get_num_bytes(), Aleph::FunctionalMixin< BitArray, unsigned int >::maps(), and output.

◆ save_in_array_of_chars()

void Aleph::BitArray::save_in_array_of_chars ( const std::string &  name,
std::ostream &  output 
) const
inline

Saves a static string declaration to a text file.

characters representing the arrangement.

save_in_array_of_chars(name, output) generates a declaration of the guy:

char name [ size ] = { comma-separated array values };

The declaration is saved in the output stream and the array name is name.

Parameters
[in]namename of the array variable.
[in]outputoutput stream where you want to save the statement.

Definition at line 643 of file bitArray.H.

References array_of_bytes, current_size, get_num_bytes(), Aleph::FunctionalMixin< BitArray, unsigned int >::maps(), and output.

◆ set_bit_str()

void Aleph::BitArray::set_bit_str ( const std::string &  str)
inline

◆ set_num() [1/5]

void Aleph::BitArray::set_num ( const char c)
inline

◆ set_num() [2/5]

void Aleph::BitArray::set_num ( const int c)
inline

◆ set_num() [3/5]

void Aleph::BitArray::set_num ( const long c)
inline

◆ set_num() [4/5]

void Aleph::BitArray::set_num ( const short c)
inline

◆ set_num() [5/5]

template<typename T >
void Aleph::BitArray::set_num ( T  n)
inline

◆ set_size()

void Aleph::BitArray::set_size ( const size_t  sz)
inline

◆ size()

◆ swap()

void Aleph::BitArray::swap ( BitArray array)
inlinenoexcept

Definition at line 485 of file bitArray.H.

References array_of_bytes, and current_size.

Referenced by BitArray(), load(), operator=(), and Aleph::Bloom_Filter< T >::swap().

◆ to_string()

std::string Aleph::BitArray::to_string ( ) const
inline

Definition at line 915 of file bitArray.H.

References get_bit_str().

◆ traverse() [1/4]

template<class Operation >
bool Aleph::BitArray::traverse ( Operation &&  operation = Operation())
inline

◆ traverse() [2/4]

template<class Operation >
bool Aleph::BitArray::traverse ( Operation &&  operation = Operation()) const
inline

◆ traverse() [3/4]

template<class Operation >
bool Aleph::BitArray::traverse ( Operation operation)
inline

◆ traverse() [4/4]

template<class Operation >
bool Aleph::BitArray::traverse ( Operation operation) const
inline

◆ write()

void Aleph::BitArray::write ( const size_t  i,
const unsigned int  value 
)
inline

Writes bit i with value without memory check.

Parameters
[in]iindex of the bit to be written.
[in]valuevalue to be written at position i.
Note
It doesn't check out of range, and it doesn't check that value have a binary value.

Definition at line 426 of file bitArray.H.

References ah_out_of_range_error_if, array_of_bytes, clear_unused_bits_in_last_byte(), and current_size.

◆ write_bit()

void Aleph::BitArray::write_bit ( const size_t  i,
const unsigned int  value 
)
inline

Write bit i with the value.

Parameters
[in]iindex of the bit to be written.
[in]valuevalue to be written at position i.
Note
It doesn't check out of range, and it doesn't check that value have a binary value.

Definition at line 392 of file bitArray.H.

References ah_out_of_range_error_if, array_of_bytes, clear_unused_bits_in_last_byte(), and current_size.

Referenced by BitArray(), circular_left_shift(), circular_right_shift(), demo_bitwise_operations(), dyn_right_shift(), left_shift(), push(), right_shift(), set_bit_str(), set_num(), set_size(), TEST(), TEST(), TEST(), and TEST().

Friends And Related Symbol Documentation

◆ begin [1/2]

iterator begin ( BitArray s)
friend

Definition at line 1135 of file bitArray.H.

◆ begin [2/2]

const_iterator begin ( const BitArray s)
friend

Definition at line 1135 of file bitArray.H.

◆ cbegin

const_iterator cbegin ( const BitArray s)
friend

Definition at line 1135 of file bitArray.H.

◆ cend

const_iterator cend ( const BitArray s)
friend

Definition at line 1135 of file bitArray.H.

◆ end [1/2]

iterator end ( BitArray s)
friend

Definition at line 1135 of file bitArray.H.

◆ end [2/2]

const_iterator end ( const BitArray s)
friend

Definition at line 1135 of file bitArray.H.

◆ operator&

BitArray operator& ( const BitArray op1,
const BitArray op2 
)
friend

Definition at line 999 of file bitArray.H.

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
const BitArray array 
)
friend

Definition at line 920 of file bitArray.H.

◆ operator|

BitArray operator| ( const BitArray op1,
const BitArray op2 
)
friend

Definition at line 992 of file bitArray.H.

Member Data Documentation

◆ array_of_bytes

◆ current_size


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