-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
51 lines (41 loc) · 800 Bytes
/
main.go
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
package main
import (
"algorythms-golang/pkg/adt/hash"
"algorythms-golang/pkg/adt/list"
"fmt"
)
func main() {
ht := hash.NewHashTable()
data := map[int]int{}
for i := 0; i < 1000; i++ {
data[i] = i
}
for k, v := range data {
ht.Put(k, v)
fmt.Println(ht.ToString())
}
fmt.Println(ht.Get(100))
return
list := list.NewLinkedList()
list.PushBack(1)
list.PushBack(2)
fmt.Printf("%+v\n", list)
value, err := list.PopBack()
if err != nil {
fmt.Println("got error popping value")
}
if value != 2 {
fmt.Println("wrong value popped")
}
value, err = list.PopBack()
if err != nil {
fmt.Println("got error popping value")
}
if value != 1 {
fmt.Println("wrong value popped")
}
_, err = list.PopBack()
if err == nil {
fmt.Println("expected error, got nil")
}
}