MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / DelAtBeg

Method DelAtBeg

structure/linkedlist/singlylinkedlist.go:50–61  ·  view source on GitHub ↗

DelAtBeg deletes the snode at the head(beginning) of the list and returns its value. Returns false if the list is empty.

()

Source from the content-addressed store, hash-verified

48// DelAtBeg deletes the snode at the head(beginning) of the list
49// and returns its value. Returns false if the list is empty.
50func (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.

Callers 2

DelAtEndMethod · 0.95
DelByPosMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected