1 USING: help.markup help.syntax kernel math sequences
6 { $values { "deque" deque } { "?" "a boolean" } }
7 { $contract "Returns true if a deque is empty." }
8 { $notes "This operation is O(1)." } ;
13 { $description "Removes all elements from a deque." } ;
17 { "value" object } { "deque" deque }
19 { $description "Returns true if the " { $snippet "value" } " is found in the deque." } ;
22 { $values { "obj" object } { "deque" deque } }
23 { $description "Push the object onto the front of the deque." }
24 { $notes "This operation is O(1)." } ;
27 { $values { "obj" object } { "deque" deque } { "node" "a node" } }
28 { $contract "Push the object onto the front of the deque and return the newly created node." }
29 { $notes "This operation is O(1)." } ;
32 { $values { "obj" object } { "deque" deque } }
33 { $description "Push the object onto the back of the deque." }
34 { $notes "This operation is O(1)." } ;
37 { $values { "obj" object } { "deque" deque } { "node" "a node" } }
38 { $contract "Push the object onto the back of the deque and return the newly created node." }
39 { $notes "This operation is O(1)." } ;
43 { "seq" sequence } { "deque" deque } }
44 { $description "Pushes a sequence of elements onto the back of a deque." } ;
48 { "seq" sequence } { "deque" deque } }
49 { $description "Pushes a sequence of elements onto the front of a deque." } ;
52 { $values { "deque" deque } { "obj" object } { "?" boolean } }
53 { $contract "Returns the object at the front of the deque, and a boolean indicating if an object was found." } ;
56 { $values { "deque" deque } { "obj" object } }
57 { $description "Returns the object at the front of the deque." }
58 { $errors "Throws an error if the deque is empty." } ;
61 { $values { "deque" deque } { "obj/f" "an object or " { $link f } } }
62 { $description "A forgiving version of " { $link peek-front } ". If the deque is empty, returns " { $link f } "." } ;
65 { $values { "deque" deque } { "obj" object } }
66 { $description "Pop the object off the front of the deque and return the object." }
67 { $notes "This operation is O(1)." } ;
70 { $values { "deque" deque } }
71 { $contract "Pop the object off the front of the deque." }
72 { $notes "This operation is O(1)." } ;
75 { $values { "deque" deque } { "obj" object } { "?" boolean } }
76 { $contract "Returns the object at the back of the deque, and a boolean indicating if an object was found." } ;
79 { $values { "deque" deque } { "obj" object } }
80 { $description "Returns the object at the back of the deque." }
81 { $errors "Throws an error if the deque is empty." } ;
84 { $values { "deque" deque } { "obj/f" "an object or " { $link f } } }
85 { $description "A forgiving version of " { $link peek-back } ". If the deque is empty, returns " { $link f } "." } ;
88 { $values { "deque" deque } { "obj" object } }
89 { $description "Pop the object off the back of the deque and return the object." }
90 { $notes "This operation is O(1)." } ;
93 { $values { "deque" deque } }
94 { $contract "Pop the object off the back of the deque." }
95 { $notes "This operation is O(1)." } ;
99 { "node" object } { "deque" deque } }
100 { $contract "Deletes the node from the deque." } ;
103 { $description "A data structure that has constant-time insertion and removal of elements at both ends." } ;
109 { $description "Accesses the value stored at a node." } ;
113 { "deque" deque } { "quot" quotation } }
114 { $description "Pops off the back element of the deque and calls the quotation in a loop until the deque is empty." } ;
116 ARTICLE: "deques" "Deques"
117 "The " { $vocab-link "deques" } " vocabulary implements the deque data structure which has constant-time insertion and removal of elements at both ends."
119 "Deques must be instances of a mixin class:"
120 { $subsections deque }
121 "Deques must implement a protocol."
123 "Querying the deque:"
130 "Adding and removing elements:"
138 "Working with node objects output by " { $link push-front* } " and " { $link push-back* } ":"
143 "Utility operations built in terms of the above:"
153 "When using a deque as a queue, the convention is to queue elements with " { $link push-front } " and deque them with " { $link pop-back } "." ;