cds  2.3.2
cds::algo::number_splitter< Int > Class Template Reference

Cuts a bit sequence from a number. More...

#include <cds/algo/split_bitstring.h>

Public Types

typedef Int int_type
 Number type.
 
typedef Int uint_type
 Result type of cut() function.
 

Public Member Functions

 number_splitter (int_type n)
 Initalizes the splitter with nymber n and initial bit offset 0.
 
 number_splitter (int_type n, size_t initial_offset)
 Initalizes the splitter with nymber n and initial bit offset initial_offset.
 
 operator bool () const
 Returns true if end-of-string is not reached yet.
 
bool eos () const
 Returns true if end-of-stream encountered.
 
int_type cut (unsigned count)
 Cuts next count bits (must be multiplier of 8) from the number. More...
 
int_type safe_cut (unsigned count)
 Cuts up to count from the bit-string. More...
 
void reset () noexcept
 Resets the splitter.
 
int_type source () const
 Returns initial number.
 
size_t bit_offset () const
 Returns current bit offset from beginning of the number.
 
size_t rest_count () const
 Returns how many bits remain.
 

Static Public Member Functions

static constexpr bool is_correct (unsigned count)
 Checks if count is multiple of 8.
 

Detailed Description

template<typename Int>
class cds::algo::number_splitter< Int >

Cuts a bit sequence from a number.

The splitter can be used as an iterator over bit representation of the number of type Int. Each call of cut() or safe_cut() cuts the bit count specified and keeps the position inside the number for the next call.

Member Function Documentation

◆ cut()

template<typename Int >
int_type cds::algo::number_splitter< Int >::cut ( unsigned  count)
inline

Cuts next count bits (must be multiplier of 8) from the number.

For performance reason, the function does not manage out-of-bound condition. To control that use safe_cut().

◆ safe_cut()

template<typename Int >
int_type cds::algo::number_splitter< Int >::safe_cut ( unsigned  count)
inline

Cuts up to count from the bit-string.

Safe analog of cut(): if count is more than the rest of int_type, only the rest is returned. When eos() condition is met the function returns 0.


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

cds 2.3.2 Developed by Maxim Khizhinsky aka khizmax and other contributors 2007 - 2017
Autogenerated Sun Dec 31 2017 12:10:13 by Doxygen 1.8.13