bool CTECHashTable<Type>:: contains(HashNode<Type> currentNode){
	bool isInTable = false;

	int possibleLocation = findPosition(currentNode);

	while(internalStorage[possibleLocation] != nullptr && !isInTable){
		if(internalStorage[possibleLocation] == currentNode.getValue()){
			isInTable = true;
		}
		possibleLocation = (possibleLocation + 1) % capacity;
	}

	return isInTable;
}
bool CTECHashTable<Type>:: remove(HashNode<Type> currentNode){
	bool hasBeenRemoved = false;
	int possibleLocation = findPosition(currentNode);

	if(contains(currentNode)){
		while(internalStorage[possibleLocation] != nullptr && !hasBeenRemoved){
			if(internalStorage[possibleLocation] == currentNode.getValue()){
				hasBeenRemoved = true;
				internalStorage[possibleLocation] = nullptr;
			}
			possibleLocation = (possibleLocation + 1) % capacity;
		}
	}
	return hasBeenRemoved;
}
Ejemplo n.º 3
0
bool CTECHashTable<Type>::contains(HashNode<Type> currentNode)
{
	bool isInTable = false;

	int index = findPosition(currentNode);
	while (internalStorage[index] != nullptr&& !isInTable)
	{
		if(internalStorage[index]->getValue() == currentNode.getValue())
		{
			isInTable = true;
		}
		else
		{
			index = (index + 1) % capacity;
		}
	}

	return isInTable;
}
Ejemplo n.º 4
0
bool HashTable<Type> :: contains(HashNode<Type> currentNode)
{
    bool wasRemoved = false;
  
        int index = findPosition(currentNode);
        while(internalStorage[index] != nullptr && !wasRemoved)
        {
            if(internalStorage[index]->getValue() == currentNode.getValue())
            {
                wasRemoved = true;
                internalStorage[index] = nullptr;
                size--;
            }
            else
            {
                index = (index + 1) % capacity;
            }
        }
    
    return wasRemoved;
}