# Sets/OOP

### From charlesreid1

Sets can utilize many of the same OOP features during implementation that Maps do (see Maps/OOP).

However, one important feature is that sets can be implemented using nothing more than a hash table or hash map, where the value itself is its own key. This enables the definition of a Set class, whose interface may be entirely different from a map or a hash table, but which nevertheless utilizes these data structures under the hood.

The Set class should not just blindly use the HashMap, however, as the HashMap allocates space for both keys and values, and all we need to implement a set are the values.

As in mathematics, the Set type can be thought of as an elemental building block of more complex objects. For example, @phishman3579 on github implemented several data structures in Java (Link: https://github.com/phishman3579/java-algorithms-implementation), but one he did not implement was the Set type. Instead, his library relies on the Java API's HashSet, TreeSet, and AbstractSet classes.

Maps and DictionariesSeries on Data Structures
Maps Map implementations: Maps/AbstractMap Dictionary implementations: Dictionaries/LinkedDict
Hash Maps/OOP Hash Maps/Dynamic Resizing Hash functions: Hash Functions Hash map implementations: Hash Maps/AbstractHashMap
Skip Lists Java implementations: SkipList
Sets
· Template:MapsFlagBase · e |