map_queue v0.2.0 MapQueue

MapQueue is an implemenation of a queue with a single map as the underlying data structure.

The benefit of using a MapQueue over a list is that appending to the tail of a list ++ can become quite an expensive operation when the list is large.

With MapQueue adding or removing items from the queue is roughtly as fast as the same operation on a Map.

MapQueue keeps track of items in a map with integers as keys, and also tracks the highest (last) and lowest (first) items in the map.

Since each item in a MapQueue is tracked by an integer, the memory consumption of a MapQueue will be higher than that of an equivalent list or Erlang :queue.

Link to this section Summary

Link to this section Types

Link to this type t()
t() :: %MapQueue{
  first: integer(),
  last: integer(),
  map: %{required(integer()) => any()}
}

Link to this section Functions

Link to this function append(queue, enumerable)
append(MapQueue.t(), any()) :: MapQueue.t()
Link to this function new(enumerable)
new(any()) :: MapQueue.t()
Link to this function pop(queue)
pop(MapQueue.t()) :: :empty | {any(), MapQueue.t()}
Link to this function pop(queue, count)
Link to this function pop_rear(queue)
pop_rear(MapQueue.t()) :: :empty | {any(), MapQueue.t()}
Link to this function pop_rear(queue, count)
pop_rear(MapQueue.t(), non_neg_integer()) :: {list(), MapQueue.t()}
Link to this function prepend(queue, enumerable)
prepend(MapQueue.t(), any()) :: MapQueue.t()
Link to this function push(queue, value)
push(MapQueue.t(), any()) :: MapQueue.t()
Link to this function push_front(queue, value)
push_front(MapQueue.t(), any()) :: MapQueue.t()
Link to this function slice(map_queue, index, amount)
slice(MapQueue.t(), any(), any()) :: MapQueue.t()