#include <hash-list.h>
Classes | |
struct | Elem |
struct | HashBucket |
Public Member Functions | |
HashList () | |
Constructor takes no arguments. More... | |
Elem * | Clear () |
Clears the hash and gives the head of the current list to the user; ownership is transferred to the user (the user must call Delete() for each element in the list, at his/her leisure). More... | |
const Elem * | GetList () const |
Gives the head of the current list to the user. More... | |
void | Delete (Elem *e) |
Think of this like delete(). More... | |
Elem * | New () |
This should probably not be needed to be called directly by the user. More... | |
Elem * | Find (I key) |
Find tries to find this element in the current list using the hashtable. More... | |
Elem * | Insert (I key, T val) |
Insert inserts a new element into the hashtable/stored list. More... | |
void | InsertMore (I key, T val) |
Insert inserts another element with same key into the hashtable/ stored list. More... | |
void | SetSize (size_t sz) |
SetSize tells the object how many hash buckets to allocate (should typically be at least twice the number of objects we expect to go in the structure, for fastest performance). More... | |
size_t | Size () |
Returns current number of hash buckets. More... | |
~HashList () | |
Private Attributes | |
Elem * | list_head_ |
size_t | bucket_list_tail_ |
size_t | hash_size_ |
std::vector< HashBucket > | buckets_ |
Elem * | freed_head_ |
std::vector< Elem * > | allocated_ |
Static Private Attributes | |
static const size_t | allocate_block_size_ = 1024 |
Definition at line 50 of file hash-list.h.
HashList | ( | ) |
Constructor takes no arguments.
Call SetSize to inform it of the likely size.
Definition at line 30 of file hash-list-inl.h.
~HashList | ( | ) |
Definition at line 106 of file hash-list-inl.h.
Referenced by HashList< StateId, Token *>::Size().
Clears the hash and gives the head of the current list to the user; ownership is transferred to the user (the user must call Delete() for each element in the list, at his/her leisure).
Definition at line 46 of file hash-list-inl.h.
Referenced by LatticeBiglmFasterDecoder::DeleteElems(), FasterDecoder::InitDecoding(), FasterDecoder::ProcessEmitting(), OnlineFasterDecoder::ResetDecoder(), and kaldi::TestHashList().
|
inline |
Think of this like delete().
It is to be called for each Elem in turn after you "obtained ownership" by doing Clear(). This is not the opposite of. Insert, it is the opposite of New. It's really a memory operation.
Definition at line 66 of file hash-list-inl.h.
Referenced by FasterDecoder::ClearToks(), BiglmFasterDecoder::ClearToks(), LatticeBiglmFasterDecoder::DeleteElems(), FasterDecoder::ProcessEmitting(), and kaldi::TestHashList().
Find tries to find this element in the current list using the hashtable.
It returns NULL if not present. The Elem it returns is not owned by the user, it is part of the internal list owned by this object, but the user is free to modify the "val" element.
Definition at line 72 of file hash-list-inl.h.
Referenced by kaldi::TestHashList().
Gives the head of the current list to the user.
Ownership retained in the class. Caution: in December 2013 the return type was changed to const Elem* and this function was made const. You may need to change some types of local Elem* variables to const if this produces compilation errors.
Definition at line 61 of file hash-list-inl.h.
Referenced by OnlineFasterDecoder::FinishTraceBack(), FasterDecoder::GetBestPath(), FasterDecoder::ProcessNonemitting(), FasterDecoder::ReachedFinal(), kaldi::TestHashList(), OnlineFasterDecoder::TracebackNFrames(), and OnlineFasterDecoder::UpdateImmortalToken().
Insert inserts a new element into the hashtable/stored list.
Because element keys in a hashtable are unique, this operation checks whether each inserted element has a key equivalent to the one of an element already in the hashtable. If so, the element is not inserted, returning an pointer to this existing element.
Definition at line 125 of file hash-list-inl.h.
Referenced by FasterDecoder::InitDecoding(), FasterDecoder::ProcessEmitting(), FasterDecoder::ProcessNonemitting(), OnlineFasterDecoder::ResetDecoder(), and kaldi::TestHashList().
|
inline |
Insert inserts another element with same key into the hashtable/ stored list.
By calling this, the user asserts that one element with that key is already present. We insert it that way, that all elements with the same key follow each other. Find() will return the first one of the elements with the same key.
Definition at line 168 of file hash-list-inl.h.
This should probably not be needed to be called directly by the user.
Think of it as opposite to Delete();
Definition at line 89 of file hash-list-inl.h.
void SetSize | ( | size_t | sz | ) |
SetSize tells the object how many hash buckets to allocate (should typically be at least twice the number of objects we expect to go in the structure, for fastest performance).
It must be called while the hash is empty (e.g. after Clear() or after initializing the object, but before adding anything to the hash.
Definition at line 37 of file hash-list-inl.h.
Referenced by FasterDecoder::FasterDecoder(), FasterDecoder::PossiblyResizeHash(), and kaldi::TestHashList().
|
inline |
Returns current number of hash buckets.
Definition at line 113 of file hash-list.h.
Referenced by FasterDecoder::PossiblyResizeHash().
|
staticprivate |
Definition at line 137 of file hash-list.h.
|
private |
Definition at line 135 of file hash-list.h.
|
private |
Definition at line 126 of file hash-list.h.
|
private |
Definition at line 130 of file hash-list.h.
|
private |
Definition at line 132 of file hash-list.h.
|
private |
Definition at line 128 of file hash-list.h.
Referenced by HashList< StateId, Token *>::Size().
|
private |
Definition at line 125 of file hash-list.h.