| 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 stacks |
| 11 | |
| 12 | import "github.com/emirpasic/gods/v2/containers" |
| 13 | |
| 14 | // Stack interface that all stacks implement |
| 15 | type Stack[T any] interface { |
| 16 | Push(value T) |
| 17 | Pop() (value T, ok bool) |
| 18 | Peek() (value T, ok bool) |
| 19 | |
| 20 | containers.Container[T] |
| 21 | // Empty() bool |
| 22 | // Size() int |
| 23 | // Clear() |
| 24 | // Values() []interface{} |
| 25 | // String() string |
| 26 | } |