| 3 | import "fmt" |
| 4 | |
| 5 | func ExampleNode() { |
| 6 | // creates a new node |
| 7 | node := NewNode() |
| 8 | |
| 9 | // adds words |
| 10 | node.Insert("nikola") |
| 11 | node.Insert("tesla") |
| 12 | |
| 13 | // check size and capacity |
| 14 | fmt.Println(node.Size()) // 2 words |
| 15 | fmt.Println(node.Capacity()) // 12 nodes |
| 16 | |
| 17 | // finds words |
| 18 | fmt.Println(node.Find("thomas")) // false |
| 19 | fmt.Println(node.Find("edison")) // false |
| 20 | fmt.Println(node.Find("nikola")) // true |
| 21 | |
| 22 | // remove a word, and check it is gone |
| 23 | node.Remove("tesla") |
| 24 | fmt.Println(node.Find("tesla")) // false |
| 25 | |
| 26 | // size and capacity have changed |
| 27 | fmt.Println(node.Size()) // 1 word left |
| 28 | fmt.Println(node.Capacity()) // 12 nodes remaining |
| 29 | |
| 30 | // output: |
| 31 | // 2 |
| 32 | // 12 |
| 33 | // false |
| 34 | // false |
| 35 | // true |
| 36 | // false |
| 37 | // 1 |
| 38 | // 12 |
| 39 | } |