SDSL: Succinct Data Structure Library
A C++ template library for succinct data structures
 All Classes Namespaces Files Functions Variables Typedefs Friends
Classes | Functions
sdsl::util Namespace Reference

A namespace for helper functions. More...

Classes

struct  nullstream
class  _id_helper

Functions

void set_zero_bits (nn_dict_dynamic &nn)
template<typename T >
std::string to_string (const T &t)
 Convert type to string.
void set_verbose ()
std::string basename (const std::string &file_name)
 Returns the basename of a file_name.
std::string dirname (const std::string &file_name)
 Returns the directory of a file_name. Trailing / are removed.
template<class int_vector_type >
void set_random_bits (int_vector_type &v, int seed=0)
 Sets all bits of the int_vector to pseudo-random bits.
template<class int_vector_type >
void set_zero_bits (int_vector_type &v)
 Sets all bits of the int_vector to 0-bits.
template<class int_vector_type >
void set_one_bits (int_vector_type &v)
 Sets all bits of the int_vector to 1-bits.
template<class int_vector_type >
void bit_compress (int_vector_type &v)
 Bit compress the int_vector.
template<class int_vector_type , class size_type_class >
void all_elements_mod (int_vector_type &v, size_type_class m)
 All elements of v modulo m.
template<class int_vector_type >
void set_all_values_to_k (int_vector_type &v, uint64_t k)
 Set all entries of int_vector to value k.
template<class int_vector_type >
void set_to_id (int_vector_type &v)
 Sets each entry of the numerical vector v at position $fi.
template<class int_vector_type >
int_vector_type::size_type get_one_bits (const int_vector_type &v)
 Counts and returns the 1-bits an int_vector contains.
template<class int_vector_type >
int_vector_type::size_type get_onezero_bits (const int_vector_type &v)
 Counts 10 bit pair occurencies.
template<class int_vector_type >
int_vector_type::size_type get_zeroone_bits (const int_vector_type &v)
 Counts 01 bit pair occurencies.
template<class T >
bool load_from_file (T &v, const char *file_name)
 Load a data structure from a file.
template<>
bool load_from_file (void *&, const char *file_name)
template<class size_type_class >
bool load_from_int_vector_buffer (unsigned char *&text, int_vector_file_buffer< 8, size_type_class > &text_buf)
bool load_from_file (char *&v, const char *file_name)
 Specialization of load_from_file for a char array.
template<class T >
bool store_to_file (const T &v, const char *file_name)
 Store a data structure to a file.
bool store_to_file (const char *v, const char *file_name)
 Specialization of store_to_file for a char array.
template<uint8_t fixed_int_width, class size_type_class >
bool store_to_file (const int_vector< fixed_int_width, size_type_class > &v, const char *file_name, bool write_fixed_as_variable=false)
 Specialization of store_to_file for int_vector.
std::string demangle (const char *name)
 Demangle the class name of typeid(...).name()
std::string demangle2 (const char *name)
 Demangle the class name of typeid(...).name() and remove the "sdsl::"-prefix, "unsigned int",...
template<class T >
std::string class_name (const T &t)
template<class T >
T::size_type get_size_in_bytes (const T &t)
 Get the size of a data structure in bytes.
template<class T >
double get_size_in_mega_bytes (const T &t)
 Get the size of a data structure in mega bytes (MB).
template<class T >
size_t write_member (const T &t, std::ostream &out, sdsl::structure_tree_node *v=NULL, std::string name="")
template<>
size_t write_member< std::string > (const std::string &t, std::ostream &out, structure_tree_node *v, std::string name)
template<class T >
void read_member (T &t, std::istream &in)
template<>
void read_member< std::string > (std::string &t, std::istream &in)
uint64_t get_pid ()
 Get the process id of the current process.
uint64_t get_id ()
 Get a unique id inside the process.
template<typename T >
std::string to_latex_string (const T &t)
std::string to_latex_string (unsigned char c)
void delete_all_files (tMSS &file_map)
 Delete all files in the file_map in the file system.
template<class T , class U >
void assign (T &x, const U &y)
 Assigns the value x of type T to the value of y of type U.
template<class T >
void assign (T &x, T &y)
 Swaps variables x and y.
template<class T >
void clear (T &x)
 clear the space used by x
