Reverse reverses the list.
()
| 125 | |
| 126 | // Reverse reverses the list. |
| 127 | func (ll *Singly[T]) Reverse() { |
| 128 | var prev, next *Node[T] |
| 129 | cur := ll.Head |
| 130 | |
| 131 | for cur != nil { |
| 132 | next = cur.Next |
| 133 | cur.Next = prev |
| 134 | prev = cur |
| 135 | cur = next |
| 136 | } |
| 137 | |
| 138 | ll.Head = prev |
| 139 | } |
| 140 | |
| 141 | // ReversePartition Reverse the linked list from the ath to the bth node |
| 142 | func (ll *Singly[T]) ReversePartition(left, right int) error { |
nothing calls this directly
no outgoing calls
no test coverage detected