A compact integer to integer read-only associative array.
More...
#include "nn/nlib/succinct/Sbv.h"
|
typedef SetType::IdxType | IdxType |
| Integer index.
|
|
typedef std::pair< bool, uint32_t > | FindType |
| Pair of boolean value and integer. If the value is not found, the boolean value is false .
|
|
|
bool | Build () noexcept |
| Builds an associative array. More...
|
|
size_t | MemSize () const noexcept |
| Returns the amount of memory explicitly allocated by the class. More...
|
|
void | Reset () noexcept |
| Returns the object to the state immediately after the constructor is called.
|
|
|
| Map () noexcept |
| Instantiates the object.
|
|
| ~Map () noexcept |
| Destructor.
|
|
Map & | assign (Map &rhs, move_tag) |
| Assigns the object by using swap for a move.
|
|
| Map (Map &rhs, move_tag) |
| Instantiates the object by using swap for a move.
|
|
| Map (Map &&rhs) |
| Instantiates the object (move constructor). This function is useful when using C++11.
|
|
Map & | operator= (Map &&rhs) |
| Move assignment operator. This function is useful when using C++11.
|
|
void | swap (Map &rhs) noexcept |
| Swaps the contents of an object.
|
|
|
Member function used before Build .
|
bool | Init (IdxType bv_size) noexcept |
| Initializes an object. More...
|
|
bool | TurnOn (IdxType idx, uint32_t data) noexcept |
| Adds a key and value. More...
|
|
|
|
FindType | Find (IdxType idx) noexcept |
| Specifies a key and gets the value in the associative array. More...
|
|
const FindType | Find (IdxType idx) const noexcept |
| Specifies a key and gets the value in the associative array. More...
|
|
const SetType & | GetKeys () const noexcept |
| Gets the key set. More...
|
|
const ArrayType & | GetValues () const noexcept |
| Gets the set of values. More...
|
|
|
bool | Export (BinaryWriter *w) const noexcept |
| Writes the object to the file. More...
|
|
bool | Import (BinaryReader *r) noexcept |
| Reads the written object. More...
|
|
A compact integer to integer read-only associative array.
- Description
- Stores the key integer using the
SparseSet
class, and stores the value integers using the CompressedArray
class. This class is well-suited for implementing nowhere dense associative arrays.
- Use this class in the following way.
-
Create the objects using the constructor.
-
Initialize the bit vector using
Init
to set the defined space.
-
Add the value corresponding to the key using
TurnOn
.
-
Construct a dictionary using
Build
to run Rank
/Select
operations at constant time.
-
The associative array is now ready to use.
- When the data has been written using
Export
, the data may be used by calling the data using Import
after running the constructor.
Definition at line 241 of file Sbv.h.
◆ Build()
nn::nlib::succinct::Map::Build |
( |
| ) |
|
|
inlinenoexcept |
Builds an associative array.
- Returns
- Returns
true
when successful.
Definition at line 264 of file Sbv.h.
◆ Export()
Writes the object to the file.
- Parameters
-
- 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.
Definition at line 288 of file Sbv.h.
◆ Find() [1/2]
nn::nlib::succinct::Map::Find |
( |
IdxType |
idx | ) |
|
|
inlinenoexcept |
Specifies a key and gets the value in the associative array.
- Parameters
-
[in] | idx | Integer value used as a key. |
- Returns
- Returns a pair of types
bool
and uint32_t
. The bool
value is true
when a value corresponding to the key is found.
Definition at line 265 of file Sbv.h.
◆ Find() [2/2]
nn::nlib::succinct::Map::Find |
( |
IdxType |
idx | ) |
const |
|
inlinenoexcept |
Specifies a key and gets the value in the associative array.
- Parameters
-
[in] | idx | Integer value used as a key. |
- Returns
- Returns a pair of types
bool
and uint32_t
. The bool
value is true
when a value corresponding to the key is found.
Definition at line 271 of file Sbv.h.
◆ GetKeys()
nn::nlib::succinct::Map::GetKeys |
( |
| ) |
const |
|
inlinenoexcept |
Gets the key set.
- Returns
- Returns the set of keys (
SparseSet
type).
Definition at line 282 of file Sbv.h.
◆ GetValues()
nn::nlib::succinct::Map::GetValues |
( |
| ) |
const |
|
inlinenoexcept |
Gets the set of values.
- Returns
- Returns the set of values (
CompressedArray
type).
Definition at line 283 of file Sbv.h.
◆ Import()
Reads the written object.
- Parameters
-
- Returns
- Returns
true
when import is successful.
Definition at line 293 of file Sbv.h.
◆ Init()
nn::nlib::succinct::Map::Init |
( |
IdxType |
bv_size | ) |
|
|
inlinenoexcept |
Initializes an object.
- Parameters
-
[in] | bv_size | The upper bound of the key (not including bvSize). |
- Returns
- Returns
true
when successful.
- Description
- This allows a key value larger than
0
, and smaller than bvSize.
Definition at line 255 of file Sbv.h.
◆ MemSize()
nn::nlib::succinct::Map::MemSize |
( |
| ) |
const |
|
inlinenoexcept |
Returns the amount of memory explicitly allocated by the class.
- Returns
- Returns the number of bytes.
- 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.
Definition at line 277 of file Sbv.h.
◆ TurnOn()
nn::nlib::succinct::Map::TurnOn |
( |
IdxType |
idx, |
|
|
uint32_t |
data |
|
) |
| |
|
inlinenoexcept |
Adds a key and value.
- Parameters
-
[in] | idx | Integer value used as a key. |
[in] | data | Integer value used as value. |
- Returns
- Returns
true
when successful. To use this function repeatedly, idx value must monotonically increase. It means you need to set the keys in the ascending order of their values.
Definition at line 259 of file Sbv.h.
The documentation for this class was generated from the following files: