Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
fixedqueue.cc
Go to the documentation of this file.
1
2/*
3 Aleph_w
4
5 Data structures & Algorithms
6 version 2.0.0b
7 https://github.com/lrleon/Aleph-w
8
9 This file is part of Aleph-w library
10
11 Copyright (c) 2002-2026 Leandro Rabindranath Leon
12
13 Permission is hereby granted, free of charge, to any person obtaining a copy
14 of this software and associated documentation files (the "Software"), to deal
15 in the Software without restriction, including without limitation the rights
16 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 copies of the Software, and to permit persons to whom the Software is
18 furnished to do so, subject to the following conditions:
19
20 The above copyright notice and this permission notice shall be included in all
21 copies or substantial portions of the Software.
22
23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 SOFTWARE.
30*/
31
32
33
38# include <vector>
39
40# include <gtest/gtest.h>
41
42# include <tpl_arrayQueue.H>
43
44# include <ahFunctional.H>
45
46# include <limits>
47# include <stdexcept>
48# include <type_traits>
49# include <utility>
50
51using namespace std;
52using namespace testing;
53using namespace Aleph;
54
55constexpr size_t N = 17;
56
57struct SimpleQueue : public Test
58{
59 size_t n = 0;
62 {
63 for (size_t i = 0; i < N; ++i, ++n)
64 q.put(i);
65 }
66 void print() const
67 {
68 cout << "q ="; q.for_each([] (auto i) { cout << " " << i; }); cout << endl;
69 }
70};
71
72struct ComplexQueue : public Test
73{
74 size_t n = 0;
77 {
78 for (size_t i = 0; i < N; ++i, ++n)
79 q.put({ int(i), 1, 2, int(i) });
80 }
81};
82
83TEST(FixedQueue, empty_queue)
84{
86 EXPECT_TRUE(q.is_empty());
87 EXPECT_EQ(q.size(), 0);
88}
89
90// The capacity is the least power of two not less than the one asked for.
91// It was 1 << (log2(d) + 1), with the logarithm of a double: log2(0) is
92// -inf, which a size_t does not hold, and past 2^63 that shift is of 64
93// bits or more, so that FixedQueue<int>(2^63 + 1) had a capacity of 1
94TEST(FixedQueue, capacity_is_the_least_power_of_two_not_less_than_the_one_asked)
95{
96 const pair<size_t, size_t> cases[] = {{0, 1}, {1, 1}, {2, 2}, {3, 4}, {5, 8},
97 {1000, 1024}, {1024, 1024}, {1025, 2048}};
98 for (const auto & [d, capacity] : cases)
99 EXPECT_EQ(FixedQueue<int>(d).capacity(), capacity) << d;
100
101 EXPECT_THROW((void) FixedQueue<int>((size_t(1) << 63) + 1), overflow_error);
102 EXPECT_THROW((void) FixedQueue<int>(numeric_limits<size_t>::max()), overflow_error);
103}
104
105TEST(FixedQueue, fill_and_empty_queue)
106{
108 const size_t N = q.capacity();
109 for (int i = 0; i < N; ++i)
110 {
111 ASSERT_EQ(q.put(i), i);
112 ASSERT_EQ(q.rear(), i);
113 ASSERT_EQ(q.front(), 0);
114 }
115 EXPECT_EQ(q.size(), N);
116 EXPECT_FALSE(q.is_empty());
117
118 for (int i = 0; i < N; ++i)
119 {
120 ASSERT_EQ(q.front(i), i);
121 ASSERT_EQ(q.rear(i), N - i - 1);
122 }
123
124 for (int i = 0; i < N; ++i)
125 {
126 ASSERT_EQ(q.front(), i);
127 ASSERT_EQ(q.rear(), N - 1);
128 ASSERT_EQ(q.get(), i);
129 }
130 EXPECT_TRUE(q.is_empty());
131 EXPECT_EQ(q.size(), 0);
132 EXPECT_EQ(q.capacity(), N);
133}
134
135TEST_F(SimpleQueue, put_and_get_stress)
136{
137 EXPECT_LT(q.size(), q.capacity());
138
139 // fill until complete initial_cap
140 for (int i = q.size(); i < q.capacity(); ++i)
141 ASSERT_EQ(q.put(i), i);
142
143 EXPECT_EQ(q.size(), q.capacity());
144
145 for (size_t i = 0; i < q.size(); ++i)
146 {
147 ASSERT_EQ(q.front(i), i);
148 ASSERT_EQ(q.rear(i), q.size() - i - 1);
149 }
150
151 const size_t nn = q.size();
152
153 // get out the half
154 for (size_t i = 0; i < nn/2; ++i)
155 ASSERT_EQ(q.get(), i);
156
157 EXPECT_EQ(q.size(), nn/2);
158
159 // test consistency of remaining items
160 for (size_t i = 0; i < nn/2; ++i)
161 ASSERT_EQ(q.front(i), i + nn/2);
162
163 // now extract them all
164 for (size_t i = 0; i < nn/2; ++i)
165 ASSERT_EQ(q.get(), i + nn/2);
166
167 EXPECT_EQ(q.size(), 0);
168 EXPECT_TRUE(q.is_empty());
169
170 // now we put the queue thus
171 //
172 // xxx------xxxxxxx
173 //
174 // where x is an item
175 const size_t cap = q.capacity();
176 for (size_t i = 0; i < cap; ++i)
177 ASSERT_EQ(q.put(i), i);
178
179 for (size_t i = 0; i < cap/4; ++i) // extract a fourth
180 ASSERT_EQ(q.get(), i);
181
182 ASSERT_FALSE(q.is_empty());
183 ASSERT_EQ(q.size(), 3*cap/4);
184
185 for (size_t i = 0; i < cap/4; ++i) // put them again
186 ASSERT_EQ(q.put(i), i);
187
188 for (size_t i = 0; i < 3*cap/4; ++i) // extract and verify the 3/4 oldest
189 ASSERT_EQ(q.get(), cap/4 + i);
190
191 // now extract and verify the 1/4 remaining
192 for (size_t i = 0; i < cap/4; ++i)
193 ASSERT_EQ(q.get(), i);
194}
195
196TEST_F(ComplexQueue, put_and_stress)
197{
198 EXPECT_LT(q.size(), q.capacity());
199
200 // fill until complete initial_cap
201 for (int i = q.size(); i < q.capacity(); ++i)
202 {
203 auto & l = q.put({int(i), 1, 2, int(i)});
204 ASSERT_EQ(l.get_first(), i);
205 ASSERT_EQ(l.get_last(), i);
206 ASSERT_EQ(l.nth(1), 1);
207 ASSERT_EQ(l.nth(2), 2);
208 }
209
210 EXPECT_EQ(q.size(), q.capacity());
211
212 for (size_t i = 0; i < q.size(); ++i)
213 {
214 auto & lf = q.front(i);
215 ASSERT_EQ(lf.get_first(), i);
216 ASSERT_EQ(lf.get_last(), i);
217 ASSERT_EQ(lf.nth(1), 1);
218 ASSERT_EQ(lf.nth(2), 2);
219
220 auto & lr = q.rear(i);
221 ASSERT_EQ(lr.get_first(), q.size() - i - 1);
222 ASSERT_EQ(lr.get_last(), q.size() - i - 1);
223 ASSERT_EQ(lr.nth(1), 1);
224 ASSERT_EQ(lr.nth(2), 2);
225 }
226
227 const size_t nn = q.size();
228
229 // get out the half
230 for (size_t i = 0; i < nn/2; ++i)
231 {
232 auto l = q.get();
233 ASSERT_EQ(l.get_first(), i);
234 ASSERT_EQ(l.get_last(), i);
235 ASSERT_EQ(l.nth(1), 1);
236 ASSERT_EQ(l.nth(2), 2);
237 }
238
239 EXPECT_EQ(q.size(), nn/2);
240
241 // test consistency of remaining items
242 for (size_t i = 0; i < nn/2; ++i)
243 {
244 auto & l = q.front(i);
245 ASSERT_EQ(l.get_first(), i + nn/2);
246 ASSERT_EQ(l.get_last(), i + nn/2);
247 ASSERT_EQ(l.nth(1), 1);
248 ASSERT_EQ(l.nth(2), 2);
249 }
250
251 // now extract them all
252 for (size_t i = 0; i < nn/2; ++i)
253 {
254 auto l = q.get();
255 ASSERT_EQ(l.get_first(), i + nn/2);
256 ASSERT_EQ(l.get_last(), i + nn/2);
257 ASSERT_EQ(l.nth(1), 1);
258 ASSERT_EQ(l.nth(2), 2);
259 }
260
261 EXPECT_EQ(q.size(), 0);
262 EXPECT_TRUE(q.is_empty());
263
264 // now we put the queue thus
265 //
266 // xxx------xxxxxxx
267 //
268 // where x is an item
269 const size_t cap = q.capacity();
270 for (size_t i = 0; i < cap; ++i)
271 {
272 auto & l = q.put({int(i), 1, 2, int(i)});
273 ASSERT_EQ(l.get_first(), i);
274 ASSERT_EQ(l.get_last(), i);
275 ASSERT_EQ(l.nth(1), 1);
276 ASSERT_EQ(l.nth(2), 2);
277 }
278
279 for (size_t i = 0; i < cap/4; ++i) // extract a fourth
280 {
281 auto l = q.get();
282 ASSERT_EQ(l.get_first(), i);
283 ASSERT_EQ(l.get_last(), i);
284 ASSERT_EQ(l.nth(1), 1);
285 ASSERT_EQ(l.nth(2), 2);
286 }
287
288 ASSERT_FALSE(q.is_empty());
289 ASSERT_EQ(q.size(), 3*cap/4);
290
291 for (size_t i = 0; i < cap/4; ++i) // put them again
292 {
293 auto l = q.put({int(i), 1, 2, int(i)});
294 ASSERT_EQ(l.get_first(), i);
295 ASSERT_EQ(l.get_last(), i);
296 ASSERT_EQ(l.nth(1), 1);
297 ASSERT_EQ(l.nth(2), 2);
298 }
299
300 for (size_t i = 0; i < 3*cap/4; ++i) // extract and verify the 3/4 oldest
301 {
302 auto l = q.get();
303 ASSERT_EQ(l.get_first(), cap/4 + i);
304 ASSERT_EQ(l.get_last(), cap/4 + i);
305 ASSERT_EQ(l.nth(1), 1);
306 ASSERT_EQ(l.nth(2), 2);
307 }
308
309 // now extract and verify the 1/4 remaining
310 for (size_t i = 0; i < cap/4; ++i)
311 {
312 auto l = q.get();
313 ASSERT_EQ(l.get_first(), i);
314 ASSERT_EQ(l.get_last(), i);
315 ASSERT_EQ(l.nth(1), 1);
316 ASSERT_EQ(l.nth(2), 2);
317 }
318}
319
320TEST(FixedQueue, Iterator_on_empty_queue)
321{
323 auto it = q.get_it();
324 ASSERT_FALSE(it.has_curr());
325 ASSERT_THROW(it.get_curr(), overflow_error);
326 ASSERT_THROW(it.next(), overflow_error);
327 ASSERT_THROW(it.prev(), underflow_error);
328}
329
330static size_t primes[] = {13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59,
331 61, 67, 71, 73, 79, 83, 89, 97, 197 };
332TEST(FixedQueue, Iterator)
333{
334 for (size_t i = 0, N = primes[i]; N < 100; ++i, N = primes[i])
335 //size_t N = 13;
336 {
338
339 for (size_t i = 0; i < N; ++i)
340 ASSERT_EQ(q.put(i), i);
341
342 int k = 0;
343 for (auto it = q.get_it(); it.has_curr(); it.next(), ++k)
344 ASSERT_EQ(it.get_curr(), k);
345 ASSERT_EQ(k, N); // test that queue has been traversed
346
347 // extract 1/4 of items
348 for (size_t i = 0; i < N/4; ++i)
349 ASSERT_EQ(q.get(), i);
350
351 ASSERT_FALSE(q.is_empty());
352
353 // Test iterator again
354 k = N/4;
355 for (auto it = q.get_it(); it.has_curr(); it.next(), ++k)
356 ASSERT_EQ(it.get_curr(), k);
357 ASSERT_EQ(k, N); // test that queue has been traversed
358
359 // now put again N/4 for testing iterator on queue of form xxx----xxxxxxx
360 for (size_t i = 0; i < N/4; ++i)
361 ASSERT_EQ(q.put(i), i);
362 ASSERT_EQ(q.size(), N);
363
364 // now test if iterator still works
365 k = 0;
366 for (auto it = q.get_it(); it.has_curr(); it.next(), ++k)
367 ASSERT_EQ(it.get_curr(), (k + N/4) % N);
368 ASSERT_EQ(k, N); // test that queue has been traversed
369
370 k = N - 1;
371 auto it = q.get_it();
372 it.reset_last();
373 for (; it.has_curr(); it.prev(), --k)
374 ASSERT_EQ(it.get_curr(), (k + N/4) % N);
375 ASSERT_EQ(k, -1); // test that queue has been traversed
376 }
377}
378
380{
381 for (size_t i = 0, N = primes[i]; N < 100; ++i, N = primes[i])
382 {
384
385 for (size_t i = 0; i < N; ++i)
386 ASSERT_EQ(q.put(i), i);
387
388 int k = 0;
389 auto ret = q.traverse([&k] (int i) { return i == k++; });
390 ASSERT_TRUE(ret);
391 ASSERT_EQ(k, N);
392
393 // extract 1/4 of items
394 for (size_t i = 0; i < N/4; ++i)
395 ASSERT_EQ(q.get(), i);
396
397 ASSERT_FALSE(q.is_empty());
398 assert(not q.is_empty());
399
400 // Test traverse
401 k = N/4;
402 ret = q.traverse([&k] (int i) { return i == k++; });
403 ASSERT_TRUE(ret);
404 ASSERT_EQ(k, N);
405
406 // now put again N/4 for testing iterator on queue of form xxx----xxxxxxx
407 for (size_t i = 0; i < N/4; ++i)
408 ASSERT_EQ(q.put(i), i);
409 ASSERT_EQ(q.size(), N);
410
411 // now test if iterator still works
412 k = 0;
413 ret = q.traverse([&k, N] (int i) { return i == (k++ + N/4) % N; });
414 ASSERT_TRUE(ret);
415 ASSERT_EQ(k, N);
416
417 // finally test partial traverse
418 k = 0;
419 ret = q.traverse([&k, n = N/4] (int) { return ++k < n; });
420 ASSERT_FALSE(ret);
421 ASSERT_EQ(k, N/4);
422 }
423}
424
425TEST(FixedQueue, front_reads_across_the_wrap_around)
426{
427 // Once the queue wraps around, front_index + i passes the end of the
428 // buffer: front(i) must apply the circular mask, as rear(i) does.
429 FixedQueue<int> q(8);
430 for (int k = 0; k < 6; ++k)
431 q.put(k);
432 for (int k = 0; k < 5; ++k)
433 (void) q.get();
434 for (int k = 6; k < 12; ++k)
435 q.put(k); // the items 5 ... 11 occupy slots 5, 6, 7, 0, 1, 2, 3
436
437 ASSERT_EQ(q.size(), 7u);
438 const FixedQueue<int> & cq = q;
439 for (size_t i = 0; i < q.size(); ++i)
440 {
441 EXPECT_EQ(q.front(i), static_cast<int>(5 + i));
442 EXPECT_EQ(cq.front(i), static_cast<int>(5 + i));
443 }
444 EXPECT_EQ(q.rear(), 11);
445}
446
447TEST(FixedQueue, copy_of_wrapped_and_full_queues)
448{
449 // The copy constructor walked from front_index to rear_index without
450 // wrapping: past the buffer for a queue that wraps around, and over no
451 // slot at all for a full queue, whose front_index equals its rear_index.
452 auto items = [] (const FixedQueue<int> & q)
453 {
454 std::vector<int> v;
455 q.for_each([&v] (int x) { v.push_back(x); });
456 return v;
457 };
458
459 FixedQueue<int> wrapped(8);
460 for (int k = 0; k < 6; ++k)
461 wrapped.put(k);
462 for (int k = 0; k < 5; ++k)
463 (void) wrapped.get();
464 for (int k = 6; k < 12; ++k)
465 wrapped.put(k); // 5 ... 11, around the end of the buffer
466 const FixedQueue<int> wrapped_copy(wrapped);
467 EXPECT_EQ(items(wrapped_copy), (std::vector<int>{5, 6, 7, 8, 9, 10, 11}));
468
469 FixedQueue<int> full(8);
470 for (int k = 0; k < 8; ++k)
471 full.put(k); // front_index == rear_index
472 const FixedQueue<int> full_copy(full);
473 EXPECT_EQ(items(full_copy), (std::vector<int>{0, 1, 2, 3, 4, 5, 6, 7}));
474
475 FixedQueue<int> full_wrapped(8);
476 for (int k = 0; k < 8; ++k)
477 full_wrapped.put(k);
478 for (int k = 0; k < 3; ++k)
479 (void) full_wrapped.get();
480 for (int k = 8; k < 11; ++k)
481 full_wrapped.put(k); // 3 ... 10: full and around the end
482 FixedQueue<int> copy(full_wrapped);
483 EXPECT_EQ(items(copy), (std::vector<int>{3, 4, 5, 6, 7, 8, 9, 10}));
484
485 // The copy keeps working as a queue.
486 EXPECT_EQ(copy.get(), 3);
487 copy.put(11);
488 EXPECT_EQ(items(copy), (std::vector<int>{4, 5, 6, 7, 8, 9, 10, 11}));
489 EXPECT_EQ(copy.front(), 4);
490 EXPECT_EQ(copy.rear(), 11);
491
492 // Copy assignment goes through the copy constructor.
493 FixedQueue<int> target(8);
494 target.put(100);
495 target = full_wrapped;
496 EXPECT_EQ(items(target), (std::vector<int>{3, 4, 5, 6, 7, 8, 9, 10}));
497
498 const FixedQueue<int> empty(8);
499 const FixedQueue<int> empty_copy(empty);
500 EXPECT_TRUE(empty_copy.is_empty());
501}
502
503TEST(FixedQueue, copy_operations)
504{
505 size_t N = 31;
506 {
508 for (size_t i = 0; i < N; ++i)
509 ASSERT_EQ(q.put(i), i);
510
511 {
512 FixedQueue<int> qc = q;
513 ASSERT_TRUE(eq(q, qc));
514 }
515
516 {
517 FixedQueue<int> qc = move(q);
518 ASSERT_TRUE(q.is_empty());
519 ASSERT_EQ(q.size(), 0);
520 int k = 0;
521 auto ret = qc.traverse([&k] (int i) { return i == k++; });
522 ASSERT_TRUE(ret);
523 ASSERT_EQ(k, qc.size());
524
525 q.swap(qc);
526 ASSERT_EQ(qc.size(), 0);
527 ASSERT_TRUE(qc.is_empty());
528 ASSERT_EQ(q.size(), N);
529 ASSERT_FALSE(q.is_empty());
530 }
531
533 qc = q;
534 ASSERT_TRUE(eq(q, qc));
535
536 qc.empty();
537 ASSERT_EQ(qc.size(), 0);
538 ASSERT_TRUE(qc.is_empty());
539
540 qc = move(q);
541 ASSERT_TRUE(q.is_empty());
542 ASSERT_EQ(q.size(), 0);
543 int k = 0;
544 auto ret = qc.traverse([&k] (int i) { return i == k++; });
545 ASSERT_TRUE(ret);
546 ASSERT_EQ(k, qc.size());
547 }
548}
549
550// The move built a queue of the default capacity, of 1024 items, for the
551// queue that it moved from, in a constructor that is noexcept: it could
552// not say that there was no memory for them. It takes the array now, and
553// the queue that it moved from has none, as a moved-from FixedStack
554TEST(FixedQueue, a_move_takes_the_array_and_leaves_a_queue_without_capacity)
555{
556 static_assert(std::is_nothrow_move_constructible_v<FixedQueue<int>>);
557
558 for (const size_t capacity : {size_t(1), size_t(8), size_t(1024), size_t(4096)})
559 {
560 FixedQueue<int> source(capacity);
561 for (size_t i = 0; i < capacity / 2; ++i) // so that the items wrap around
562 {
563 source.put(-1);
564 (void) source.get();
565 }
566 for (size_t i = 0; i < capacity; ++i)
567 source.put(static_cast<int>(i));
568 const int * const where = &source.front();
569
570 FixedQueue<int> target(std::move(source));
571
572 ASSERT_EQ(target.capacity(), capacity);
573 ASSERT_EQ(target.size(), capacity);
574 EXPECT_EQ(&target.front(), where); // the very array
575 for (size_t i = 0; i < capacity; ++i)
576 ASSERT_EQ(target.front(i), static_cast<int>(i));
577
578 // the queue that was moved from: empty and without capacity. It can
579 // be read, traversed, compared, copied and moved
580 EXPECT_EQ(source.capacity(), 0u);
581 EXPECT_EQ(source.size(), 0u);
582 EXPECT_TRUE(source.is_empty());
583 EXPECT_FALSE(source.get_it().has_curr());
584 size_t visited = 0;
585 EXPECT_TRUE(source.traverse([&visited] (int) { ++visited; return true; }));
586 EXPECT_EQ(visited, 0u);
587 FixedQueue<int> copy(source);
588 EXPECT_EQ(copy.capacity(), 0u);
589 EXPECT_TRUE(copy == source);
590 FixedQueue<int> again(std::move(source));
591 EXPECT_EQ(again.capacity(), 0u);
592 EXPECT_EQ(source.capacity(), 0u);
593
594 // and it takes items once it is assigned a queue
595 source = FixedQueue<int>(4);
596 source.put(1);
597 source.put(2);
598 EXPECT_EQ(source.capacity(), 4u);
599 EXPECT_EQ(source.get(), 1);
600 EXPECT_EQ(source.get(), 2);
601
602 source = std::move(target); // the move assignment swaps
603 ASSERT_EQ(source.size(), capacity);
604 EXPECT_EQ(target.capacity(), 4u);
605 int expected = 0;
606 for (auto it = source.get_it(); it.has_curr(); it.next_ne())
607 ASSERT_EQ(it.get_curr(), expected++);
608 }
609}
Functional programming utilities for Aleph-w containers.
T & put(const T &item)
Copy and put an item in the queue.
T & get_first()
Return the first item of the list.
Definition htlist.H:1548
T get()
See remove().
Definition htlist.H:1485
T & get_last()
Return the last item of the list.
Definition htlist.H:1529
T & put(const T &item)
See insert(const T & item).
Definition htlist.H:1341
Very simple queue implemented with a contiguous array.
T & put(const T &item) noexcept
Put an item into the queue by copy.
bool traverse(Operation &operation) noexcept(Aleph::NothrowPredicateWith< Operation &, T & >)
Traverse all the elements from the youngest to the oldest and execute operation on each on them.
constexpr bool is_empty() const noexcept
Return true if the queue is empty.
T get() noexcept
Remove the oldest item of the queue.
void swap(FixedQueue &q) noexcept
T & front(const size_t i=0) noexcept
Return the i-th oldest item.
void empty() noexcept
empty the queue
T & rear(const size_t i=0) noexcept
Return the i-th youngest item.
constexpr size_t size() const noexcept
Return the number of items.
constexpr size_t capacity() const noexcept
Return the queue capacity (maximum number of element to be stored)
Number Theoretic Transform over Z / MOD Z.
Definition ntt.H:115
Minimal std::expected-style result type for C++20.
void for_each(Operation &operation) const
Traverse all the container and performs an operation on each element.
Definition ah-dry.H:1475
Type & nth(const size_t n)
Return the n-th item of the container.
Definition ah-dry.H:774
auto get_it()
Return a properly initialized iterator positioned at the first item on the container.
Definition ah-dry.H:663
#define TEST(name)
TEST_F(SimpleQueue, put_and_get_stress)
static size_t primes[]
constexpr size_t N
Definition fixedqueue.cc:55
bool traverse(Node *root, Op op)
See infix_traverse().
Main namespace for Aleph-w library functions.
bool eq(const C1 &c1, const C2 &c2, Eq e=Eq())
Check equality of two containers using a predicate.
Itor2 copy(Itor1 sourceBeg, const Itor1 &sourceEnd, Itor2 destBeg)
Copy elements from one range to another.
Definition ahAlgo.H:584
std::pair< First, Second > pair
Alias to std::pair kept for backwards compatibility.
Definition ahPair.H:89
STL namespace.
FixedQueue< DynList< int > > q
Definition fixedqueue.cc:75
ArrayQueue< DynList< int > > q
Definition arrayqueue.cc:74
ArrayQueue< int > q
Definition arrayqueue.cc:59
void print() const
Definition fixedqueue.cc:66
FixedQueue< int > q
Definition fixedqueue.cc:60
static int * k
Circular queue implementations backed by arrays.
DynList< int > l