Skip to content

Instantly share code, notes, and snippets.

@majidazimi
majidazimi / ArrayMap.scala
Created November 18, 2018 17:14
ArrayMap implementation
import java.util.Arrays
import scala.reflect.ClassTag
import scala.collection.AbstractIterator
/**
* Conceptually, a map where the (implicit) keys are positive `Int` values and the values are
* non-`null`; `null` values are not permitted!
* The key values always have to be larger than or equal to 0 and are ideally continues
* (0,1,2,3,...). The values are stored in a plain array to enable true O(1) retrieval.
* Furthermore, the array is only as large as it has to be to keep the value associated