PreviousUpNext

15.3.358  src/lib/src/bounded-queue.api

## bounded-queue.api
#
# Immutable, fully-persistent bounded queues.

# Compiled by:
#     src/lib/std/standard.lib


# See also:
#     src/lib/src/queue.api

# This api is implemented in:
#
#     src/lib/src/bounded-queue.pkg

api Bounded_Queue {
    #
    Queue(X) = QUEUE  { front:  List(X),                                        # No harm in publishing the structure -- it is not going to change.
                        back:   List(X),                                        # 
                        length: Int,                                            # Current combined lengths of front+back lists.
                        bound:  Int
                      };

    make_queue:               Int       -> Queue(X);                            # Construct an empty queue with given bound.  We don't have empty_queue here because we don't know what bound to give it.
    queue_is_empty:           Queue(X)  -> Bool;

    put_on_back_of_queue:    (Queue(X), X) -> Queue(X);                         # Normal way of adding an item.
    push:                    (Queue(X), X) -> Queue(X);                         # Synonym for previous.

    take_from_front_of_queue: Queue(X) -> (Queue(X), Null_Or(X));               # Normal way of removing an item.
    pull:                     Queue(X) -> (Queue(X), Null_Or(X));               # Synonym for previous.

    put_on_front_of_queue:   (Queue(X), X) -> Queue(X);                         # Bass-ackwards way of adding an item.
    unpull:                  (Queue(X), X) -> Queue(X);                         # Synonym for previous.

    take_from_back_of_queue:  Queue(X) -> (Queue(X), Null_Or(X));               # Bass-ackwards way of removing an item.
    unpush:                   Queue(X) -> (Queue(X), Null_Or(X));               # Synonym for previous.

    to_list:                  Queue(X) -> List(X);
    from_list:               (List(X), Int) -> Queue(X);                        # Int is the bound.

    unpull':                 (Queue(X), List(X)) -> Queue(X);
    push':                   (Queue(X), List(X)) -> Queue(X);

    length:                   Queue(X) -> Int;
};                                                                              #  api Queue


## COPYRIGHT (c) 1993 by AT&T Bell Laboratories.  See SMLNJ-COPYRIGHT file for details.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext