1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
template<class Key, class Value>
class BinaryTreeMap
{
private:
struct Entry
{
Key key;
Value value;
...
};
BinaryTree<Entry> tree;
friend DataLoader &operator>><Key,Value>(DataLoader &in, BinaryTreeMap<Key, Value> &tree);
friend DataSaver &operator<<<Key,Value>(DataSaver &out, const BinaryTreeMap<Key, Value> &tree);
friend DataLoader &operator>><Key,Value>(DataLoader &in, Entry &entry);
friend DataSaver &operator<<<Key,Value>(DataSaver &out, const Entry &entry);
public:
...
}
template<class Key, class Value>
DataLoader &operator>>(DataLoader &in, BinaryTreeMap<Key, Value> &tree)
{
return in>>tree.tree;
}
template<class Key, class Value>
DataSaver &operator<<(DataSaver &out, const BinaryTreeMap<Key, Value> &tree)
{
return out<<tree.tree;
}
template<class Key, class Value>
DataLoader &operator>>(DataLoader &in, typename BinaryTreeMap<Key, Value>::Entry &entry)
{
return in>>entry.key>>entry.value;
}
template<class Key, class Value>
DataSaver &operator<<(DataSaver &out, const typename BinaryTreeMap<Key, Value>::Entry &entry)
{
return out<<entry.key<<entry.value;
}
...
| |