From 229d0d8ca88bc344bed89e46541b325c1d267996 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Fri, 6 May 2011 15:58:09 +0200 Subject: r Use Erlang specs and types for documentation --- lib/stdlib/doc/src/queue.xml | 286 +++++++++++++++---------------------------- 1 file changed, 96 insertions(+), 190 deletions(-) (limited to 'lib/stdlib/doc/src/queue.xml') diff --git a/lib/stdlib/doc/src/queue.xml b/lib/stdlib/doc/src/queue.xml index 5ada1c2c57..383f52d10d 100644 --- a/lib/stdlib/doc/src/queue.xml +++ b/lib/stdlib/doc/src/queue.xml @@ -4,7 +4,7 @@
- 19962009 + 19962011 Ericsson AB. All Rights Reserved. @@ -88,122 +88,94 @@ Original API + + + queue() +

As returned by new/0.

+
+
+ - new() -> Q + Create an empty queue - - Q = queue() -

Returns an empty queue.

- is_queue(Term) -> true | false + Test if a term is a queue - - Term = term() - -

Tests if Q is a queue and returns true if so and +

Tests if Term is a queue and returns true if so and false otherwise.

- is_empty(Q) -> true | false + Test if a queue is empty - - Q = queue() - -

Tests if Q is empty and returns true if so and +

Tests if Q is empty and returns true if so and false otherwise.

- len(Q) -> N + Get the length of a queue - - Q = queue() - N = integer() - -

Calculates and returns the length of queue Q.

+

Calculates and returns the length of queue Q.

- in(Item, Q1) -> Q2 + Insert an item at the rear of a queue - - Item = term() - Q1 = Q2 = queue() - -

Inserts Item at the rear of queue Q1. - Returns the resulting queue Q2.

+

Inserts Item at the rear of queue Q1. + Returns the resulting queue Q2.

- in_r(Item, Q1) -> Q2 + Insert an item at the front of a queue - - Item = term() - Q1 = Q2 = queue() - -

Inserts Item at the front of queue Q1. - Returns the resulting queue Q2.

+

Inserts Item at the front of queue Q1. + Returns the resulting queue Q2.

- out(Q1) -> Result + Remove the front item from a queue - - Result = {{value, Item}, Q2} | {empty, Q1} - Q1 = Q2 = queue() - -

Removes the item at the front of queue Q1. Returns the - tuple {{value, Item}, Q2}, where Item is the - item removed and Q2 is the resulting queue. If Q1 is - empty, the tuple {empty, Q1} is returned.

+

Removes the item at the front of queue Q1. Returns the + tuple {{value, Item}, Q2}, where Item is the + item removed and Q2 is the resulting queue. If Q1 is + empty, the tuple {empty, Q1} is returned.

- out_r(Q1) -> Result + Remove the rear item from a queue - - Result = {{value, Item}, Q2} | {empty, Q1} - Q1 = Q2 = queue() - -

Removes the item at the rear of the queue Q1. Returns the - tuple {{value, Item}, Q2}, where Item is the - item removed and Q2 is the new queue. If Q1 is - empty, the tuple {empty, Q1} is returned.

+

Removes the item at the rear of the queue Q1. Returns the + tuple {{value, Item}, Q2}, where Item is the + item removed and Q2 is the new queue. If Q1 is + empty, the tuple {empty, Q1} is returned.

- from_list(L) -> queue() + Convert a list to a queue - - L = list() - -

Returns a queue containing the items in L in the +

Returns a queue containing the items in L in the same order; the head item of the list will become the front item of the queue.

- to_list(Q) -> list() + Convert a queue to a list - - Q = queue() -

Returns a list of the items in the queue in the same order; the front item of the queue will become the head of the list.

@@ -211,57 +183,43 @@
- reverse(Q1) -> Q2 + Reverse a queue - - Q1 = Q2 = queue() - -

Returns a queue Q2 that contains the items of - Q1 in the reverse order.

+

Returns a queue Q2 that contains the items of + Q1 in the reverse order.

- split(N, Q1) -> {Q2,Q3} + Split a queue in two - - N = integer() - Q1 = Q2 = Q3 = queue() - -

Splits Q1 in two. The N front items - are put in Q2 and the rest in Q3

+

Splits Q1 in two. The N front items + are put in Q2 and the rest in Q3

- join(Q1, Q2) -> Q3 + Join two queues - - Q1 = Q2 = Q3 = queue() - -

Returns a queue Q3 that is the result of joining - Q1 and Q2 with Q1 in front of - Q2.

+

Returns a queue Q3 that is the result of joining + Q1 and Q2 with Q1 in front of + Q2.

- filter(Fun, Q1) -> Q2 + Filter a queue - - Fun = fun(Item) -> bool() | list() - Q1 = Q2 = queue() - -

Returns a queue Q2 that is the result of calling - Fun(Item) on all items in Q1, +

Returns a queue Q2 that is the result of calling + Fun(Item) on all items in Q1, in order from front to rear.

-

If Fun(Item) returns true, Item +

If Fun(Item) returns true, Item is copied to the result queue. If it returns false, - Item is not copied. If it returns a list + Item is not copied. If it returns a list the list elements are inserted instead of Item in the result queue.

-

So, Fun(Item) returning [Item] is thereby +

So, Fun(Item) returning [Item] is thereby semantically equivalent to returning true, just as returning [] is semantically equivalent to returning false. But returning a list builds @@ -269,15 +227,11 @@ - member(Item, Q) -> bool() + Test if an item is in a queue - - Item = term() - Q = queue() - -

Returns true if Item matches some element - in Q, otherwise false.

+

Returns true if Item matches some element + in Q, otherwise false.

@@ -290,77 +244,53 @@ - get(Q) -> Item + Return the front item of a queue - - Item = term() - Q = queue() - -

Returns Item at the front of queue Q.

-

Fails with reason empty if Q is empty.

+

Returns Item at the front of queue Q.

+

Fails with reason empty if Q is empty.

- get_r(Q) -> Item + Return the rear item of a queue - - Item = term() - Q = queue() - -

Returns Item at the rear of queue Q.

-

Fails with reason empty if Q is empty.

+

Returns Item at the rear of queue Q.

+

Fails with reason empty if Q is empty.

- drop(Q1) -> Q2 + Remove the front item from a queue - - Item = term() - Q1 = Q2 = queue() - -

Returns a queue Q2 that is the result of removing - the front item from Q1.

-

Fails with reason empty if Q1 is empty.

+

Returns a queue Q2 that is the result of removing + the front item from Q1.

+

Fails with reason empty if Q1 is empty.

- drop_r(Q1) -> Q2 + Remove the rear item from a queue - - Item = term() - Q1 = Q2 = queue() - -

Returns a queue Q2 that is the result of removing - the rear item from Q1.

-

Fails with reason empty if Q1 is empty.

+

Returns a queue Q2 that is the result of removing + the rear item from Q1.

+

Fails with reason empty if Q1 is empty.

- peek(Q) -> {value,Item} | empty + Return the front item of a queue - - Item = term() - Q = queue() - -

Returns the tuple {value, Item} where Item is the - front item of Q, or empty if Q1 is empty.

+

Returns the tuple {value, Item} where Item is the + front item of Q, or empty if Q is empty.

- peek_r(Q) -> {value,Item} | empty + Return the rear item of a queue - - Item = term() - Q = queue() - -

Returns the tuple {value, Item} where Item is the - rear item of Q, or empty if Q1 is empty.

+

Returns the tuple {value, Item} where Item is the + rear item of Q, or empty if Q is empty.

@@ -372,80 +302,56 @@ - cons(Item, Q1) -> Q2 + Insert an item at the head of a queue - - Item = term() - Q1 = Q2 = queue() - -

Inserts Item at the head of queue Q1. Returns - the new queue Q2.

+

Inserts Item at the head of queue Q1. Returns + the new queue Q2.

- head(Q) -> Item + Return the item at the head of a queue - - Item = term() - Q = queue() - -

Returns Item from the head of queue Q.

-

Fails with reason empty if Q is empty.

+

Returns Item from the head of queue Q.

+

Fails with reason empty if Q is empty.

- tail(Q1) -> Q2 + Remove the head item from a queue - - Item = term() - Q1 = Q2 = queue() - -

Returns a queue Q2 that is the result of removing - the head item from Q1.

-

Fails with reason empty if Q1 is empty.

+

Returns a queue Q2 that is the result of removing + the head item from Q1.

+

Fails with reason empty if Q1 is empty.

- snoc(Q1, Item) -> Q2 + Insert an item at the tail of a queue - - Item = term() - Q1 = Q2 = queue() - -

Inserts Item as the tail item of queue Q1. Returns - the new queue Q2.

+

Inserts Item as the tail item of queue Q1. Returns + the new queue Q2.

- daeh(Q) -> Item - last(Q) -> Item + + Return the tail item of a queue - - Item = term() - Q = queue() - -

Returns the tail item of queue Q.

-

Fails with reason empty if Q is empty.

+

Returns the tail item of queue Q.

+

Fails with reason empty if Q is empty.

- liat(Q1) -> Q2 - init(Q1) -> Q2 - lait(Q1) -> Q2 + + + Remove the tail item from a queue - - Item = term() - Q1 = Q2 = queue() - -

Returns a queue Q2 that is the result of removing - the tail item from Q1.

-

Fails with reason empty if Q1 is empty.

+

Returns a queue Q2 that is the result of removing + the tail item from Q1.

+

Fails with reason empty if Q1 is empty.

The name lait/1 is a misspelling - do not use it anymore.

-- cgit v1.2.3