yapf/hashtable.hpp
changeset 5129 15e48dea98a5
parent 5083 6da97b6fbbd6
equal deleted inserted replaced
5128:c75525088fb9 5129:15e48dea98a5
     9 	typedef typename Titem_::Key Key;          // make Titem_::Key a property of HashTable
     9 	typedef typename Titem_::Key Key;          // make Titem_::Key a property of HashTable
    10 
    10 
    11 	Titem_*    m_pFirst;
    11 	Titem_*    m_pFirst;
    12 
    12 
    13 	CHashTableSlotT() : m_pFirst(NULL) {}
    13 	CHashTableSlotT() : m_pFirst(NULL) {}
       
    14 
       
    15 	/** hash table slot helper - clears the slot by simple forgetting its items */
       
    16 	FORCEINLINE void Clear() {m_pFirst = NULL;}
    14 
    17 
    15 	/** hash table slot helper - linear search for item with given key through the given blob - const version */
    18 	/** hash table slot helper - linear search for item with given key through the given blob - const version */
    16 	FORCEINLINE const Titem_* Find(const Key& key) const
    19 	FORCEINLINE const Titem_* Find(const Key& key) const
    17 	{
    20 	{
    18 		for (const Titem_* pItem = m_pFirst; pItem != NULL; pItem = pItem->GetHashNext()) {
    21 		for (const Titem_* pItem = m_pFirst; pItem != NULL; pItem = pItem->GetHashNext()) {
   160 
   163 
   161 public:
   164 public:
   162 	/** item count */
   165 	/** item count */
   163 	FORCEINLINE int Count() const {return m_num_items;}
   166 	FORCEINLINE int Count() const {return m_num_items;}
   164 
   167 
       
   168 	/** simple clear - forget all items - used by CSegmentCostCacheT.Flush() */
       
   169 	FORCEINLINE void Clear() const {for (int i = 0; i < Tcapacity; i++) m_slots[i].Clear();}
       
   170 
   165 	/** const item search */
   171 	/** const item search */
   166 	const Titem_* Find(const Tkey& key) const
   172 	const Titem_* Find(const Tkey& key) const
   167 	{
   173 	{
   168 		int hash = CalcHash(key);
   174 		int hash = CalcHash(key);
   169 		const Slot& slot = m_slots[hash];
   175 		const Slot& slot = m_slots[hash];