nlib
nn::nlib::succinct::CompressedArray Class Referencefinal

A compressed array of integers that allows appending additional data. More...

#include "nn/nlib/succinct/Sbv.h"

Public Member Functions

bool PushBack (uint32_t x) noexcept
 Adds data. Compresses data after it becomes 64 elements long. More...
 
uint32_t operator[] (size_t idx) const noexcept
 Specifies an index and extracts the value. More...
 
size_t Size () const noexcept
 Gets the array length.
 
void Reset () noexcept
 Returns the object to the state immediately after the constructor is called.
 
size_t MemSize () const noexcept
 Returns the amount of memory explicitly allocated by the class. More...
 
Basic Member Functions
 CompressedArray () noexcept
 Instantiates the object.
 
 ~CompressedArray () noexcept
 Destructor.
 
 CompressedArray (CompressedArray &rhs, move_tag) noexcept
 Instantiates the object by using swap for a move.
 
CompressedArrayassign (CompressedArray &rhs, move_tag) noexcept
 Assigns the object by using swap for a move.
 
 CompressedArray (CompressedArray &&rhs) noexcept
 Instantiates the object (move constructor). This function is useful when using C++11.
 
CompressedArrayoperator= (CompressedArray &&rhs) noexcept
 Move assignment operator. This function is useful when using C++11.
 
void swap (CompressedArray &rhs) noexcept
 Swaps the contents of an object.
 
Importing and Exporting
bool Export (BinaryWriter *w) const noexcept
 Writes the object to the file. More...
 
bool Import (BinaryReader *r) noexcept
 Reads the written object. More...
 

Detailed Description

A compressed array of integers that allows appending additional data.

Description
The integer array is divided into blocks of 64 elements, and records the black's average value, and the 64 elements as the offset from the average value. The offset value is stored after being fit to a set bit width for each block. Values may be randomly accessed by a simple calculation of adding the average value and the offset.
This simple method allows for high compressions rates with data containing a high ratio of smaller values, usually becoming one-half to one-quarter the size of directly storing the values in an array.

Definition at line 191 of file Sbv.h.

Member Function Documentation

◆ Export()

nn::nlib::succinct::CompressedArray::Export ( BinaryWriter w) const
noexcept

Writes the object to the file.

Parameters
[in]wWrite out object.
Returns
Returns true when successful.
Description
The written data can be read and restored using the Import function. The data is always written little endian.

◆ Import()

nn::nlib::succinct::CompressedArray::Import ( BinaryReader r)
noexcept

Reads the written object.

Parameters
[in]rRead out object.
Returns
Returns true when import is successful.

◆ MemSize()

nn::nlib::succinct::CompressedArray::MemSize ( ) const
noexcept

Returns the amount of memory explicitly allocated by the class.

Returns
Returns the number of bytes.
Description
The actual amount of memory allocated by the system may be larger than the value returned by this function because of alignment and space for heap management.

◆ operator[]()

nn::nlib::succinct::CompressedArray::operator[] ( size_t  idx) const
noexcept

Specifies an index and extracts the value.

Parameters
[in]idxThe array index.
Returns
Returns the value of the array. Returns 0 when idx is out of bounds.

◆ PushBack()

nn::nlib::succinct::CompressedArray::PushBack ( uint32_t  x)
inlinenoexcept

Adds data. Compresses data after it becomes 64 elements long.

Parameters
[in]xValue being added.
Returns
Returns true when successful.

Definition at line 207 of file Sbv.h.


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