---
description: >-
  Collections of key-value pairs such that each unique key can have only one
  occurrence in the collection.
---

# Maps

Import alias `'ads-js/maps'`

This group provides implementations of different data-structures for fast search and access. It does not include common for such libraries [HashMap](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)/[HashSet](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) classes because they do already exist in JavaScript since ES6. Instead of replacing standard JS built-ins, classes presented here implement the same interfaces and may be used alongside with the first ones in the same client code.

{% hint style="info" %}
This may sound confusing after what just have been said but one difference with the standard interface was introduced in get() method of all maps in ADSJS. Call to it throws an error instead of returning an undefined if key was not found. The necessity here is in fact that in TypeScript with strict types set on you will have to perform explicit type-checking for undefined each time even if you are not expecting to have such situations in your code in practice. Since convenience for TypeScript users is priority for this package so this change have been done.&#x20;
{% endhint %}

### Table of contents

[SortedMap](maps/sortedmap) - a map that provides ordering on its keys. Keys are ordered by a [comparator](comparators) provided at map creation time or by default as strings.

[MaximaSet](maps/maximaset) - container which stores only pairs forming strictly increasing trend in both keys and values. This structure is based on SortedMap.&#x20;

[AVLTreeMap](maps/avltreemap) - sorted map based on an AVL binary tree structure.

[SplayTreeMap](maps/splaytreemap) - sorted map based on a splay binary tree structure.

[RedBlackTreeMap](maps/redblacktreemap) - sorted map based on a red-black binary tree structure.
