ace::NGramStore Class Reference

Class serves as NGram(s) store. More...

#include <ngrams.h>

List of all members.

Public Types

typedef HashVector< NGram
*, NGramHasher
hash_table_t
typedef std::pair< NGram *, bool > insert_status_t
 Pair returned as insert method result.

Public Member Functions

 NGramStore (size_t memory_pool_block_size=0)
 Constructor initializes all underlying containers in case, the passed types_count is non zero.
hash_table_t::const_iterator begin (ngram_size_t type) const
hash_table_t::const_iterator begin (void) const
hash_table_t::const_iterator end (ngram_size_t type) const
hash_table_t::const_iterator end (void) const
const NGramget (const NGram *ngram) const
void init (size_t memory_pool_block_size)
 Performs object initialization.
insert_status_t insert (const NGram *ngram)
size_t size (ngram_type_t type) const
size_t size (void) const
void sort (ngram_type_t type=0)

Public Attributes

NGram zero_ngram
 Only one zero-typed N-gram exists in whole universe (which is restrained by program scope of course).

Private Types

typedef std::pair
< hash_table_t::const_iterator,
bool > 
_hash_table_pair_cib_t
 Pair is returned as find() methods result.

Private Member Functions

_hash_table_pair_cib_t _find (const NGram *ngram) const
 NGramStore (const NGramStore &)
 No copy constructs.
NGramStoreoperator= (const NGramStore &)
 No assignments.

Private Attributes

std::vector< VoidPool_memory_pools
 VoidPool serves as a data container for NGram instances.
std::vector< hash_table_t_hash_tables
 Hash table is used to quickly gain pointer to stored NGram instance.


Detailed Description

Class serves as NGram(s) store.

There is separate memory pool and hash table for each NGram type. NGram data are stored within the pool, while pointer to NGram is stored within the hash table.


Member Typedef Documentation

Pair is returned as find() methods result.

The 1st value is const_iterator pointing to founded item (if founded - otherwise its value cannot be consider as valid). 2nd value answers the question: was searched key founded?

typedef std::pair<NGram *, bool> ace::NGramStore::insert_status_t

Pair returned as insert method result.

The 1st value is pointer to the stored NGram instance, 2nd value determines whether inserted item was added to store (true) or was not, which means it has been already present.


Constructor & Destructor Documentation

ace::NGramStore::NGramStore ( const NGramStore  )  [private]

No copy constructs.

ace::NGramStore::NGramStore ( size_t  memory_pool_block_size = 0  ) 

Constructor initializes all underlying containers in case, the passed types_count is non zero.

Parameters:
memory_pool_block_size Number of NGram(s) to be stored in every pool.


Member Function Documentation

NGramStore::_hash_table_pair_cib_t ace::NGramStore::_find ( const NGram ngram  )  const [private]

Parameters:
ngram Pointer to NGram instance which shall be looked after.
Returns:
Lookup result (see return type description for more info).

NGramStore& ace::NGramStore::operator= ( const NGramStore  )  [private]

No assignments.

hash_table_t::const_iterator ace::NGramStore::begin ( ngram_size_t  type  )  const [inline]

Parameters:
type N-gram type.
Returns:
Iterator pointing to the beginning of store of given N-grams type.

hash_table_t::const_iterator ace::NGramStore::begin ( void   )  const [inline]

hash_table_t::const_iterator ace::NGramStore::end ( ngram_size_t  type  )  const [inline]

Parameters:
type N-gram type.
Returns:
Iterator pointing to the end of store of given N-grams type.

hash_table_t::const_iterator ace::NGramStore::end ( void   )  const [inline]

const NGram * ace::NGramStore::get ( const NGram ngram  )  const

Returns:
Pointer to the stored counterpart of passed NGram or NULL, if no counterpart instance has been found within the store.

void ace::NGramStore::init ( size_t  memory_pool_block_size  ) 

Performs object initialization.

Can be used in "post-init" manner also, but only if object has been created by default constructor.

Parameters:
memory_pool_block_size Number of NGram(s) to be stored in every pool.

NGramStore::insert_status_t ace::NGramStore::insert ( const NGram ngram  ) 

Parameters:
ngram Pointer to NGram instance which should be inserted into store.

size_t ace::NGramStore::size ( ngram_type_t  type  )  const [inline]

Parameters:
type N-gram type.
Returns:
Number of given type N-grams within the store.

size_t ace::NGramStore::size ( void   )  const [inline]

Returns:
Number of all full N-grams within the store.

void ace::NGramStore::sort ( ngram_type_t  type = 0  ) 


Member Data Documentation

Only one zero-typed N-gram exists in whole universe (which is restrained by program scope of course).

std::vector<VoidPool> ace::NGramStore::_memory_pools [private]

VoidPool serves as a data container for NGram instances.

For each N-gram type there is a separate pool, because of various memory sizes needed.

Hash table is used to quickly gain pointer to stored NGram instance.

There is a separate hash table for each N-gram type, what makes iteration through all instances of certain N-gram type very easy.


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

Generated on Wed Aug 6 23:25:51 2008 for PACE by  doxygen 1.5.6