@@ -6,20 +6,15 @@ package listext
66// Node is an element of the doubly linked list.
77type Node [V any ] struct {
88 next , prev * Node [V ]
9- value V
9+ Value V
1010}
1111
12- // Value returns the underlying nodes value.
13- func (n * Node [V ]) Value () V {
14- return n .value
15- }
16-
17- // Next returns the nodes next value or nil if it is at the tail.
12+ // Next returns the nodes next Value or nil if it is at the tail.
1813func (n * Node [V ]) Next () * Node [V ] {
1914 return n .next
2015}
2116
22- // Prev returns the nodes previous value or nil if it is at the head.
17+ // Prev returns the nodes previous Value or nil if it is at the head.
2318func (n * Node [V ]) Prev () * Node [V ] {
2419 return n .prev
2520}
@@ -38,7 +33,7 @@ func NewDoublyLinked[V any]() *DoublyLinkedList[V] {
3833// PushFront adds an element first in the list.
3934func (d * DoublyLinkedList [V ]) PushFront (v V ) * Node [V ] {
4035 node := & Node [V ]{
41- value : v ,
36+ Value : v ,
4237 }
4338 d .pushFront (node )
4439 return d .head
@@ -79,7 +74,7 @@ func (d *DoublyLinkedList[V]) PopFront() *Node[V] {
7974// PushBack appends an element to the back of a list.
8075func (d * DoublyLinkedList [V ]) PushBack (v V ) * Node [V ] {
8176 node := & Node [V ]{
82- value : v ,
77+ Value : v ,
8378 }
8479 d .pushBack (node )
8580 return d .tail
@@ -98,12 +93,12 @@ func (d *DoublyLinkedList[V]) pushBack(node *Node[V]) {
9893 d .len ++
9994}
10095
101- // PushAfter pushes the supplied value after the supplied node.
96+ // PushAfter pushes the supplied Value after the supplied node.
10297//
10398// The supplied node must be attached to the current list otherwise undefined behaviour could occur.
10499func (d * DoublyLinkedList [V ]) PushAfter (node * Node [V ], v V ) * Node [V ] {
105100 newNode := & Node [V ]{
106- value : v ,
101+ Value : v ,
107102 }
108103 d .MoveAfter (node , newNode )
109104 return newNode
@@ -130,12 +125,12 @@ func (d *DoublyLinkedList[V]) MoveAfter(node *Node[V], moving *Node[V]) {
130125 }
131126}
132127
133- // PushBefore pushes the supplied value before the supplied node.
128+ // PushBefore pushes the supplied Value before the supplied node.
134129//
135130// The supplied node must be attached to the current list otherwise undefined behaviour could occur.
136131func (d * DoublyLinkedList [V ]) PushBefore (node * Node [V ], v V ) * Node [V ] {
137132 newNode := & Node [V ]{
138- value : v ,
133+ Value : v ,
139134 }
140135 d .MoveBefore (node , newNode )
141136 return newNode
0 commit comments