Exemplo n.º 1
0
void Dictionary::SetAt(const ieResRef key, unsigned int type, unsigned int value)
{
	int i;
	unsigned int nHash;
	MyAssoc* pAssoc=GetAssocAt( key, type, nHash );

	if (pAssoc == NULL) {
		if (m_pHashTable == NULL)
			InitHashTable( m_nHashTableSize );

		// it doesn't exist, add a new Association
		pAssoc = NewAssoc();
		// put into hash table
		pAssoc->pNext = m_pHashTable[nHash];
		m_pHashTable[nHash] = pAssoc;
	}
	for(i=0;i<KEYSIZE && key[i];i++) {
		pAssoc->key[i]=tolower(key[i]);
	}
	for(;i<KEYSIZE;i++) {
		pAssoc->key[i]=0;
	}
	pAssoc->type = type;
	pAssoc->value = value;
}
Exemplo n.º 2
0
void* CFX_MapPtrToPtr::GetValueAt(void* key) const {
  FX_DWORD nHash;
  CAssoc* pAssoc = GetAssocAt(key, nHash);
  if (pAssoc == NULL) {
    return NULL;
  }
  return pAssoc->value;
}
Exemplo n.º 3
0
bool CFX_MapPtrToPtr::Lookup(void* key, void*& rValue) const {
  uint32_t nHash;
  CAssoc* pAssoc = GetAssocAt(key, nHash);
  if (!pAssoc) {
    return false;
  }
  rValue = pAssoc->value;
  return true;
}
Exemplo n.º 4
0
FX_BOOL CFX_MapPtrToPtr::Lookup(void* key, void*& rValue) const {
  FX_DWORD nHash;
  CAssoc* pAssoc = GetAssocAt(key, nHash);
  if (pAssoc == NULL) {
    return FALSE;
  }
  rValue = pAssoc->value;
  return TRUE;
}
Exemplo n.º 5
0
void Dictionary::RemoveAt(const ieResRef key, unsigned int type)
{
	unsigned int nHash;
	MyAssoc* pAssoc = GetAssocAt( key, type, nHash );

	if (pAssoc != NULL) {
		FreeAssoc(pAssoc);
	}
}
Exemplo n.º 6
0
FX_BOOL CFX_MapPtrToPtr::Lookup(void* key, void*& rValue) const {
  uint32_t nHash;
  CAssoc* pAssoc = GetAssocAt(key, nHash);
  if (!pAssoc) {
    return FALSE;
  }
  rValue = pAssoc->value;
  return TRUE;
}
Exemplo n.º 7
0
LTBOOL CMapWordToPtr::Lookup(int32 key, void*& rValue) const
{
	uint16 nHash;
	CAssoc* pAssoc = GetAssocAt(key, nHash);
	if (pAssoc == LTNULL)
		return LTFALSE;  // not in map

	rValue = pAssoc->value;
	return LTTRUE;
}
Exemplo n.º 8
0
bool THashTable:: Lookup(char* key, int& rValue) const
{
	UINT nHash;
	bool bHasBucket;
	TAssoc* pAssoc = GetAssocAt(key, nHash,bHasBucket);
	if (pAssoc == NULL)
		return false;  // not in map

	rValue = pAssoc->fValue;
	return true;
}
Exemplo n.º 9
0
BOOL CMapPtrToPtr::Lookup(void* key, void*& rValue) const
{
	ASSERT_VALID(this);

	UINT nHash;
	CAssoc* pAssoc = GetAssocAt(key, nHash);
	if (pAssoc == NULL)
		return FALSE;  // not in map

	rValue = pAssoc->value;
	return TRUE;
}
Exemplo n.º 10
0
BOOL CMapWordToOb::Lookup(WORD key, CObject*& rValue) const
{
	ASSERT_VALID(this);

	UINT nHash;
	CAssoc* pAssoc = GetAssocAt(key, nHash);
	if (pAssoc == NULL)
		return FALSE;  // not in map

	rValue = pAssoc->value;
	return TRUE;
}
Exemplo n.º 11
0
BOOL CMapDWORDToChar::Lookup(DWORD key, char& rValue) const
{
	ASSERT_VALID(this);

	UINT nHash;
	CAssoc* pAssoc = GetAssocAt(key, nHash);
	if (pAssoc == NULL)
		return FALSE;  // not in map

	rValue = pAssoc->value;
	return TRUE;
}
Exemplo n.º 12
0
BOOL CMapStringToPtr::LookupKey(LPCTSTR key, LPCTSTR& rKey) const
{
	ASSERT_VALID(this);

	UINT nHash;
	CAssoc* pAssoc = GetAssocAt(key, nHash);
	if (pAssoc == NULL)
		return FALSE;  // not in map

	rKey = pAssoc->key;
	return TRUE;
}
Exemplo n.º 13
0
BOOL CMapStringToString::Lookup(LPCTSTR key, CString& rValue) const
{
	ASSERT_VALID(this);

	UINT nHash;
	CAssoc* pAssoc = GetAssocAt(key, nHash);
	if (pAssoc == NULL)
		return FALSE;  // not in map

	rValue = pAssoc->value;
	return TRUE;
}
Exemplo n.º 14
0
BOOL CMapStringToOb::Lookup(LPCTSTR key, CObject*& rValue) const
{
	ASSERT_VALID(this);

	UINT nHashBucket, nHashValue;
	CAssoc* pAssoc = GetAssocAt(key, nHashBucket, nHashValue);
	if (pAssoc == NULL)
		return FALSE;  // not in map

	rValue = pAssoc->value;
	return TRUE;
}
Exemplo n.º 15
0
BOOL CMapWordToPtr::Lookup(WORD key, void*& rValue) const
{
	ASSERT_VALID(this);

	UINT nHashBucket, nHashValue;
	CAssoc* pAssoc = GetAssocAt(key, nHashBucket, nHashValue);
	if (pAssoc == NULL)
		return FALSE;  // not in map

	rValue = pAssoc->value;
	return TRUE;
}
Exemplo n.º 16
0
bool Dictionary::Lookup(const ieResRef key, unsigned int type,
	unsigned int& rValue) const
{
	unsigned int nHash;

	MyAssoc* pAssoc = GetAssocAt( key, type, nHash );
	if (pAssoc == NULL) {
		return false;
	}  // not in map

	rValue = pAssoc->value;
	return true;
}
Exemplo n.º 17
0
void THashTable:: SetAt(char* key, int value){
	UINT nHash;
	TAssoc* pAssoc;
        TBucket* pBucket;
        bool bHasBucket;

	if ((pAssoc = GetAssocAt(key, nHash, bHasBucket)) == NULL) {
               if (bHasBucket == false) {
                  // create a TBucket
                  pBucket = new TBucket(BUCKET_SIZE);
                  fBuckets[nHash] = pBucket;
                  fBucketsUsed++;
                }
                pBucket = fBuckets[nHash];
                pAssoc = new TAssoc(key,value);
                pBucket->insert(pAssoc);

                //if (pBucket->entries() > 1 ){
                //     fCollisions++;
                //}
	}
}
Exemplo n.º 18
0
char& CMapDWORDToChar::operator[](DWORD key)
{
	ASSERT_VALID(this);

	UINT nHash;
	CAssoc* pAssoc;
	if ((pAssoc = GetAssocAt(key, nHash)) == NULL)
	{
		if (m_pHashTable == NULL)
			InitHashTable(m_nHashTableSize);

		// it doesn't exist, add a new Association
		pAssoc = NewAssoc();
		pAssoc->nHashValue = nHash;
		pAssoc->key = key;
		// 'pAssoc->value' is a constructed object, nothing more

		// put into hash table
		pAssoc->pNext = m_pHashTable[nHash];
		m_pHashTable[nHash] = pAssoc;
	}
	return pAssoc->value;  // return new reference
}
Exemplo n.º 19
0
int& THashTable:: operator[](char* key){
    UINT nHash;
    TAssoc* pAssoc;
    TBucket* pBucket;
    bool bHasBucket;

	if ((pAssoc = GetAssocAt(key, nHash, bHasBucket)) == NULL) {
               if (bHasBucket == false) {
                  // create a TBucket
                  pBucket = new TBucket(BUCKET_SIZE);
                  fBuckets[nHash] = pBucket;
                  fBucketsUsed++;
                }
                pBucket = fBuckets[nHash];
                // dummy in value
                pAssoc = new TAssoc(key,0);
                pBucket->insert(pAssoc);

                //if (pBucket->entries() > 1 ){
                //     fCollisions++;
                //}
	}
    return pAssoc->fValue;  // assigns value
}
Exemplo n.º 20
0
void* CFX_MapPtrToPtr::GetValueAt(void* key) const {
  uint32_t nHash;
  CAssoc* pAssoc = GetAssocAt(key, nHash);
  return pAssoc ? pAssoc->value : nullptr;
}