Aleph-w  1.9
General library for algorithms and data structures
Aleph::DynLhashTable< Key, Record, Cmp > Class Template Reference

#include <tpl_dynLhash.H>

+ Inheritance diagram for Aleph::DynLhashTable< Key, Record, Cmp >:
+ Collaboration diagram for Aleph::DynLhashTable< Key, Record, Cmp >:

Public Types

using Hash_Fct_Ptr = typename DynLhashTable< Key, Record >::Hash_Fct_Ptr
 El tipo de función hash.
 
using Base = GenLhashTable< Key, LhashBucket< Key >, Aleph::equal_to< Key > >
 
using Bucket = LhashBucket< Key >
 
using Hash_Fct = std::function< size_t(const Key &)>
 
using Key_Type = Key
 
using Item_Type = Key
 

Public Member Functions

void swap (DynLhashTable &table)
 
 DynLhashTable (size_t len=DefaultPrime, Hash_Fct_Ptr hash_fct=dft_hash_fct< Key >)
 
 DynLhashTable (const DynLhashTable &table)
 
 DynLhashTable (DynLhashTable &&table)
 
DynLhashTableoperator= (const DynLhashTable &table)
 
DynLhashTableoperator= (DynLhashTable &&table)
 
Record * insert (const Key &key, const Record &record)
 
Record * insert (const Key &key, Record &&record=Record())
 
Record * insert (Key &&key, const Record &record)
 
Record * insert (Key &&key, Record &&record)
 
Record * search (const Key &key)
 
void remove (Record *record)
 
DLProxy operator[] (const Key &key) const
 
DLProxy operator[] (const Key &key)
 
Aleph::equal_to< Key > & get_compare ()
 
const Aleph::equal_to< Key > & get_compare () const
 
void swap (GenLhashTable &other) noexcept
 
void empty () noexcept
 Vacía la tabla hash; libera memoria de todas las cubetas.
 
Hash_Fct get_hash_fct () const noexcept
 
void set_hash_fct (Hash_Fct fct) noexcept
 Set the internal hash function.
 
void set_hash_fct (Hash_Fct_Ptr fct) noexcept
 
float current_alpha () const noexcept
 return the current table load
 
Bucketinsert (Bucket *bucket)
 
Bucketsearch_or_insert (Bucket *bucket)
 
Bucketsearch (const Key &key) const noexcept
 
Bucketremove (Bucket *bucket) noexcept
 
size_t resize (size_t new_size)
 
Bucketsearch_next (Bucket *bucket) const noexcept
 
const size_t & capacity () const noexcept
 Retorna el tamaño de la tabla.
 
const size_t & size () const noexcept
 Retorna el número de elementos que contiene la tabla.
 
const size_t & get_num_busy_slots () const noexcept
 Retorna la cantidad de entradas del arreglo que están ocupadas.
 
bool is_empty () const noexcept
 
Stats stats () const
 
void print_stats (const Stats &stats) const
 
void set_upper_alpha (const float &__upper_alpha)
 
void set_lower_alpha (const float &__lower_alpha)
 
float get_lower_alpha () const noexcept
 
float get_upper_alpha () const noexcept
 

Protected Attributes

Hash_Fct hash_fct
 
size_t len
 
Aleph::equal_to< Key > cmp
 
float lower_alpha
 
float upper_alpha
 

Detailed Description

template<typename Key, typename Record, class Cmp = Aleph::equal_to<Key>>
class Aleph::DynLhashTable< Key, Record, Cmp >

Mapeo dinámico clave-rango instrumentado mediante una tabla hash con resolución de colisiones por encadenamiento separado.

El tipo DynLhashTable<Key,Record> instrumenta un mapeo mediante una tabla hash con resolución de colisiones por encadenamiento separado. El tipo exporta observadores para conocer el radio de uso y, eventualmente, reajustar el tamaño de la tabla, de modo que ésta exhiba un mejor desempeño.

Pueden usarse de manera segura punteros a registros dentro de la tabla.

