#include "Ware.h" #include #include #pragma once typedef int (*hashFunctionPtr)( std::string); // typedefinition of a pointer for a hashfunction; they all // need conform to the guideline: int // (std::string ) int mod17(std::string telNr); // hash algorithm that takes a given telNr mod17 int firstTwoLetters(std::string bezeichnung); class HashTable { private: class HashFunction { // private inner class to make hash functions managable public: int size; std::string name; hashFunctionPtr algorithm; HashFunction(std::string name, hashFunctionPtr algorithm, int size); // constructor }; HashFunction availableAlgorithms[1] = { {"firstTwoLetters", firstTwoLetters, 100}}; class HashNode { // private inner class for HashNodes that have a key (which // will be the telephone number) and a value of type Ware public: std::string key = ""; Ware *ware; }; public: int size; // m in lecture int numberOfEntries; // n in lecture std::list *entries; // nodes of the hash table hashFunctionPtr hashFunction; // pointer to the hash algorithm used is stored // in a private variable of type // hashFunctionPtr - see beginning of this file void insert(Ware *entry); const Ware *search(std::string key); bool deleteItem(std::string key); void print(); void setHashFunction(std::string name); HashTable(); // default constructor int getHash(std::string bezeichnung) const; };