gatb.core-API-0.0.0
MapMPHF< Key, Value, Adaptator > Class Template Reference

hash table implementation More...

#include <MapMPHF.hpp>

Inheritance diagram for MapMPHF< Key, Value, Adaptator >:
Inheritance graph

Public Types

typedef BooPHF< Key, Adaptator > Hash
 

Public Member Functions

 MapMPHF ()
 
void build (tools::collections::Iterable< Key > &keys, int nbThreads=1, tools::dp::IteratorListener *progress=0)
 
size_t save (tools::storage::impl::Group &group, const std::string &name)
 
void load (tools::storage::impl::Group &group, const std::string &name)
 
Value & operator[] (const Key &key)
 
Value & at (typename Hash::Code code)
 
Hash::Code getCode (const Key &key)
 
size_t size () const
 
- Public Member Functions inherited from SmartPointer
void use ()
 
void forget ()
 
- Public Member Functions inherited from ISmartPointer
virtual ~ISmartPointer ()
 

Additional Inherited Members

- Protected Member Functions inherited from SmartPointer
 SmartPointer ()
 
virtual ~SmartPointer ()
 

Detailed Description

template<class Key, class Value, class Adaptator = AdaptatorDefault<Key>>
class gatb::core::tools::collections::impl::MapMPHF< Key, Value, Adaptator >

hash table implementation

This hash table implementation uses a minimal perfect hash function (MPHF) for identifying the keys with a unique number in [0..N-1] where N is the number of items.

Using BooPHF, the memory usage is about 3-4 bits per key.

The values can be stored in a simple vector. The keys are not stored in memory, only the mphf is needed.

Note that such an implementation can't afford to add items into the map (it's static).

Member Typedef Documentation

typedef BooPHF<Key, Adaptator> Hash

Hash type.

Constructor & Destructor Documentation

MapMPHF ( )
inline

Default constructor.

Member Function Documentation

Value& at ( typename Hash::Code  code)
inline

Get the value for a given index

Parameters
[in]code: the key
Returns
the value associated to the key.
void build ( tools::collections::Iterable< Key > &  keys,
int  nbThreads = 1,
tools::dp::IteratorListener progress = 0 
)
inline

Build the hash function from a set of items.

Parameters
[in]keys: iterable over the keys of the hash table
[in]progress: listener called during the building of the MPHF
Hash::Code getCode ( const Key &  key)
inline

Get the hash code of the given key.

void load ( tools::storage::impl::Group group,
const std::string &  name 
)
inline

Load hash function from a Group

Parameters
[in]group: group where to load the MPHF from
[in]name: name of the MPHF
Value& operator[] ( const Key &  key)
inline

Get the value for a given key

Parameters
[in]key: the key
Returns
the value associated to the key.
size_t save ( tools::storage::impl::Group group,
const std::string &  name 
)
inline

Save the hash function into a Group object.

Parameters
[out]group: group where to save the MPHF
[in]name: name of the saved MPHF
Returns
the number of bytes of the saved data.
size_t size ( ) const
inline

Get the number of keys.

Returns
keys number.

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