Chapter Index | Slide Index | Frames [ Windows ] | Narrative On | <- prev | next -> |

Associative Array

Very useful special case of Table

aka Symbol Table

void      Put   (KeyType k, DataType d); // unimodal - overwrite data if k is in table, insert pair otherwise
DataType& Get   (KeyType k);             // return data associated with k; ensure k is in table
bool      Erase (KeyType k);             // ensure k is not in table

// syntactic sugar - Associative Array bracket operator
DataType& operator[] (KeyType k) { return Get(k); }

void     Clear ();                      // make empty

// size operations
bool     Empty       ()   const;
size_t   Size        ()   const;

// plus the usual support system:
//   logical operators ==(), !=()
//   iterator support for bidirectional iterators
//   Big 4: Constructor, Destructor, Copy Constructor, assignment operator

<- prev | next -> | Top of Page | 10. Introduction to Maps - 6 of 11