template<class S , class P >
void swap_support (S &s1, S &s2, const P *p1, const P *p2)
 Swap support data structure and assign to new vector.
template<class S , class X >
void init_support (S &s, const X *x)
 Initialise support data structure with.
template<format_type F, class X >
void write_structure (const X &x, std::ostream &out)

Detailed Description

A namespace for helper functions.


Function Documentation

template<class T , class U >
void sdsl::util::assign ( T &  x,
const U &  y 
)

Assigns the value x of type T to the value of y of type U.

Parameters:
xThe assigned variable.
yThe variable which provides the value that is assigned to x.
template<class T >
void sdsl::util::assign ( T &  x,
T &  y 
)

Swaps variables x and y.

Parameters:
xReference to the first variable.
yReference to the second variable.
template<class int_vector_type >
void sdsl::util::bit_compress ( int_vector_type &  v)

Bit compress the int_vector.

Determine the biggest value X and then set the int_width to the smallest possible so that we still can represent X

template<class T >
void sdsl::util::clear ( T &  x)

clear the space used by x

Parameters:
xReference to the data structure.
std::string sdsl::util::demangle ( const char *  name)

Demangle the class name of typeid(...).name()

Parameters:
nameA pointer to the the result of typeid(...).name()
template<class int_vector_type >
int_vector_type::size_type sdsl::util::get_one_bits ( const int_vector_type &  v)

Counts and returns the 1-bits an int_vector contains.

Parameters:
vThe int_vector to count the 1-bits.
Returns:
The number of 1-bits in v.
template<class int_vector_type >
int_vector_type::size_type sdsl::util::get_onezero_bits ( const int_vector_type &  v)

Counts 10 bit pair occurencies.

See also:
getOneBits, getOneZeroBits
template<class T >
T::size_type sdsl::util::get_size_in_bytes ( const T &  t)

Get the size of a data structure in bytes.

Parameters:
vA reference to the data structure for which the size in bytes should be calculated.
template<class T >
double sdsl::util::get_size_in_mega_bytes ( const T &  t)

Get the size of a data structure in mega bytes (MB).

Parameters:
tA reference to the data structure for which the size in bytes should be calculated.
template<class int_vector_type >
int_vector_type::size_type sdsl::util::get_zeroone_bits ( const int_vector_type &  v)

Counts 01 bit pair occurencies.

See also:
getOneBits, getZeroOneBits
template<class S , class X >
void sdsl::util::init_support ( S &  s,
const X *  x 
)

Initialise support data structure with.

Parameters:
sSupport structure which should be initialized
xPointer to the data structure which should be supported.
template<class T >
bool sdsl::util::load_from_file ( T &  v,
const char *  file_name 
)

Load a data structure from a file.

The data structure has to provide a load function.

Parameters:
vData structure to load.
file_nameName of the serialized file.
template<class int_vector_type >
void sdsl::util::set_all_values_to_k ( int_vector_type &  v,
uint64_t  k 
)

Set all entries of int_vector to value k.

Parameters:
vThe int_vector which should be set
kThe value which should be inserted into v.
Details
This method precalculates the content of at most 64 words and then repeatedly inserts these words into v.
template<class int_vector_type >
void sdsl::util::set_random_bits ( int_vector_type &  v,
int  seed = 0 
)

Sets all bits of the int_vector to pseudo-random bits.

Parameters:
vThe int_vector whose bits should be set to random bits
seedIf seed = 0, the time is used to initialize the pseudo random number generator, otherwise the seed parameter is used.
template<class T >
bool sdsl::util::store_to_file ( const T &  v,
const char *  file_name 
)

Store a data structure to a file.

The data structure has to provide a serialize function.

Parameters:
vData structure to store.
file_nameName of the file where to store the data structure.
Returnif the data structure was stored successfully
template<class S , class P >
void sdsl::util::swap_support ( S &  s1,
S &  s2,
const P *  p1,
const P *  p2 
)

Swap support data structure and assign to new vector.

Parameters:
s1First support structure.
s2Second support structure.
p1First supported structure.
p2Second supported structure. s1 is swapped with s2 and after the execution s1 supports p1 and s2 supports p2. I.e. if p1 and p2 are members of a complex data structure, we have to swap p1 and p2 before we use this method.