setsmultisetsand multimaps we conclude this by examining several additional abstractions that are closely related to the map adtand that can be implemented using data structures similar to those for map set is an unordered collection of elementswithout duplicatesthat typically supports efficient membership tests in essenceelements of set are like keys of mapbut without any auxiliary values multiset (also known as bagis set-like container that allows duplicates multimap is similar to traditional mapin that it associates values with keyshoweverin multimap the same key can be mapped to multiple values for examplethe index of this book maps given term to one or more locations at which the term occurs elsewhere in the book the set adt python provides support for representing the mathematical notion of set through the built-in classes frozenset and setas originally discussed in with frozenset being an immutable form both of those classes are implemented using hash tables in python python' collections module defines abstract base classes that essentially mirror these built-in classes although the choice of names is counterintuitivethe abstract base class collections set matches the concrete frozenset classwhile the abstract base class collections mutableset is akin to the concrete set class in our own discussionwe equate the "set adtwith the behavior of the builtin set class (and thusthe collections mutableset base classwe begin by listing what we consider to be the five most fundamental behaviors for set ss add( )add element to the set this has no effect if the set already contains discard( )remove element from the setif present this has no effect if the set does not contain in sreturn true if the set contains element in pythonthis is implemented with the special contains method len( )return the number of elements in set in pythonthis is implemented with the special method len iter( )generate an iteration of all elements of the set in pythonthis is implemented with the special method iter