Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
testSnode.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 This program is free software: you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program. If not, see <https://www.gnu.org/licenses/>.
26*/
27
28# include <aleph.H>
29# include <tpl_snode.H>
30
31
32# define NumItems 10
33
34
35# include <iostream>
36
37using namespace std;
38
39int main()
40{
41 Snode<int> head;
42 unsigned i;
43 Snode<int> *node;
44 Snode<int> *aux;
45
46 for (i = 0; i < NumItems; i++)
47 {
48 node = new Snode<int> (i);
49 head.insert_next(node);
50 }
51
52 for (node = head.get_next(); node != &head; node = node->get_next())
53 {
54 cout << node->get_data() << " ";
55 }
56
57 while (not head.is_empty())
58 {
59 aux = head.remove_next();
60 delete aux;
61 }
62
63 printf("Ended\n");
64}
Core header for the Aleph-w library.
Singly linked node that stores data of type T.
Definition tpl_snode.H:66
T & get_data()
Return a modifiable reference to the stored data.
Definition tpl_snode.H:73
Snode *& get_next()
Return the next node after this.
Definition tpl_snode.H:91
Snode * remove_next()
Remove the node right after this and return it.
Definition tpl_snode.H:88
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
STL namespace.
#define NumItems
Definition testSnode.C:32
int main()
Definition testSnode.C:39
Typed singly linked node.