void HashClass::avgNodesInLists() {
    int total = 0;

    for (int index = 0; index < tableSize; index++) {
        total += numberOfItemsInIndex(index); // Count up all nodes
    };

    cout << "The average number of nodes in the linked lists is " <<
            total / tableSize << endl;

}
void HashClass::printLongestLinkedList() {
    int indexOfLongest;
    int itemsCount = 0;


    for (int index = 0; index < tableSize; index++) {
		if (numberOfItemsInIndex(index) > itemsCount)
		{
			itemsCount = numberOfItemsInIndex(index);
			indexOfLongest = index;
		}
		if (index < 200)
		{
			cout << "For table " << index << " has an size of " << numberOfItemsInIndex(index) << endl;
			//cout << "Item count of longest linked list " << itemsCount << endl;
		}
    };

    cout << "The index/bucket with the longest linked list is " << indexOfLongest <<
            " and the number of items inside it is " << itemsCount << endl;

};
Exemple #3
0
void Hash::printTable()
{
	int number;
	//sprawdzam ilosc itemow w kazdym slocie
	for (int i=0; i<tableSize_;i++)
	{
		number=numberOfItemsInIndex(i);
		cout<<"-------------------\n";
		cout<<"index= "<<i<<endl;
		cout<<hashTable[i].name<<endl;
		cout<<"# of items = "<<number<<endl;
		cout<<"-------------------\n";
	}
}
void HashClass::printTable() {
    int numItemsInBucket;

    for (int index = 0; index < tableSize; index++) {
        numItemsInBucket = numberOfItemsInIndex(index);

        cout << "Word: " << HashTable[index]->word << endl;
        cout << "Line #: " << HashTable[index]->line << endl;
        cout << "Column #: " << HashTable[index]->column << endl;
        cout << "Frequency of word: " << HashTable[index]->frequency << endl;
        cout << "Number of nodes in bucket: " << numItemsInBucket << endl;
        cout << endl;

    } // end for

}