#include <ut_hash.h>
Classes | |
class | UT_Cursor |
Public Member Functions | |
UT_GenericStringMap (size_t expected_cardinality=11) | |
virtual | ~UT_GenericStringMap () |
bool | insert (const char *key, T value) |
bool | insert (const UT_String &key, T value) |
void | set (const char *key, T val) |
void | set (const UT_String &key, T val) |
T | pick (const char *key) const |
T | pick (const UT_String &key) const |
bool | contains (const char *key, T val) const |
bool | contains (const UT_String &key, T val) const |
void | remove (const char *key, T) |
void | remove (const UT_String &key, T) |
void | clear () |
const gchar ** | list () |
UT_GenericVector< T > * | enumerate (bool strip_null_values=true) const |
UT_GenericVector< const UT_String * > * | keys (bool strip_null_values=true) const |
size_t | size () const |
void | purgeData (void) |
void | freeData (void) |
Private Types | |
enum | SM_search_type { SM_INSERT, SM_LOOKUP, SM_REORG } |
Private Member Functions | |
UT_GenericStringMap (const UT_GenericStringMap< T > &) | |
void | operator= (const UT_GenericStringMap< T > &) |
void | reorg (size_t slots_to_allocate) |
void | grow () |
void | assign_slots (hash_slot< T > *p, size_t old_num_slots) |
bool | too_full () const |
bool | too_many_deleted () const |
bool | exceeds_n_delete_threshold () const |
hash_slot< T > * | find_slot (const UT_String &k, SM_search_type search_type, size_t &slot, bool &key_found, size_t &hashval, const void *v, bool *v_found, void *vi, size_t hashval_in) const |
hash_slot< T > * | find_slot (const char *k, SM_search_type search_type, size_t &slot, bool &key_found, size_t &hashval, const void *v, bool *v_found, void *vi, size_t hashval_in) const |
const T | _first (UT_Cursor &c) const |
const T | _next (UT_Cursor &c) const |
const T | _prev (UT_Cursor &c) const |
const UT_String & | _key (UT_Cursor &c) const |
void | _make_deleted (UT_Cursor &c) const |
Static Private Member Functions | |
static size_t | compute_reorg_threshold (size_t nslots) |
Private Attributes | |
hash_slot< T > * | m_pMapping |
size_t | n_keys |
size_t | n_deleted |
size_t | m_nSlots |
size_t | reorg_threshold |
size_t | flags |
gchar ** | m_list |
Friends | |
class | UT_Cursor |
enum UT_GenericStringMap::SM_search_type [private] |
UT_GenericStringMap< T >::UT_GenericStringMap | ( | size_t | expected_cardinality = 11 |
) |
This class represents a mapping between key/value pairs where the keys are represented by UT_String (a wrapper around char*) and the values may be of any pointer type (void*)
References UT_GenericStringMap< T >::m_nSlots, and UT_GenericStringMap< T >::m_pMapping.
UT_GenericStringMap< T >::~UT_GenericStringMap | ( | ) | [virtual] |
References DELETEPV, FREEP, UT_GenericStringMap< T >::m_list, and UT_GenericStringMap< T >::m_pMapping.
UT_GenericStringMap< T >::UT_GenericStringMap | ( | const UT_GenericStringMap< T > & | ) | [private] |
const T UT_GenericStringMap< T >::_first | ( | UT_Cursor & | c | ) | const [private] |
const UT_String & UT_GenericStringMap< T >::_key | ( | UT_Cursor & | c | ) | const [private] |
void UT_GenericStringMap< T >::_make_deleted | ( | UT_Cursor & | c | ) | const [private] |
const T UT_GenericStringMap< T >::_next | ( | UT_Cursor & | c | ) | const [private] |
const T UT_GenericStringMap< T >::_prev | ( | UT_Cursor & | c | ) | const [private] |
void UT_GenericStringMap< T >::assign_slots | ( | hash_slot< T > * | p, | |
size_t | old_num_slots | |||
) | [private] |
void UT_GenericStringMap< T >::clear | ( | void | ) |
Remove all key/value pairs from the map
References hash_slot< T >::deleted(), hash_slot< T >::empty(), FREEP, UT_GenericStringMap< T >::m_list, UT_GenericStringMap< T >::m_nSlots, UT_GenericStringMap< T >::m_pMapping, hash_slot< T >::make_deleted(), hash_slot< T >::make_empty(), UT_GenericStringMap< T >::n_deleted, and UT_GenericStringMap< T >::n_keys.
Referenced by UT_Multipart::clear(), and ODe_Style_List::~ODe_Style_List().
size_t UT_GenericStringMap< T >::compute_reorg_threshold | ( | size_t | nslots | ) | [static, private] |
Referenced by UT_GenericStringMap< T >::reorg().
bool UT_GenericStringMap< T >::contains | ( | const UT_String & | key, | |
T | val | |||
) | const |
References UT_GenericStringMap< T >::find_slot(), and UT_GenericStringMap< T >::SM_LOOKUP.
bool UT_GenericStringMap< T >::contains | ( | const char * | k, | |
T | v | |||
) | const |
See if the map contains the (key, value) pair represented by (, ) If is null, just see if the key exists
Referenced by ODe_FontFaceDecls::addFont(), PD_Document::areDocumentFormatsEqual(), PD_Document::areDocumentStylesheetsEqual(), XAP_Dictionary::isWord(), PD_Document::purgeRevisionTable(), and SpellManager::requestDictionary().
UT_GenericVector< T > * UT_GenericStringMap< T >::enumerate | ( | bool | strip_null_values = true |
) | const |
Return a UT_Vector of elements in the HashTable that you must Later g_free with a call to delete
References UT_GenericVector< T >::addItem(), and UT_GenericStringMap< T >::size().
Referenced by ODe_Main_Listener::_openHeaderFooterSection(), ODe_AutomaticStyles::_storeStyle(), OO_StylesContainer::enumerateSpanStyles(), ODe_Styles::getGraphicStylesEnumeration(), ODe_Style_List::getListLevelStyles(), ODe_AutomaticStyles::getListStyles(), ODe_AutomaticStyles::getParagraphStyles(), ODe_Styles::getParagraphStylesEnumeration(), ODe_AutomaticStyles::getTextStyles(), ODe_Styles::getTextStylesEnumeration(), XAP_Dictionary::save(), XAP_Dictionary::suggestWord(), ODe_Styles::write(), ODe_Style_List::write(), ODe_FontFaceDecls::write(), ODe_AutomaticStyles::write(), ODe_DocumentData::writeStylesXML(), ODe_AutomaticStyles::~ODe_AutomaticStyles(), ODe_DocumentData::~ODe_DocumentData(), ODe_FontFaceDecls::~ODe_FontFaceDecls(), ODe_Style_List::~ODe_Style_List(), ODe_Styles::~ODe_Styles(), SpellManager::~SpellManager(), and XAP_PrefsScheme::~XAP_PrefsScheme().
bool UT_GenericStringMap< T >::exceeds_n_delete_threshold | ( | ) | const [inline, private] |
hash_slot< T > * UT_GenericStringMap< T >::find_slot | ( | const char * | k, | |
SM_search_type | search_type, | |||
size_t & | slot, | |||
bool & | key_found, | |||
size_t & | hashval, | |||
const void * | v, | |||
bool * | v_found, | |||
void * | vi, | |||
size_t | hashval_in | |||
) | const [private] |
hash_slot< T > * UT_GenericStringMap< T >::find_slot | ( | const UT_String & | k, | |
SM_search_type | search_type, | |||
size_t & | slot, | |||
bool & | key_found, | |||
size_t & | hashval, | |||
const void * | v, | |||
bool * | v_found, | |||
void * | vi, | |||
size_t | hashval_in | |||
) | const [private] |
void UT_GenericStringMap< T >::freeData | ( | void | ) | [inline] |
Referenced by AP_Dialog_Spell::~AP_Dialog_Spell(), and XAP_Dictionary::~XAP_Dictionary().
void UT_GenericStringMap< T >::grow | ( | ) | [private] |
References _Recommended_hash_size(), UT_GenericStringMap< T >::m_nSlots, and UT_GenericStringMap< T >::reorg().
Referenced by UT_GenericStringMap< T >::insert().
bool UT_GenericStringMap< T >::insert | ( | const UT_String & | key, | |
T | value | |||
) |
References UT_GenericStringMap< T >::find_slot(), FREEP, UT_GenericStringMap< T >::grow(), hash_slot< T >::insert(), UT_GenericStringMap< T >::m_list, UT_GenericStringMap< T >::m_nSlots, UT_GenericStringMap< T >::n_keys, UT_GenericStringMap< T >::reorg(), UT_GenericStringMap< T >::SM_INSERT, UT_GenericStringMap< T >::too_full(), and UT_GenericStringMap< T >::too_many_deleted().
bool UT_GenericStringMap< T >::insert | ( | const char * | key, | |
T | value | |||
) |
Insert this key/value pair into the map
Referenced by ODe_Styles::_addStyle(), IE_Imp_AbiWord_1::_handleImage(), XAP_Prefs::_markPrefChange(), s_HRText_Listener::_openTag(), IE_Exp_RTF::_selectStyles(), ODe_AutomaticStyles::_storeStyle(), OO_StylesContainer::addBlockStyle(), AP_Dialog_Spell::addChangeAll(), ODe_FontFaceDecls::addFont(), OO_StylesContainer::addFont(), ODe_Styles::addGraphicsStyle(), ODe_AutomaticStyles::addListStyle(), ODe_AutomaticStyles::addPageLayout(), OO_StylesContainer::addSpanStyle(), ODe_AutomaticStyles::addTableCellStyle(), ODe_AutomaticStyles::addTableColumnStyle(), ODe_AutomaticStyles::addTableRowStyle(), ODe_AutomaticStyles::addTableStyle(), XAP_Dictionary::addWord(), PD_Document::areDocumentFormatsEqual(), PD_Document::areDocumentStylesheetsEqual(), IE_Imp_OpenWriter::defineSimpleStyle(), ODe_DocumentData::doPreListeningWork(), OpenWriter_StylesStream_Listener::endElement(), UT_Multipart::insert(), ODe_Main_Listener::openSection(), PD_Document::purgeRevisionTable(), SpellManager::requestDictionary(), UT_GenericStringMap< T >::set(), ODe_Style_List::setLevelStyle(), XAP_PrefsScheme::setValue(), BarbarismChecker::startElement(), and UT_Xpm2Bmp().
UT_GenericVector< const UT_String * > * UT_GenericStringMap< T >::keys | ( | bool | strip_null_values = true |
) | const |
Return a UT_Vector of pointers to our UT_String keys in the Hashtable You must FREEP the UT_Vector* but not the keys
References UT_GenericVector< T >::addItem(), and UT_GenericStringMap< T >::size().
Referenced by OO_StylesContainer::getBlockStyleNum(), OO_StylesContainer::getBlockStylesKeys(), OO_StylesContainer::getFontsKeys(), XAP_PrefsScheme::getNthValue(), OO_StylesContainer::getSpanStylesKeys(), and s_HRText_Listener::~s_HRText_Listener().
const gchar ** UT_GenericStringMap< T >::list | ( | ) |
void UT_GenericStringMap< T >::operator= | ( | const UT_GenericStringMap< T > & | ) | [private] |
T UT_GenericStringMap< T >::pick | ( | const char * | k | ) | const |
Find the value associated with the key
References UT_GenericStringMap< T >::find_slot(), UT_GenericStringMap< T >::SM_LOOKUP, and hash_slot< T >::value().
Referenced by IE_Exp_RTF::_getStyleNumber(), IE_Imp_AbiWord_1::_handleImage(), IE_Imp_AbiWord_1::_handleResource(), XAP_Prefs::_markPrefChange(), s_HRText_Listener::_openTag(), IE_Exp_RTF::_selectStyles(), OO_StylesContainer::addBlockStyle(), OO_StylesContainer::addFont(), OO_StylesContainer::addSpanStyle(), BarbarismChecker::checkWord(), ODe_Styles::getGraphicsStyle(), ODe_Style_List::getLevelStyle(), ODe_AutomaticStyles::getMasterPage(), XAP_PrefsScheme::getNthValue(), ODe_AutomaticStyles::getPageLayout(), OO_StylesContainer::getSpanStyleNum(), OpenWriter_StylesStream_Listener::getStyleName(), XAP_PrefsScheme::getValue(), AP_Dialog_Spell::inChangeAll(), UT_Multipart::lookup(), IE_Imp_OpenWriter::mapStyle(), IE_Imp_OpenWriter::mapStyleObj(), ODe_Main_Listener::openSection(), UT_GenericStringMap< T >::pick(), OO_StylesContainer::pickBlockAtts(), SpellManager::requestDictionary(), ODe_Style_List::setLevelStyle(), XAP_PrefsScheme::setValue(), BarbarismChecker::suggestExactWord(), UT_Xpm2Bmp(), and s_HRText_Listener::~s_HRText_Listener().
T UT_GenericStringMap< T >::pick | ( | const UT_String & | key | ) | const |
References UT_String::c_str(), and UT_GenericStringMap< T >::pick().
void UT_GenericStringMap< T >::purgeData | ( | void | ) | [inline] |
void UT_GenericStringMap< T >::remove | ( | const char * | key, | |
T | ||||
) |
Remove the item referenced by in the map
void UT_GenericStringMap< T >::remove | ( | const UT_String & | key, | |
T | ||||
) |
References _Recommended_hash_size(), UT_GenericStringMap< T >::find_slot(), FREEP, UT_GenericStringMap< T >::m_list, UT_GenericStringMap< T >::m_nSlots, hash_slot< T >::make_deleted(), UT_GenericStringMap< T >::n_deleted, UT_GenericStringMap< T >::n_keys, UT_GenericStringMap< T >::reorg(), and UT_GenericStringMap< T >::SM_LOOKUP.
void UT_GenericStringMap< T >::reorg | ( | size_t | slots_to_allocate | ) | [private] |
References UT_GenericStringMap< T >::assign_slots(), UT_GenericStringMap< T >::compute_reorg_threshold(), DELETEPV, UT_GenericStringMap< T >::m_nSlots, UT_GenericStringMap< T >::m_pMapping, UT_GenericStringMap< T >::n_deleted, and UT_GenericStringMap< T >::reorg_threshold.
Referenced by UT_GenericStringMap< T >::grow(), UT_GenericStringMap< T >::insert(), and UT_GenericStringMap< T >::remove().
void UT_GenericStringMap< T >::set | ( | const UT_String & | key, | |
T | val | |||
) |
void UT_GenericStringMap< T >::set | ( | const char * | key, | |
T | value | |||
) |
Set the item determined by to the value If item() does not exist, insert it into the map
Referenced by XAP_PrefsScheme::setValue().
size_t UT_GenericStringMap< T >::size | ( | ) | const [inline] |
Referenced by OO_StylesContainer::addFont(), ODe_AutomaticStyles::addListStyle(), ODe_AutomaticStyles::addPageLayout(), OO_StylesContainer::addSpanStyle(), UT_GenericStringMap< T >::enumerate(), XAP_PrefsScheme::getNthValue(), ODe_AutomaticStyles::getSectionStylesCount(), UT_GenericStringMap< T >::keys(), XAP_Dictionary::load(), BarbarismChecker::load(), and ODe_Main_Listener::openSection().
bool UT_GenericStringMap< T >::too_full | ( | ) | const [inline, private] |
Referenced by UT_GenericStringMap< T >::insert().
bool UT_GenericStringMap< T >::too_many_deleted | ( | ) | const [inline, private] |
Referenced by UT_GenericStringMap< T >::insert().
friend class UT_Cursor [friend] |
size_t UT_GenericStringMap< T >::flags [private] |
gchar** UT_GenericStringMap< T >::m_list [private] |
size_t UT_GenericStringMap< T >::m_nSlots [private] |
Referenced by UT_GenericStringMap< T >::_first(), UT_GenericStringMap< T >::_next(), UT_GenericStringMap< T >::clear(), UT_GenericStringMap< T >::find_slot(), UT_GenericStringMap< T >::grow(), UT_GenericStringMap< T >::insert(), UT_GenericStringMap< T >::remove(), UT_GenericStringMap< T >::reorg(), and UT_GenericStringMap< T >::UT_GenericStringMap().
hash_slot<T>* UT_GenericStringMap< T >::m_pMapping [private] |
Referenced by UT_GenericStringMap< T >::_first(), UT_GenericStringMap< T >::_key(), UT_GenericStringMap< T >::_make_deleted(), UT_GenericStringMap< T >::_next(), UT_GenericStringMap< T >::_prev(), UT_GenericStringMap< T >::clear(), UT_GenericStringMap< T >::find_slot(), UT_GenericStringMap< T >::reorg(), UT_GenericStringMap< T >::UT_GenericStringMap(), and UT_GenericStringMap< T >::~UT_GenericStringMap().
size_t UT_GenericStringMap< T >::n_deleted [private] |
Referenced by UT_GenericStringMap< T >::clear(), UT_GenericStringMap< ODe_ListLevelStyle * >::exceeds_n_delete_threshold(), UT_GenericStringMap< T >::remove(), UT_GenericStringMap< T >::reorg(), UT_GenericStringMap< ODe_ListLevelStyle * >::too_full(), and UT_GenericStringMap< ODe_ListLevelStyle * >::too_many_deleted().
size_t UT_GenericStringMap< T >::n_keys [private] |
size_t UT_GenericStringMap< T >::reorg_threshold [private] |