Έχω να εφαρμόσουν μια κατηγορία που συμπεριφέρεται σαν ένα χάρτη της χορδές χρησιμοποιώντας δυαδικό δέντρο αναζήτησης. Αυτή είναι η κατηγορία που υλοποιούνται:
template<class T>
class StringMapper {
private:
// Pair
struct Pair {
std::string el1;
T el2;
};
// Nod
struct Node {
Pair* data;
Node* left;
Node* right;
Node()
{
data = new Pair;
}
~Node()
{
delete data;
}
int nod_size()
{
// code here
}
};
Node* root;
public:
StringMapper()
{
root = 0;
}
~StringMapper() {}
void insert(std::string from, const T& to)
{
// code here
}
bool find(std::string from,const T& to) const
{
return find(root, to);
}
bool find(Node* node, const T& value) const
{
// code here
}
bool getFirstPair(std::string& from, T& to)
{
if(root != 0)
{
from = root->data->el1;
to = root->data->el2;
return true;
}
return false;
}
bool getNextPair(std::string& from, T& to)
{
if(root != 0)
{
}
return false;
}
int size() const
{
return root->nod_size();
}
};
Για να είμαι ειλικρινής δεν ξέρω πώς να εφαρμόσουν τη λειτουργία getNextPair().
Αν κάποιος μπορούσε να με βοηθήσει θα το εκτιμούσα.













