Search⌘ K
AI Features

Unordered Collections

Explore unordered collections in Clojure, including hash maps, sorted maps, and sets. Understand when to use each collection type, how to instantiate them, and essential functions for data access and manipulation while maintaining immutability.

Maps

A map is a collection that maps keys to values. In Clojure, there are two different types—hashed and sorted.

Hash map

A hash map is the most used map in Clojure. It requires keys that correctly support hashCode and equals.

When should we use it?

They’re useful for:

  • Representing entities

  • When the order isn’t important, and we’re going to perform random access using keys

  • When we don’t want to have duplicated keys

  • Associating keys to values

  • Removing key-value pairs based on the key

  • Fast count ...