Documentation
¶
Overview ¶
Package stack implements a LIFO (last in first out) data structure supporting arbitrary types (even a mixture).
Internally it uses a dynamically growing slice of blocks, resulting in faster resizes than a simple dynamic array/slice would allow.
Example (Usage) ¶
Simple usage example that inserts the numbers 1, 2, 3 into a stack and then removes them one by one, printing them to the standard output.
package main import ( "fmt" "gopkg.in/karalabe/cookiejar.v1/collections/stack" ) func main() { // Create a stack and push some data in s := stack.New() for i := 0; i < 3; i++ { s.Push(i) } // Pop out the stack contents and display them for !s.Empty() { fmt.Println(s.Pop()) } }
Output: 2 1 0
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Last in, first out data structure.
func (*Stack) Pop ¶
func (s *Stack) Pop() (res interface{})
Pops a value off the stack and returns it. Currently no shrinking is done.
Click to show internal directories.
Click to hide internal directories.