| | | | | |

Table as Set<Entry>

class Entry;

class Table
{
private:
  Set < Entry >  table_;

public:
  void Insert (const KeyType& k, const DataType& d)
  {
    Entry e(k,d);
    table_.Insert(e); // assumes Set is unimodal
  }
  bool Retrieve (const KeyType& k, DataType& d)
  {
    Entry e(k,DataType());
    Set::Iterator i = table_.Includes(e);
    if (i == table_.End()) return 0;
    d = (*i).data_;   // d now refers to stored data
    return 1;
  }
};

| | Top of Page | 10. Introduction to Maps - 9 of 11