create hashnode class
This commit is contained in:
parent
389858dbb3
commit
851ce00dbe
40
HashNode.h
40
HashNode.h
@ -1,10 +1,42 @@
|
||||
#ifndef INC_08_TEAM_PROJECT_HASHNODE_H
|
||||
#define INC_08_TEAM_PROJECT_HASHNODE_H
|
||||
|
||||
template<typename T>
|
||||
class HashNode {
|
||||
template <typename T>
|
||||
class HashNode
|
||||
{
|
||||
private:
|
||||
T item;
|
||||
int occupied; // 1 -> occupied, 0 -> empty from start, -1 -> empty after removal
|
||||
int numCollisions;
|
||||
|
||||
public:
|
||||
// constructors
|
||||
HashNode()
|
||||
{
|
||||
occupied = 0;
|
||||
numCollisions = 0;
|
||||
}
|
||||
HashNode(T anItem)
|
||||
{
|
||||
item = anItem;
|
||||
occupied = 1;
|
||||
numCollisions = 0;
|
||||
}
|
||||
HashNode(T anItem, int ocp, int nCol)
|
||||
{
|
||||
item = anItem;
|
||||
occupied = ocp;
|
||||
numCollisions = nCol;
|
||||
}
|
||||
// setters
|
||||
void setItem(const T &anItem) { item = anItem; }
|
||||
void setOccupied(int ocp) { occupied = ocp; }
|
||||
void setNumCollisions(int nCol) { numCollisions = nCol; }
|
||||
|
||||
// getters
|
||||
T getItem() const { return item; }
|
||||
int getOccupied() const { return occupied; }
|
||||
int getNumCollisions() const { return numCollisions; }
|
||||
};
|
||||
|
||||
|
||||
#endif //INC_08_TEAM_PROJECT_HASHNODE_H
|
||||
#endif // INC_08_TEAM_PROJECT_HASHNODE_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user