-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHashTable.h
64 lines (47 loc) · 1.98 KB
/
HashTable.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//*****************************************************************
// HashTable.h
// HashTable
//
// Created by Karlina Beringer on June 18, 2014.
//
// This header file contains the Hash Table class declaration.
// Hash Table array elements consist of Linked List objects.
//*****************************************************************
#ifndef HashTable_h
#define HashTable_h
#include "LinkedList.h"
//*****************************************************************
// Hash Table objects store a fixed number of Linked Lists.
//*****************************************************************
class HashTable {
private:
// Array is a reference to an array of Linked Lists.
LinkedList * array;
// Length is the size of the Hash Table array.
int length;
// Returns an array location for a given item key.
int hash(Item* item);
public:
// Constructs the empty Hash Table object.
// Array length is set to 211 by default.
HashTable(int tableLength = 211);
// Adds an item to the Hash Table.
void insertItem(Item * newItem);
// Deletes an Item by key from the Hash Table.
// Returns true if the operation is successful.
bool existItem(Item* item);
// Returns an item from the Hash Table by key.
// If the item isn't found, a null pointer is returned.
//Item * getItemByKey( string itemKey );
// Display the contents of the Hash Table to console window.
void printTable();
// Prints a histogram illustrating the Item distribution.
void printHistogram();
// Returns the number of locations in the Hash Table.
int getLength();
// Returns the number of Items in the Hash Table.
int getNumberOfItems();
// De-allocates all memory used for the Hash Table.
~HashTable();
};
#endif