-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtreesort.cc
More file actions
41 lines (30 loc) · 707 Bytes
/
Copy pathtreesort.cc
File metadata and controls
41 lines (30 loc) · 707 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <cstdlib>
#include <iostream>
#include <unistd.h>
#include <lace/haystack.h>
#include "tree.h"
struct node {
int value;
node(int v) : value(v) { }
lite::tree_link<node> tree_link;
typedef lite::tree<node, &node::tree_link, typeof(node::value), &node::value> tree_t;
};
int
main(int, char*[]) {
lace::haystack h;
node::tree_t tree;
h.alignment_mask() = alignof(node) - 1;
while (std::cin) {
int i;
if ((std::cin >> i).good())
tree.graft(new (h.allocate<node>()) node(i));
}
if (!tree.empty())
for (node* i = tree.min() ; i ; i = tree.next(i))
std::cout << i->value << std::endl;
#ifndef NDEBUG
tree.fell();
#endif
return EXIT_SUCCESS;
}
//