1 | [[tags: egg]] |
---|
2 | [[toc:]] |
---|
3 | |
---|
4 | |
---|
5 | == queues |
---|
6 | |
---|
7 | Single-ended queue data structure. |
---|
8 | |
---|
9 | |
---|
10 | === Usage |
---|
11 | |
---|
12 | {{(require-extension queues)}} |
---|
13 | |
---|
14 | |
---|
15 | === Programming interface |
---|
16 | |
---|
17 | |
---|
18 | ==== list->queue |
---|
19 | |
---|
20 | <procedure>(list->queue LIST)</procedure> |
---|
21 | |
---|
22 | Returns {{LIST}} converted into a queue, where the first element |
---|
23 | of the list is the same as the first element of the queue. The resulting |
---|
24 | queue may share memory with the list and the list should not be modified |
---|
25 | after this operation. |
---|
26 | |
---|
27 | |
---|
28 | ==== make-queue |
---|
29 | |
---|
30 | <procedure>(make-queue)</procedure> |
---|
31 | |
---|
32 | Returns a newly created queue. |
---|
33 | |
---|
34 | |
---|
35 | ==== queue? |
---|
36 | |
---|
37 | <procedure>(queue? X)</procedure> |
---|
38 | |
---|
39 | Returns {{#t}} if {{X}} is a queue, or {{#f}} otherwise. |
---|
40 | |
---|
41 | |
---|
42 | ==== queue-length |
---|
43 | |
---|
44 | <procedure>(queue-length QUEUE)</procedure> |
---|
45 | |
---|
46 | Returns the current number of items stored in {{QUEUE}}. |
---|
47 | |
---|
48 | |
---|
49 | ==== queue->list |
---|
50 | |
---|
51 | <procedure>(queue->list QUEUE)</procedure> |
---|
52 | |
---|
53 | Returns {{QUEUE}} converted into a list, where the first element |
---|
54 | of the list is the same as the first element of the queue. The resulting |
---|
55 | list is freshly allocated and does not share memory with the queue object. |
---|
56 | |
---|
57 | |
---|
58 | ==== queue-add! |
---|
59 | |
---|
60 | <procedure>(queue-add! QUEUE X)</procedure> |
---|
61 | |
---|
62 | Adds {{X}} to the rear of {{QUEUE}}. |
---|
63 | |
---|
64 | |
---|
65 | ==== queue-empty? |
---|
66 | |
---|
67 | <procedure>(queue-empty? QUEUE)</procedure> |
---|
68 | |
---|
69 | Returns {{#t}} if {{QUEUE}} is empty, or {{#f}} otherwise. |
---|
70 | |
---|
71 | |
---|
72 | ==== queue-first |
---|
73 | |
---|
74 | <procedure>(queue-first QUEUE)</procedure> |
---|
75 | |
---|
76 | Returns the first element of {{QUEUE}}. If {{QUEUE}} is empty |
---|
77 | an error is signaled |
---|
78 | |
---|
79 | |
---|
80 | ==== queue-last |
---|
81 | |
---|
82 | <procedure>(queue-last QUEUE)</procedure> |
---|
83 | |
---|
84 | Returns the last element of {{QUEUE}}. If {{QUEUE}} is empty |
---|
85 | an error is signaled |
---|
86 | |
---|
87 | |
---|
88 | ==== queue-remove! |
---|
89 | |
---|
90 | <procedure>(queue-remove! QUEUE)</procedure> |
---|
91 | |
---|
92 | Removes and returns the first element of {{QUEUE}}. If {{QUEUE}} |
---|
93 | is empty an error is signaled |
---|
94 | |
---|
95 | |
---|
96 | ==== queue-push-back! |
---|
97 | |
---|
98 | <procedure>(queue-push-back! QUEUE ITEM)</procedure> |
---|
99 | |
---|
100 | Pushes an item into the first position of a queue, i.e. the next |
---|
101 | {{queue-remove!}} will return {{ITEM}}. |
---|
102 | |
---|
103 | |
---|
104 | ==== queue-push-back-list! |
---|
105 | |
---|
106 | <procedure>(queue-push-back-list! QUEUE LIST)</procedure> |
---|
107 | |
---|
108 | Pushes the items in item-list back onto the queue, |
---|
109 | so that {{(car LIST)}} becomes the next removable item. |
---|
110 | |
---|
111 | |
---|
112 | === Author |
---|
113 | |
---|
114 | The CHICKEN Team |
---|
115 | |
---|
116 | |
---|
117 | === License |
---|
118 | |
---|
119 | Copyright (c) 2014, The CHICKEN Team |
---|
120 | All rights reserved. |
---|
121 | |
---|
122 | Redistribution and use in source and binary forms, with or without |
---|
123 | modification, are permitted provided that the following conditions |
---|
124 | are met: |
---|
125 | 1. Redistributions of source code must retain the above copyright |
---|
126 | notice, this list of conditions and the following disclaimer. |
---|
127 | 2. Redistributions in binary form must reproduce the above copyright |
---|
128 | notice, this list of conditions and the following disclaimer in the |
---|
129 | documentation and/or other materials provided with the distribution. |
---|
130 | 3. The name of the authors may not be used to endorse or promote products |
---|
131 | derived from this software without specific prior written permission. |
---|
132 | |
---|
133 | THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR |
---|
134 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
---|
135 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
---|
136 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
---|
137 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
---|
138 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
---|
139 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
---|
140 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
---|
141 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
---|
142 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
143 | |
---|
144 | |
---|
145 | === Version History |
---|
146 | |
---|
147 | ; 1.0 : Extracted from {{data-structures}} core library unit and released as an egg. |
---|