27 template <
typename S,
typename T>
31 FastMap(
bool allowDups =
false,
const unsigned short initialSize = 32 )
32 :
array_( true, initialSize, 16384 ),
39 bool put( S& key, T item,
bool deleteOnCleanup =
false )
66 T
get(
const S& key,
bool andPop = false )
78 return get( key, true );
99 if( 0 != entry && andPop )
116 if( 0 != entry && entry->
getItem() == item )
124 int findIndex(
const S& key,
int minIndex = 0,
int maxIndex = -1 )
130 if( maxIndex < minIndex )
134 int midIndex = ( maxIndex + minIndex ) / 2;
137 if( key == midEntry->
getKey() )
141 else if( key < midEntry->getKey() )
143 if( midIndex == minIndex )
145 return midIndex ^ -1;
147 return findIndex( key, minIndex, midIndex - 1 );
151 if( midIndex == maxIndex )
153 return ( midIndex + 1 ) ^ -1;
155 return findIndex( key, midIndex + 1, maxIndex );
169 void clear(
bool andDeleteValues =
false )
171 for(
unsigned int i = 0; andDeleteValues && i <
size(); ++i )
Simple class for providing key-pointer mappings.
Definition: Slate.h:44
Wraps an key/value pair in a FastMap.
Definition: MapEntry.h:18
virtual T getItem()
Definition: MapEntry.h:39
int findIndex(const S &key, int minIndex=0, int maxIndex=-1)
Definition: FastMap.h:124
void insert(const unsigned int index, T item)
Definition: FlexArray.h:155
T nullItem_
Definition: FastMap.h:182
void clear(bool andDeleteValues=false)
Definition: FastMap.h:169
T pop(int index=-1)
Definition: FlexArray.h:171
unsigned int size()
Definition: FastMap.h:159
Contains the FlexArrayBase and FlexArray class declarations.
int getMaxIndex() const
Definition: FlexArray.cpp:47
unsigned int size() const
Definition: FlexArray.cpp:69
MapEntry< S, T > * getIndexedEntry(unsigned int index, bool andPop=false)
Definition: FastMap.h:96
T getIndexed(unsigned int index, bool andPop=false)
Definition: FastMap.h:81
Contains the MapEntry class declaration.
FlexArray< MapEntry< S, T > * > array_
Definition: FastMap.h:180
S & findKey(T item, const S &defaultValue)
Definition: FastMap.h:111
virtual S & getKey()
Definition: MapEntry.h:35
bool allowDups_
Definition: FastMap.h:181
T popIndexed(unsigned int index)
Definition: FastMap.h:106
Simple class providing a flexible size array of pointers.
Definition: DataReader.h:19
virtual ~FastMap()
Definition: FastMap.h:36
T pop(S &key)
Definition: FastMap.h:76
bool put(S &key, T item, bool deleteOnCleanup=false)
Definition: FastMap.h:39
void clear()
Definition: FlexArray.cpp:22
FlexArray< MapEntry< S, T > * > getArray()
Definition: FastMap.h:164
FastMap(bool allowDups=false, const unsigned short initialSize=32)
Definition: FastMap.h:31