-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.nim
89 lines (74 loc) · 1.49 KB
/
test.nim
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import tree
var
datom1 : Datom
datom2 : Datom
datom3 : Datom
datom4 : Datom
datom5 : Datom
datom6 : Datom
datom1 = createStringDatom(3, 2, "abs")
datom2 = createIntDatom(1, 2, 23)
datom3 = createIntDatom(1, 2, 12)
datom4 = createStringDatom(1, 3, "sds")
datom5 = createFloatDatom(2, 4, 2.3)
var treap : Treap = createTreap(@[Entity, Attribute, Value])
treap.add(datom1);
treap.add(datom2);
treap.add(datom3);
treap.add(datom4);
treap.add(datom5);
treap.print()
echo "--------"
var it : TreapIter = treap.createTreapIter()
it.open()
echo key(it)
it.next()
echo key(it)
it.next()
echo key(it)
it.next()
echo key(it)
echo "======="
it = treap.createTreapIter()
it.open()
it.open()
echo key(it)
it.next()
echo key(it)
it.next()
echo key(it)
it.up()
it.next()
echo key(it)
echo "!!!!!!!!!!!!!!!!!!!"
var r : Treap = createTreap(@[Entity, Value, Attribute])
r.add(createStringDatom(3, 42, "hey"))
r.add(createStringDatom(1, 55, "there"))
r.add(createStringDatom(1, 77, "there"))
r.add(createStringDatom(0, 55, "x"))
r.add(createStringDatom(1, 88, "a"))
r.add(createStringDatom(7, 42, "fuckit"))
r.add(createStringDatom(7, 11, "aargh"))
r.print()
echo "--------"
var iter : TreapIter = r.createTreapIter()
iter.open()
while not iter.atEnd:
echo key(iter)
#
iter.open()
while not iter.atEnd:
echo " - ", key(iter)
#
iter.open()
while not iter.atEnd:
echo " -- ", key(iter)
#
#
iter.next()
iter.up()
#
iter.next()
iter.up()
iter.next()
iter.up()