# Module fix_queue

- Description
- Data Types
- Function Index
- Function Details

Queue implementation with a fixed maximum length.

Copyright © 2009-2011 Zuse Institute Berlin

Version: $Id$

Authors: Christian Hennig (`hennig@zib.de`).

## Description

Queue implementation with a fixed maximum length.

## Data Types

### fix_queue()

abstract datatype: `fix_queue(Element)`

## Function Index

add/2 | Adds an element to the given queue.
add_unique_head/4 | Adds an element to the given queue.
length/1 |
map/2 | Maps a function to all elements of the given queue.
max_length/1 |
new/1 | Creates a new fixed-size queue.
queue/1 |
remove/3 |

## Function Details

### new/1

    new(MaxLength :: pos_integer()) -> fix_queue(any())

Creates a new fixed-size queue.

### add/2

    add(Element, Queue :: fix_queue(Element)) -> fix_queue(Element)

Adds an element to the given queue.

### add_unique_head/4

    add_unique_head(Element,
                    Queue :: fix_queue(Element),
                    EqFun ::
                        fun((Old :: Element, New :: Element) ->
                                boolean()),
                    SelectFun ::
                        fun((Old :: Element, New :: Element) ->
                                Element)) ->
                       fix_queue(Element)

Adds an element to the given queue. If there is already an equal element at the "head" (rear) of the queue, it will be replaced by the element selected by SelectFun. Note that this is much cheaper than checking all elements!

### map/2

    map(Fun :: fun((Element) -> X), Queue :: fix_queue(Element)) ->
           [X]

Maps a function to all elements of the given queue.

### remove/3

    remove(Element,
           Queue :: fix_queue(Element),
           EqFun :: fun((Element, Element) -> boolean())) ->
              fix_queue(Element)

### length/1

    length(X1 :: fix_queue(any())) -> non_neg_integer()

### max_length/1

    max_length(X1 :: fix_queue(any())) -> pos_integer()

### queue/1

    queue(X1 :: fix_queue(Element)) -> queue:queue(Element)

Generated by EDoc, Feb 29 2016, 16:12:17.