MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / Peek

Method Peek

structure/stack/stacklinkedlistwithlist.go:28–34  ·  view source on GitHub ↗

Peak is return last value that insert into our stack

()

Source from the content-addressed store, hash-verified

26
27// Peak is return last value that insert into our stack
28func (sl *SList) Peek() (any, error) {
29 if !sl.IsEmpty() {
30 element := sl.Stack.Front()
31 return element.Value, nil
32 }
33 return "", fmt.Errorf("stack list is empty")
34}
35
36// Pop is return last value that insert into our stack
37// also it will remove it in our stack

Callers 1

Calls 2

IsEmptyMethod · 0.95
FrontMethod · 0.45

Tested by 1