-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.go
55 lines (42 loc) · 908 Bytes
/
example.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
52
53
54
55
/*
* @Name: One Way Linked List Go
* @Author: Max Base
* @Date: 2022-11-14
* @Repository: https://github.com/basemax/OneWayLinkedListGo
*/
package main
import "fmt"
// Main
func main() {
// Create a list
list := List{}
list.Create(1)
// Insert some values at begin
list.InsertBegin(2)
list.InsertBegin(3)
list.InsertBegin(4)
// Insert some values at end
list.InsertEnd(5)
list.InsertEnd(6)
list.InsertEnd(7)
// Insert some values after
list.InsertAfter(8, 5)
list.InsertAfter(9, 6)
list.InsertAfter(10, 7)
// Search in the list
fmt.Println(list.Search(3))
// Print the list
list.Print()
// Re-create a list
list.Create(100)
// Print the list
list.Print()
// Search in the list
fmt.Println(list.Search(3))
// Delete from the list
list.Delete()
list.Delete()
list.Delete()
// Print the list
list.Print()
}