Documentation
¶
Index ¶
- type IStack
- type SafeStack
- func (s *SafeStack[T]) Clear()
- func (s *SafeStack[T]) IsEmpty() bool
- func (s *SafeStack[T]) Len() int
- func (s *SafeStack[T]) Peek() (T, bool)
- func (s *SafeStack[T]) Pop() (T, bool)
- func (s *SafeStack[T]) Push(value ...T)
- func (s *SafeStack[T]) PushSequence(seq iter.Seq[T])
- func (s *SafeStack[T]) Values() iter.Seq[T]
- type Stack
- func (s *Stack[T]) Clear()
- func (s *Stack[T]) IsEmpty() bool
- func (s *Stack[T]) Len() int
- func (s *Stack[T]) Peek() (element T, ok bool)
- func (s *Stack[T]) Pop() (element T, ok bool)
- func (s *Stack[T]) Push(value ...T)
- func (s *Stack[T]) PushSequence(seq iter.Seq[T])
- func (s *Stack[T]) Values() iter.Seq[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IStack ¶
type IStack[T any] interface { // Push adds elements to the stack. Push(value ...T) // PushSequence adds elements to the stack. PushSequence(seq iter.Seq[T]) // Pop removes and returns an element from the stack. Returns ok true if the stack is not empty. Pop() (element T, ok bool) // Peek returns the element at the top of the stack without removing it. Peek() (element T, ok bool) // IsEmpty states whether the stack is empty. Returns ok true if the stack is not empty. IsEmpty() bool // Clear clears all elements from the stack. Clear() // Values returns all the elements in the stack. The stack will be empty as a result. Values() iter.Seq[T] // Len returns the number of elements in the stack. Len() int }
IStack specifies the behaviour of a last-in, first-out (LIFO) collection. it is inspired by the work of https://github.com/hayageek/threadsafe/ and https://github.com/golang-collections/collections
func NewThreadSafeStack ¶
NewThreadSafeStack returns a thread safe stack This is inspired from https://github.com/hayageek/threadsafe
type SafeStack ¶
type SafeStack[T any] struct { // contains filtered or unexported fields }
func (*SafeStack[T]) PushSequence ¶
Click to show internal directories.
Click to hide internal directories.