I am implementing a class using a map
, like so:
class Letras {
typedef std::pair<int, int> p_c;
std::map<char, p_c> bolsa;
public:
...
};
And I'd like to implement the functionality of an iterator, to be used like so:
Letras l;
Letras::iterator it;
for ( it = l.begin(); it != l.end(); ++it )
cout << *it << endl;
So that it prints out the char
s from the std::map
first component (key).
Thanks in advance.
More information about Letras
Letras
is a class that implements a Scrubble-like letter set, the map
is used to represent a set of letras (letters in Spanish) like the following:
{{letter_1, {quantity_1, score_1}}, {letter_2, {quantity_2, score_2}}, ..., {letter_n, {quantity_n, score_n}}}
Where letter_i
is a certain letter from the set, quantity_i
is the amount of times that letter is in the set (a Scrubble-like letter set can have various identical letters) and score_i
is the letter score.
I have used a map because a letter can only have an associated score, so that in this class, i != j => letter_i != letter_j
.
The utility of Letras
is to find the best words formed by a certain letter set from a Diccionario
class (dictionary), another class that has implemented a DAWG structure for fast search and lookup.