Sets and MultiSets

Steven J. Zeil

Old Dominion University, Dept. of Computer Science

Table of Contents

1. Overview of Sets and Maps
2. The Set ADT
2.1. The template header
2.2. Internal type names
2.3. Constructors & Assignment
2.4. Status
2.5. Insert & Erase
2.6. Cannot Store Data Via Iterators
2.7. Access
3. A Simple Example of Set

The data structures and ADTs we have looked at so far in this course have been what are sometimes called sequential containers - they maintain elements in a known sequence and we access the elements by indicating a position in the sequence from which we wish to obtain an element. Sometimes we indicate this position numerically (e.g., a[23]), sometimes symbolically (e.g., myVector.front()), but always, in order to get an element, we have to know where it is in relation to the other elements.

Now we turn our attention to associative containers, ones in which the container's implementation maintains the elements in a sequence that is intended to allow rapid access to elements based upon their value.

This section of the course will be a bit different from the ones that have gone before. Previously, we have introduced an abstraction (vector, list, deque, etc) and also discussed how to implement it. The implementation of sets and maps is difficult enough, however, that we'll want to look at different possible underlying data structures, so for right now we'll only look at the set and map ADTs and how to use them, and we'll leave the implementation for later.


In the Forum:

(no threads at this time)