code/Hashtable.cpp
// NOTE: Retuns hastable items in sorted order!
Retuns hastable items in sorted order!
Retuns hastable items in sorted order!
HashtableIterator* Hashtable::GetIteratorSorted(SortOrder order) 
{
   HashItem* item = NULL;
   HashtableIterator* first = NULL;
   HashtableIterator* last = NULL;
   Array items = {};
   items.Init(count, true, CompareHashItemsPos, SortOrder::Asc);
   for (uint32 slot = 0; slot < size; slot++) {
       item = table + slot;
       while (item && item->index != HASH_ITEM_UNINITIALIZED) {
           items.AddSorted(item);
           item = item->next;
       };
   }
   item = (HashItem*)items[0].data;
   first = &item->iterator;
   first->prev = NULL;
   first->next = NULL;
   last = first;
   for (uint32 i = 1; i < items.count; i++) {
        item = (HashItem*)items[i].data;
       last->next = &item->iterator;
       item->iterator.prev = last;
       item->iterator.next = NULL;
       last = &item->iterator;
   }
   items.Free();
   return first;
}
HashtableIterator * Hashtable :: GetIteratorSorted ( SortOrder order ) { HashItem * item = NULL ; HashtableIterator * first = NULL ; HashtableIterator * last = NULL ; Array items = { } ; items . Init ( count , true , CompareHashItemsPos , SortOrder :: Asc ) ; for ( uint32 slot = 0 ; slot < size ; slot ++ ) { item = table + slot ; while ( item && item -> index != HASH_ITEM_UNINITIALIZED ) { items . AddSorted ( item ) ; item = item -> next ; } ; } item = ( HashItem * ) items [ 0 ] . data ; first = & item -> iterator ; first -> prev = NULL ; first -> next = NULL ; last = first ; for ( uint32 i = 1 ; i < items . count ; i ++ ) { item = ( HashItem * ) items [ i ] . data ; last -> next = & item -> iterator ; item -> iterator . prev = last ; item -> iterator . next = NULL ; last = & item -> iterator ; } items . Free ( ) ; return first ; }
NOTE: Retuns hastable items in sorted order!
NOTE : Retuns hastable items in sorted order!
// First iterator item // Chain iterator