Aparte los métodos tradicionales de inserción y búsqueda, el operador [] funge a la vez como consulta e inserción. La asignación tabla[key]=record se corresponde con una inserción; mientras que cualquier expresión del tipo table[key] que involucre lectura se corresponde con una búsqueda.

Parameters
Keyel tipo de clave de indización
Recordel tipo de rango asociado a las claves.
Cmpclase de comparación entre las claves.

Constructor & Destructor Documentation

◆ DynLhashTable()

template<typename Key, typename Record, class Cmp = Aleph::equal_to<Key>>
Aleph::DynLhashTable< Key, Record, Cmp >::DynLhashTable ( size_t  len = DefaultPrime,
Hash_Fct_Ptr  hash_fct = dft_hash_fct<Key> 
)
inline

Instancia un mapeo hash dinámico con función hash hash_fct y tabla de longitud len. Dispara excepción bad_alloc si no hay memoria para apartar la tabla interna.

+ Here is the call graph for this function:

Member Function Documentation

◆ insert() [1/2]

Bucket* Aleph::GenLhashTable< Key, LhashBucket< Key > , Aleph::equal_to< Key > >::insert ( Bucket bucket)
inlineinherited

Inserta en la tabla la cubeta bucket y retorna su dirección si la clave no está en la tabla; de lo contrario se retorna nullptr

◆ insert() [2/2]

template<typename Key, typename Record, class Cmp = Aleph::equal_to<Key>>
Record* Aleph::DynLhashTable< Key, Record, Cmp >::insert ( const Key &  key,
const Record &  record 
)
inline

Inserta en el mapeo hash el par (key,record) indizado por la clave key. Retorna un puntero al registro dentro de la tabla. Dispara la excepción bad_alloc si no hay suficiente memoria.

+ Here is the caller graph for this function:

◆ remove() [1/2]

template<typename Key, typename Record, class Cmp = Aleph::equal_to<Key>>
void Aleph::DynLhashTable< Key, Record, Cmp >::remove ( Record *  record)
inline

Elimina de la tabla el registro record (que debe haber sido obtenido mediante la inserción o búsqueda.

+ Here is the call graph for this function:

◆ remove() [2/2]

Bucket* Aleph::GenLhashTable< Key, LhashBucket< Key > , Aleph::equal_to< Key > >::remove ( Bucket bucket)
inlinenoexceptinherited

Elimina de la tabla la cubeta bucket. Retorna la dirección de la cubeta. ATENCIÓN: no se verifica que la cubeta pertenezca a la tabla.

◆ resize()

size_t Aleph::GenLhashTable< Key, LhashBucket< Key > , Aleph::equal_to< Key > >::resize ( size_t  new_size)
inlineinherited

Reajusta la dimensión de la tabla hash al valor new_size y reubica las claves. Dispara bad_alloc si no hay suficiente memoria para reubicar el arreglo.

◆ search() [1/2]

template<typename Key, typename Record, class Cmp = Aleph::equal_to<Key>>
Record* Aleph::DynLhashTable< Key, Record, Cmp >::search ( const Key &  key)
inline

Busca la clave key y, si se encuentra, entonces retorna un puntero dentro de la tabla al registro asociado. De lo contrario -no se encuentra la clave-, se retorna nullptr:

◆ search() [2/2]

Bucket* Aleph::GenLhashTable< Key, LhashBucket< Key > , Aleph::equal_to< Key > >::search ( const Key &  key) const
inlinenoexceptinherited

Busca en la tabla una cubeta con la clave key. Retorna un puntero a la cubeta si se encuentra; nullptr de lo contrario.

◆ search_next()

Bucket* Aleph::GenLhashTable< Key, LhashBucket< Key > , Aleph::equal_to< Key > >::search_next ( Bucket bucket) const
inlinenoexceptinherited

retorna la próxima cubeta que colisiona con bucket. Si no existe, entonces se retorna nullptr.


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

Leandro Rabindranath León