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

Method Rear

structure/deque/deque.go:68–74  ·  view source on GitHub ↗

Rear gets the last item from queue.

()

Source from the content-addressed store, hash-verified

66
67// Rear gets the last item from queue.
68func (dq *DoublyEndedQueue[T]) Rear() (T, error) {
69 if (len(dq.deque)) == 0 {
70 var zeroVal T
71 return zeroVal, ErrEmptyDequeue
72 }
73 return dq.deque[len(dq.deque)-1], nil
74}
75
76// IsEmpty checks whether Deque is empty or not.
77func (dq *DoublyEndedQueue[T]) IsEmpty() bool {

Callers 1

TestDequeFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestDequeFunction · 0.64