Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
testArrayQueue.C
Go to the documentation of this file.
1
2/* Aleph-w
3
4 / \ | | ___ _ __ | |__ __ __
5 / _ \ | |/ _ \ '_ \| '_ \ ____\ \ /\ / / Data structures & Algorithms
6 / ___ \| | __/ |_) | | | |_____\ V V / version 1.9c
7 /_/ \_\_|\___| .__/|_| |_| \_/\_/ https://github.com/lrleon/Aleph-w
8 |_|
9
10 This file is part of Aleph-w library
11
12 Copyright (c) 2002-2018 Leandro Rabindranath Leon
13
14 Permission is hereby granted, free of charge, to any person obtaining a copy
15 of this software and associated documentation files (the "Software"), to deal
16 in the Software without restriction, including without limitation the rights
17 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 copies of the Software, and to permit persons to whom the Software is
19 furnished to do so, subject to the following conditions:
20
21 The above copyright notice and this permission notice shall be included in all
22 copies or substantial portions of the Software.
23
24 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 SOFTWARE.
31*/
32
33# include <iostream>
34# include <tpl_arrayQueue.H>
35
36# define NumItems 10
37
38using namespace std;
39
40int main()
41{
43 unsigned i;
44
45 for (i = 0; i < NumItems; i++)
46 {
47 q.putn(1);
48 q.rear() = i;
49 printf("%u ", i);
50 }
51
52 cout << endl
53 << "queue = ";
54 q.for_each([] (unsigned i) { cout << " " << i; });
55 cout << endl;
56
57 cout << "rear de 0: " << q.rear() << endl
58 << "rear de 1: " << q.rear(1) << endl
59 << "rear de 2: " << q.rear(2)<< endl
60 << "rear de 3: " << q.rear(3)<< endl
61 << "la cola deberia ser: " << endl;
62 while (not q.is_empty())
63 cout << q.get() << " ";
64
65 cout << endl;
66}
Very simple queue implemented with a contiguous array.
constexpr bool is_empty() const noexcept
Return true if the queue is empty.
T get() noexcept
Remove the oldest item of the queue.
T & putn(const size_t n) noexcept
Put n cells to the queue in constant time.
T & rear(const size_t i=0) const noexcept
Return the i-th youngest item.
void for_each(Operation &operation)
Traverse all the container and performs an operation on each element.
Definition ah-dry.H:796
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Definition Blossom.H:466
STL namespace.
#define NumItems
int main()
Circular queue implementations backed by arrays.