github.com/mymmsc/gox@v1.3.33/util/stacks.go (about)

     1  // Copyright (c) 2015, Emir Pasic. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Package stacks provides an abstract Stack interface.
     6  //
     7  // In computer science, a stack is an abstract data type that serves as a collection of elements, with two principal operations: push, which adds an element to the collection, and pop, which removes the most recently added element that was not yet removed. The order in which elements come off a stack gives rise to its alternative name, LIFO (for last in, first out). Additionally, a peek operation may give access to the top without modifying the stack.
     8  //
     9  // Reference: https://en.wikipedia.org/wiki/Stack_%28abstract_data_type%29
    10  package util
    11  
    12  // Stack interface that all stacks implement
    13  type Stack interface {
    14  	Push(value interface{})
    15  	Pop() (value interface{}, ok bool)
    16  	Peek() (value interface{}, ok bool)
    17  
    18  	Container
    19  	// Empty() bool
    20  	// Size() int
    21  	// Clear()
    22  	// Values() []interface{}
    23  }