Source File
stack.go
Belonging Package
github.com/jackc/puddle/v2/internal/genstack
package genstack// stack is a wrapper around an array implementing a stack.//// We cannot use slice to represent the stack because append might change the// pointer value of the slice. That would be an issue in GenStack// implementation.type stack[ any] struct {arr []}// push pushes a new element at the top of a stack.func ( *stack[]) ( ...) { .arr = append(.arr, ...) }// pop pops the stack top-most element.//// If stack length is zero, this method panics.func ( *stack[]) () {:= .len() - 1:= .arr[]// Avoid memory leakvar.arr[] =.arr = .arr[:]return}// takeAll returns all elements in the stack in order as they are stored - i.e.// the top-most stack element is the last one.func ( *stack[]) () [] {:= .arr.arr = nilreturn}// len returns number of elements in the stack.func ( *stack[]) () int { return len(.arr) }
The pages are generated with Golds v0.7.6. (GOOS=linux GOARCH=amd64)