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 } }
53 { $contract "Returns the object at the front of the deque." } ;
56 { $values { "deque" deque } { "obj" object } }
57 { $description "Pop the object off the front of the deque and return the object." }
58 { $notes "This operation is O(1)." } ;
61 { $values { "deque" deque } }
62 { $contract "Pop the object off the front of the deque." }
63 { $notes "This operation is O(1)." } ;
66 { $values { "deque" deque } { "obj" object } }
67 { $contract "Returns the object at the back of the deque." } ;
70 { $values { "deque" deque } { "obj" object } }
71 { $description "Pop the object off the back of the deque and return the object." }
72 { $notes "This operation is O(1)." } ;
75 { $values { "deque" deque } }
76 { $contract "Pop the object off the back of the deque." }
77 { $notes "This operation is O(1)." } ;
81 { "node" object } { "deque" deque } }
82 { $contract "Deletes the node from the deque." } ;
85 { $description "A data structure that has constant-time insertion and removal of elements at both ends." } ;
91 { $description "Accesses the value stored at a node." } ;
95 { "deque" deque } { "quot" quotation } }
96 { $description "Pops off the back element of the deque and calls the quotation in a loop until the deque is empty." } ;
98 ARTICLE: "deques" "Deques"
99 "The " { $vocab-link "deques" } " vocabulary implements the deque data structure which has constant-time insertion and removal of elements at both ends."
101 "Deques must be instances of a mixin class:"
102 { $subsection deque }
103 "Deques must implement a protocol."
105 "Querying the deque:"
106 { $subsection peek-front }
107 { $subsection peek-back }
108 { $subsection deque-empty? }
109 { $subsection deque-member? }
110 "Adding and removing elements:"
111 { $subsection push-front* }
112 { $subsection push-back* }
113 { $subsection pop-front* }
114 { $subsection pop-back* }
115 { $subsection clear-deque }
116 "Working with node objects output by " { $link push-front* } " and " { $link push-back* } ":"
117 { $subsection delete-node }
118 { $subsection node-value }
119 "Utility operations built in terms of the above:"
120 { $subsection push-front }
121 { $subsection push-all-front }
122 { $subsection push-back }
123 { $subsection push-all-back }
124 { $subsection pop-front }
125 { $subsection pop-back }
126 { $subsection slurp-deque }
127 "When using a deque as a queue, the convention is to queue elements with " { $link push-front } " and deque them with " { $link pop-back } "." ;