| | | | | |

Class Entry<KeyType,DataType>

struct Entry // a key,data pair
{
  const KeyType  key_;  // immutable
        DataType data_;
  Entry (const KeyType& k, const DataType& d) : key_(k),data_(d) {}
};

bool operator == (const Entry& e1, const Entry& e2)
{
  return (e1.key_ == e2.key_); // only key matters
}

bool operator <  (const Entry& e1, const Entry& e2)
{
  return (e1.key_ < e2.key_);  // only key matters
}

Entry& operator= (const Entry& that)
{
  if (this->key_ == that.key_) // assign data only if keys are equal
  {
    this->data_ = that.data_; 
  }
  else { ERROR(); }
  return *this;
}

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