PeekDepth returns the n-th value from the top. PeekDepth(0) is equivalent to the standard Peek().
(depth int)
| 39 | |
| 40 | // PeekDepth returns the n-th value from the top. PeekDepth(0) is equivalent to the standard Peek(). |
| 41 | func (s *Stack[T]) PeekDepth(depth int) (value T) { |
| 42 | if len(s.values) <= depth { |
| 43 | return |
| 44 | } |
| 45 | return s.values[len(s.values)-(1+depth)] |
| 46 | } |
| 47 | |
| 48 | // PeekReference returns a reference to the top value on the stack without removing it. |
| 49 | func (s *Stack[T]) PeekReference() *T { |
no outgoing calls
no test coverage detected