Beispiel #1
0
void *Hashtable::Remove(const void *key)
{
	Entry **table,*entry,*prev;
	uint32 hash,(*func)(const void *);
	int32 index;

	table = fTable;
	hash = (func = fHashFunc)(key);
	index = hash % fCapacity;

	for(entry = table[index],prev = NULL;entry;entry = entry->next)
	{
		if ((func(entry->key) == hash) && fCompareFunc(entry->key,key))
		{
			void *value;

			fModCount++;
			if (prev)
				prev->next = entry->next;
			else
				table[index] = entry->next;

			fCount--;
			value = entry->value;
			delete entry;

			return value;
		}
		prev = entry;
	}
	return NULL;
}
Beispiel #2
0
Hashtable::Entry *Hashtable::GetHashEntry(const void *key)
{
	Entry **table,*entry;
	uint32 hash,(*func)(const void *);

	table = fTable;
	hash = (func = fHashFunc)(key);

	for(entry = table[hash % fCapacity];entry;entry = entry->next)
	{
		if ((func(entry->key) == hash) && fCompareFunc(entry->key,key))
			return entry;
	}
	return NULL;
}
Beispiel #3
0
	bool operator()(const BListItem* a, const BListItem* b) const
	{
		return fCompareFunc(a, b) < 0;
	}