DelAtBeg deletes the snode at the head(beginning) of the list and returns its value. Returns false if the list is empty.
()
| 48 | // DelAtBeg deletes the snode at the head(beginning) of the list |
| 49 | // and returns its value. Returns false if the list is empty. |
| 50 | func (ll *Singly[T]) DelAtBeg() (T, bool) { |
| 51 | if ll.Head == nil { |
| 52 | var r T |
| 53 | return r, false |
| 54 | } |
| 55 | |
| 56 | cur := ll.Head |
| 57 | ll.Head = cur.Next |
| 58 | ll.length-- |
| 59 | |
| 60 | return cur.Val, true |
| 61 | } |
| 62 | |
| 63 | // DelAtEnd deletes the snode at the tail(end) of the list |
| 64 | // and returns its value. Returns false if the list is empty. |