-
Notifications
You must be signed in to change notification settings - Fork 0
/
linkedlist.go
55 lines (45 loc) · 1.13 KB
/
linkedlist.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
package textanalysis
type (
LinkedList interface {
// First returns the 'first' element of the list.
First() Node
// Last returns the 'last' element of the list.
Last() Node
// Next returns the 'next' element of the list.
// If there is no 'current' element, it returns
// First()
//
// If Next() == nil, it returns First() if 'cyclical'
// is true.
Next() Node
// Previous returns the 'previous' element of the list.
Prev() Node
// Cyclical returns true if the list is cyclical.
Cyclical() bool
}
// LinkedList is a linked list of nodes. These nodes
// may have additional properties and functionality
// by using graph and edge information.
linkedList struct {
first Node
last Node
current Node
cyclical bool
}
ListItem interface {
Node
Next() Node
Prev() Node
}
listItem struct {
node // Base struct
// a linked list funcionality is handy for bulk
// processing. Graph.nodes may also work fine.
//
// The *Nodes next and previous are not required
// and the default values are nil unless linked lists
// are activated as an option.
next Node
previous Node
}
)