#include <strings.h>
Public Types | |
| typedef std::vector< const char * > | table_t |
| Typedef for container of pointers to stored strings which acts as conversion table: index -> pointer (to C-string). | |
Public Member Functions | |
| StringStore (size_t max_string_length) | |
| Constructs new StringStore. | |
| void | clear (void) |
| Drops all stored strings. | |
| bool | is_full (void) const |
| const char * | get (_IndType index) const |
| Retrieves pointer to string instance tied to given index. | |
| _IndType | store (const char *str) |
| Stores the string and returns string index within store. | |
| size_t | size (void) const |
Private Types | |
| typedef std::set< _IndType, StringStoreLessComparator < _IndType > > | _index_t |
| Typedef for set which is used as index above the conversion table. | |
Private Attributes | |
| RandomSizedMemoryPool< char > | _memory_pool |
| Memory pool used to store the C-strings. | |
| table_t | _strings_table |
| Container with pointers to string instances (conversion table). | |
| _index_t | _strings_index |
| Container acts as index above strings pointers container. | |
| StringStoreEqualComparator < _IndType > | _str_equal_comp |
| Comparator needed for determination of two C-strings (un)equality. | |
The equality of strings is based just on their bitwise values (so "String" and "string" will be considered as two different strings). Class provides O(log N) when inserting new C-string and O(1) time when retrieving stored string (by accessing it by its index). Note that this concept of string storage has one advantage - when comparing two strings stored within same storage to determine if they are equal, one has only to compare the indices themself, not the strings they "point" to.
| _IndType | Type for string indices, can be any of unsigned types. When new string is inserted, overflow check is performed. |
| typedef std::vector<const char *> ace::StringStore< _IndType >::table_t |
Typedef for container of pointers to stored strings which acts as conversion table: index -> pointer (to C-string).
typedef std::set<_IndType, StringStoreLessComparator<_IndType> > ace::StringStore< _IndType >::_index_t [private] |
Typedef for set which is used as index above the conversion table.
| ace::StringStore< _IndType >::StringStore | ( | size_t | max_string_length | ) | [inline] |
| void ace::StringStore< _IndType >::clear | ( | void | ) | [inline] |
Drops all stored strings.
| bool ace::StringStore< _IndType >::is_full | ( | void | ) | const [inline] |
| const char* ace::StringStore< _IndType >::get | ( | _IndType | index | ) | const [inline] |
Retrieves pointer to string instance tied to given index.
Note: No range checks are performed!
| index | Index of C-string to rietrieve. |
| _IndType ace::StringStore< _IndType >::store | ( | const char * | str | ) | [inline] |
Stores the string and returns string index within store.
| str | Pointer to C-string to store within. |
| string_index_overflow | When insertion of new string would cause overflow of _IndType. |
| size_t ace::StringStore< _IndType >::size | ( | void | ) | const [inline] |
RandomSizedMemoryPool<char> ace::StringStore< _IndType >::_memory_pool [private] |
Memory pool used to store the C-strings.
table_t ace::StringStore< _IndType >::_strings_table [private] |
Container with pointers to string instances (conversion table).
_index_t ace::StringStore< _IndType >::_strings_index [private] |
Container acts as index above strings pointers container.
StringStoreEqualComparator<_IndType> ace::StringStore< _IndType >::_str_equal_comp [private] |
Comparator needed for determination of two C-strings (un)equality.
1.5.6