I'm new to c ++ and I'm not able to create an iterator to traverse a hash table. The table is composed of a vector of n linked list positions (created by me). I need an iterator to go from beginning to end, line by line, to be able to access each one. ( I do not want the code, only guidelines ). As a matter of curiosity, each in the list represents a vertex in a graph, to make a search in depth or width, precise runs vertex by vertex, hence the need of the iterator The list is implemented like this:
class ListVertices
{
public:
ListVertices();
~ListVertices();
void put(const int& v);
void del(const int& v);
Vertice* get(const int& v);
void imprime() const;
private:
Vertice* first; // ponteiro para o primeiro no
Vertice* getNewVertice(const int& v, Vertice* _next);
};
And the hash table:
class Hashtable
{
public:
Hashtable(const int& _n);
~Hashtable();
void putKey(const int& key); /// insere uma chave na tabela
void removeKey(const int key); /// remove uma chave na tabela
Vertice* getkey(const int& key); /// retorna um ponteiro para o vertice com id = _key
void print();
private:
int n; /// quantidade de chaves
int m; /// tamanho da tabela
ListVertices *table; /// vetor de listas ligadas
/// Funções utilitárias
int hash(const int& key); /// devolve um posiçao na tabela entre 0 e m-1(inclusive)
int sizeTable(); /// calcula o tamanho da tabela
void resizeTable( const int& newSize); /// redimensiona o tamanho da tabela
};