Initial project import
This commit is contained in:
commit
23f2d29e32
11957 files changed
+1754577
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import datatypes
|
||||
|
||||
struct KeyVal {
|
||||
mut:
|
||||
key int
|
||||
val int
|
||||
}
|
||||
|
||||
fn (a KeyVal) == (b KeyVal) bool {
|
||||
return a.key == b.key
|
||||
}
|
||||
|
||||
fn (a KeyVal) < (b KeyVal) bool {
|
||||
return a.key < b.key
|
||||
}
|
||||
|
||||
fn main() {
|
||||
mut bst := datatypes.BSTree[KeyVal]{}
|
||||
bst.insert(KeyVal{ key: 1, val: 12 })
|
||||
println(bst.in_order_traversal())
|
||||
|
||||
bst.insert(KeyVal{ key: 2, val: 34 })
|
||||
bst.insert(KeyVal{ key: -2, val: 203 })
|
||||
|
||||
for elem in bst.in_order_traversal() {
|
||||
println(elem.val)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user