Пример #1
0
void hash_index_object_t::test<6>()
{
    LLUUIDHashMap<UUIDTableEntry, 2>	hashTable(UUIDTableEntry::uuidEq, UUIDTableEntry());
    LLUUIDHashMapIter<UUIDTableEntry, 2> hashIter(&hashTable);
    const int numElementsToCheck = 256;
    std::vector<LLUUID> idList(numElementsToCheck);
    int i;

    for (i = 0; i < numElementsToCheck; i++)
    {
        LLUUID id;
        id.generate();
        // LLUUIDHashMap uses mData[0] to pick the bucket
        // overwrite mData[0] so that it ranges from 0 to 255
        // to create a sparse map
        id.mData[0] = i;
        UUIDTableEntry entry(id, i);
        hashTable.set(id, entry);
        idList[i] = id;
    }

    hashIter.first();
    int numElementsIterated = 0;
    while(!hashIter.done())
    {
        numElementsIterated++;
        UUIDTableEntry tableEntry = *hashIter;
        LLUUID id = tableEntry.getID();
        hashIter.next();
        ensure("Iteration failed for sparse map", tableEntry.getValue() < (size_t)numElementsToCheck && idList[tableEntry.getValue()] ==  tableEntry.getID());
    }

    ensure("iteration count failed", numElementsIterated == numElementsToCheck);
}
Пример #2
0
void hash_index_object_t::test<7>()
{
    LLUUIDHashMap<UUIDTableEntry, 2>	hashTable(UUIDTableEntry::uuidEq, UUIDTableEntry());
    LLUUIDHashMapIter<UUIDTableEntry, 2> hashIter(&hashTable);
    const int numElementsToCheck = 256;
    std::vector<LLUUID> idList(numElementsToCheck);
    int i;

    LLUUID uuidtoSearch;
    for (i = 0; i < numElementsToCheck; i++)
    {
        LLUUID id;
        id.generate();
        // LLUUIDHashMap uses mData[0] to pick the bucket
        // overwrite mData[0] so that it ranges from 0 to 255
        // to create a sparse map
        id.mData[0] = i;
        UUIDTableEntry entry(id, i);
        hashTable.set(id, entry);
        idList[i] = id;

        // pick uuid somewhere in the middle
        if (i == 5)
        {
            uuidtoSearch = id;
        }
    }

    hashIter.first();
    int numElementsIterated = 0;
    while(!hashIter.done())
    {
        numElementsIterated++;
        UUIDTableEntry tableEntry = *hashIter;
        LLUUID id = tableEntry.getID();
        if (uuidtoSearch == id)
        {
            break;
        }
        hashIter.next();
    }

    // current iterator implementation will not allow any remove operations
    // until ALL elements have been iterated over. this seems to be
    // an unnecessary restriction. Iterator should have a method to
    // reset() its state so that further operations (inckuding remove)
    // can be performed on the HashMap without having to iterate thru
    // all the remaining nodes.

//		 hashIter.reset();
//		 hashTable.remove(uuidtoSearch);
//		 ensure("remove after iteration reset failed", hashTable.check(uuidtoSearch) == FALSE);
}
Пример #3
0
// -----------------------------------------------------------------------------
// CCLFModifiableItemImpl::~CCLFModifiableItemImpl
// -----------------------------------------------------------------------------
//
CCLFModifiableItemImpl::~CCLFModifiableItemImpl()
    {
    iIntMap.Close();
    iTimeMap.Close();
    
    THashMapIter<TCLFFieldId, HBufC*> hashIter(iTextMap);
    for ( HBufC* const* p = hashIter.NextValue(); p; p = hashIter.NextValue() )
        {
        delete *p;
        p = NULL;
        }
    iTextMap.Close();
    }