Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
testDynListQueue.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# include <ctime>
33# include <cstdlib>
34# include <cassert>
35
36# include <iostream>
37# include <string>
38# include <aleph.H>
39# include <tpl_dynListQueue.H>
40
41using namespace std;
42
43using namespace Aleph;
44
45# define NumItems 1000
46
47int main(int argc, char *argv[])
48{
49 int n = NumItems;
50 if (argc > 1)
51 {
52 try
53 {
54 n = stoi(argv[1]);
55 }
56 catch (...)
57 {
58 n = NumItems;
59 }
60 }
61
62 if (n <= 0)
63 {
64 cerr << "Error: n must be a positive integer." << endl;
65 return 1;
66 }
67
68 unsigned int t = std::time(0);
69
70 if (argc > 2)
71 {
72 try
73 {
74 t = stoi(argv[2]);
75 }
76 catch (...)
77 {
78 t = std::time(0);
79 }
80 }
81
82 srand(t);
83
84 cout << argv[0] << " " << n << " " << t << endl;
85
87
88 for (int i = 0; i < n; i++)
89 {
90 q.put(i);
91 cout << q.rear() << " ";
92 }
93
94 cout << endl;
95
96 while (not q.is_empty())
97 {
98 cout << q.front() << " ";
99 q.get();
100 }
101
102 cout << endl;
103}
Core header for the Aleph-w library.
int main()
Dynamic queue of elements of generic type T based on single linked list.
T & put(const T &data)
The type of element.
T get()
Remove the oldest item of the queue.
T & front()
Return a modifiable reference to the oldest item in the queue.
T & rear()
Return a modifiable reference to the youngest item in the queue.
bool is_empty() const noexcept
Return true if this is empty.
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
Main namespace for Aleph-w library functions.
Definition ah-arena.H:89
STL namespace.
#define NumItems
Dynamic queue implementation based on linked lists.