Documentation ¶
Index ¶
- type ArrayStack
- func (stack *ArrayStack[T]) Capacity() int
- func (stack *ArrayStack[T]) Clear()
- func (stack *ArrayStack[T]) Copy() itff.Copier
- func (stack *ArrayStack[T]) CutNilValues()
- func (stack *ArrayStack[T]) IsEmpty() bool
- func (stack *ArrayStack[T]) IsFull() bool
- func (stack *ArrayStack[T]) Iterator() itf.Iterater[T]
- func (stack *ArrayStack[T]) Peek() T
- func (stack *ArrayStack[T]) Pop() T
- func (stack *ArrayStack[T]) Push(value T)
- func (stack *ArrayStack[T]) Size() int
- func (stack *ArrayStack[T]) Slice() []T
- func (stack *ArrayStack[T]) String() string
- type LimitedArrayStack
- func (stack *LimitedArrayStack[T]) Capacity() int
- func (stack *LimitedArrayStack[T]) Clear()
- func (stack *LimitedArrayStack[T]) Copy() itff.Copier
- func (stack *LimitedArrayStack[T]) CutNilValues()
- func (stack *LimitedArrayStack[T]) IsEmpty() bool
- func (stack *LimitedArrayStack[T]) IsFull() (isFull bool)
- func (stack *LimitedArrayStack[T]) Iterator() itf.Iterater[T]
- func (stack *LimitedArrayStack[T]) Peek() T
- func (stack *LimitedArrayStack[T]) Pop() T
- func (stack *LimitedArrayStack[T]) Push(value T)
- func (stack *LimitedArrayStack[T]) Size() int
- func (stack *LimitedArrayStack[T]) Slice() []T
- func (stack *LimitedArrayStack[T]) String() string
- type LimitedLinkedStack
- func (stack *LimitedLinkedStack[T]) Capacity() int
- func (stack *LimitedLinkedStack[T]) Clear()
- func (stack *LimitedLinkedStack[T]) Copy() itff.Copier
- func (stack *LimitedLinkedStack[T]) CutNilValues()
- func (stack *LimitedLinkedStack[T]) IsEmpty() bool
- func (stack *LimitedLinkedStack[T]) IsFull() bool
- func (stack *LimitedLinkedStack[T]) Iterator() itf.Iterater[T]
- func (stack *LimitedLinkedStack[T]) Peek() T
- func (stack *LimitedLinkedStack[T]) Pop() T
- func (stack *LimitedLinkedStack[T]) Push(value T)
- func (stack *LimitedLinkedStack[T]) Size() int
- func (stack *LimitedLinkedStack[T]) Slice() []T
- func (stack *LimitedLinkedStack[T]) String() string
- type LinkedStack
- func (stack *LinkedStack[T]) Capacity() int
- func (stack *LinkedStack[T]) Clear()
- func (stack *LinkedStack[T]) Copy() itff.Copier
- func (stack *LinkedStack[T]) CutNilValues()
- func (stack *LinkedStack[T]) IsEmpty() bool
- func (stack *LinkedStack[T]) IsFull() bool
- func (stack *LinkedStack[T]) Iterator() itf.Iterater[T]
- func (stack *LinkedStack[T]) Peek() T
- func (stack *LinkedStack[T]) Pop() T
- func (stack *LinkedStack[T]) Push(value T)
- func (stack *LinkedStack[T]) Size() int
- func (stack *LinkedStack[T]) Slice() []T
- func (stack *LinkedStack[T]) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrayStack ¶
type ArrayStack[T any] struct { // contains filtered or unexported fields }
ArrayStack is a generic type that represents a stack data structure with or without a limited capacity. It is implemented using an array.
func NewArrayStack ¶
func NewArrayStack[T any](values ...T) *ArrayStack[T]
NewArrayStack is a function that creates and returns a new instance of a ArrayStack.
Parameters:
- values: A variadic parameter of type T, which represents the initial values to be stored in the stack.
Returns:
- *ArrayStack[T]: A pointer to the newly created ArrayStack.
func (*ArrayStack[T]) Capacity ¶ added in v0.2.28
func (stack *ArrayStack[T]) Capacity() int
func (*ArrayStack[T]) Clear ¶
func (stack *ArrayStack[T]) Clear()
Clear is a method of the ArrayStack type. It is used to remove aCommon elements from the stack, making it empty.
func (*ArrayStack[T]) Copy ¶
func (stack *ArrayStack[T]) Copy() itff.Copier
Copy is a method of the ArrayStack type. It is used to create a shaCommonow copy of the stack.
Returns:
- itf.Copier: A copy of the stack.
func (*ArrayStack[T]) CutNilValues ¶
func (stack *ArrayStack[T]) CutNilValues()
CutNilValues is a method of the ArrayStack type. It is used to remove aCommon nil values from the stack.
func (*ArrayStack[T]) IsEmpty ¶
func (stack *ArrayStack[T]) IsEmpty() bool
IsEmpty is a method of the ArrayStack type. It is used to check if the stack is empty.
Returns:
- bool: A boolean value that is true if the stack is empty, and false otherwise.
func (*ArrayStack[T]) IsFull ¶ added in v0.2.28
func (stack *ArrayStack[T]) IsFull() bool
func (*ArrayStack[T]) Iterator ¶
func (stack *ArrayStack[T]) Iterator() itf.Iterater[T]
Iterator is a method of the ArrayStack type. It is used to return an iterator that iterates over the elements in the stack.
Returns:
- itf.Iterater[T]: An iterator that iterates over the elements in the stack.
func (*ArrayStack[T]) Peek ¶
func (stack *ArrayStack[T]) Peek() T
Peek is a method of the ArrayStack type. It is used to return the element at the end of the stack without removing it.
Panics with an error of type *Common.ErrEmptyList if the stack is empty.
Returns:
- T: The element at the end of the stack.
func (*ArrayStack[T]) Pop ¶
func (stack *ArrayStack[T]) Pop() T
Pop is a method of the ArrayStack type. It is used to remove and return the element at the end of the stack.
Panics with an error of type *Common.ErrEmptyList if the stack is empty.
Returns:
- T: The element at the end of the stack.
func (*ArrayStack[T]) Push ¶
func (stack *ArrayStack[T]) Push(value T)
Push is a method of the ArrayStack type. It is used to add an element to the end of the stack.
Panics with an error of type *ErrCaCommonFailed if the stack is fuCommon.
Parameters:
- value: The value of type T to be added to the stack.
func (*ArrayStack[T]) Size ¶
func (stack *ArrayStack[T]) Size() int
Size is a method of the ArrayStack type. It is used to return the number of elements in the stack.
Returns:
- int: An integer that represents the number of elements in the stack.
func (*ArrayStack[T]) Slice ¶
func (stack *ArrayStack[T]) Slice() []T
Slice is a method of the ArrayStack type. It is used to return a slice of the elements in the stack.
Returns:
- []T: A slice of the elements in the stack.
func (*ArrayStack[T]) String ¶
func (stack *ArrayStack[T]) String() string
String is a method of the ArrayStack type. It is used to return a string representation of the stack, including its capacity and the elements it contains.
Returns:
- string: A string representation of the stack.
type LimitedArrayStack ¶ added in v0.2.28
type LimitedArrayStack[T any] struct { // contains filtered or unexported fields }
LimitedArrayStack is a generic type that represents a stack data structure with or without a limited capacity. It is implemented using an array.
func NewLimitedArrayStack ¶ added in v0.2.28
func NewLimitedArrayStack[T any](values ...T) *LimitedArrayStack[T]
NewLimitedArrayStack is a function that creates and returns a new instance of a LimitedArrayStack.
Parameters:
- values: A variadic parameter of type T, which represents the initial values to be stored in the stack.
Returns:
- *LimitedArrayStack[T]: A pointer to the newly created LimitedArrayStack.
func (*LimitedArrayStack[T]) Capacity ¶ added in v0.2.28
func (stack *LimitedArrayStack[T]) Capacity() int
Capacity is a method of the LimitedArrayStack type. It is used to return the maximum number of elements the stack can hold.
Returns:
- optional.Int: An optional integer that represents the maximum number of elements the stack can hold.
func (*LimitedArrayStack[T]) Clear ¶ added in v0.2.28
func (stack *LimitedArrayStack[T]) Clear()
Clear is a method of the LimitedArrayStack type. It is used to remove all elements from the stack, making it empty.
func (*LimitedArrayStack[T]) Copy ¶ added in v0.2.28
func (stack *LimitedArrayStack[T]) Copy() itff.Copier
Copy is a method of the LimitedArrayStack type. It is used to create a shallow copy of the stack.
Returns:
- itf.Copier: A copy of the stack.
func (*LimitedArrayStack[T]) CutNilValues ¶ added in v0.2.28
func (stack *LimitedArrayStack[T]) CutNilValues()
CutNilValues is a method of the LimitedArrayStack type. It is used to remove all nil values from the stack.
func (*LimitedArrayStack[T]) IsEmpty ¶ added in v0.2.28
func (stack *LimitedArrayStack[T]) IsEmpty() bool
IsEmpty is a method of the LimitedArrayStack type. It is used to check if the stack is empty.
Returns:
- bool: A boolean value that is true if the stack is empty, and false otherwise.
func (*LimitedArrayStack[T]) IsFull ¶ added in v0.2.28
func (stack *LimitedArrayStack[T]) IsFull() (isFull bool)
IsFull is a method of the LimitedArrayStack type. It is used to check if the stack is full, i.e., if it has reached its maximum capacity.
Returns:
- isFull: A boolean value that is true if the stack is full, and false otherwise.
func (*LimitedArrayStack[T]) Iterator ¶ added in v0.2.28
func (stack *LimitedArrayStack[T]) Iterator() itf.Iterater[T]
Iterator is a method of the LimitedArrayStack type. It is used to return an iterator that iterates over the elements in the stack.
Returns:
- itf.Iterater[T]: An iterator that iterates over the elements in the stack.
func (*LimitedArrayStack[T]) Peek ¶ added in v0.2.28
func (stack *LimitedArrayStack[T]) Peek() T
Peek is a method of the LimitedArrayStack type. It is used to return the element at the end of the stack without removing it.
Panics with an error of type *ErrCallFailed if the stack is empty.
Returns:
- T: The element at the end of the stack.
func (*LimitedArrayStack[T]) Pop ¶ added in v0.2.28
func (stack *LimitedArrayStack[T]) Pop() T
Pop is a method of the LimitedArrayStack type. It is used to remove and return the element at the end of the stack.
Panics with an error of type *ErrCallFailed if the stack is empty.
Returns:
- T: The element at the end of the stack.
func (*LimitedArrayStack[T]) Push ¶ added in v0.2.28
func (stack *LimitedArrayStack[T]) Push(value T)
Push is a method of the LimitedArrayStack type. It is used to add an element to the end of the stack.
Panics with an error of type *ErrCallFailed if the stack is full.
Parameters:
- value: The value of type T to be added to the stack.
func (*LimitedArrayStack[T]) Size ¶ added in v0.2.28
func (stack *LimitedArrayStack[T]) Size() int
Size is a method of the LimitedArrayStack type. It is used to return the number of elements in the stack.
Returns:
- int: An integer that represents the number of elements in the stack.
func (*LimitedArrayStack[T]) Slice ¶ added in v0.2.28
func (stack *LimitedArrayStack[T]) Slice() []T
Slice is a method of the LimitedArrayStack type. It is used to return a slice of the elements in the stack.
Returns:
- []T: A slice of the elements in the stack.
func (*LimitedArrayStack[T]) String ¶ added in v0.2.28
func (stack *LimitedArrayStack[T]) String() string
String is a method of the LimitedArrayStack type. It is used to return a string representation of the stack, including its capacity and the elements it contains.
Returns:
- string: A string representation of the stack.
type LimitedLinkedStack ¶ added in v0.2.28
type LimitedLinkedStack[T any] struct { // contains filtered or unexported fields }
LimitedLinkedStack is a generic type that represents a stack data structure with or without a limited capacity, implemented using a linked list.
func NewLimitedLinkedStack ¶ added in v0.2.28
func NewLimitedLinkedStack[T any](values ...T) *LimitedLinkedStack[T]
NewLimitedLinkedStack is a function that creates and returns a new instance of a LimitedLinkedStack.
Parameters:
- values: A variadic parameter of type T, which represents the initial values to be stored in the stack.
Returns:
- *LimitedLinkedStack[T]: A pointer to the newly created LimitedLinkedStack.
func (*LimitedLinkedStack[T]) Capacity ¶ added in v0.2.28
func (stack *LimitedLinkedStack[T]) Capacity() int
Capacity is a method of the LimitedLinkedStack type. It is used to return the maximum number of elements the stack can hold.
Returns:
- optional.Int: The maximum number of elements the stack can hold.
func (*LimitedLinkedStack[T]) Clear ¶ added in v0.2.28
func (stack *LimitedLinkedStack[T]) Clear()
Clear is a method of the LimitedLinkedStack type. It is used to remove all elements from the stack.
func (*LimitedLinkedStack[T]) Copy ¶ added in v0.2.28
func (stack *LimitedLinkedStack[T]) Copy() itff.Copier
Copy is a method of the LimitedLinkedStack type. It is used to create a shallow copy of the stack.
Returns:
- itf.Copier: A copy of the stack.
func (*LimitedLinkedStack[T]) CutNilValues ¶ added in v0.2.28
func (stack *LimitedLinkedStack[T]) CutNilValues()
CutNilValues is a method of the LimitedLinkedStack type. It is used to remove all nil values from the stack.
func (*LimitedLinkedStack[T]) IsEmpty ¶ added in v0.2.28
func (stack *LimitedLinkedStack[T]) IsEmpty() bool
IsEmpty is a method of the LimitedLinkedStack type. It is used to check if the stack is empty.
Returns:
- bool: true if the stack is empty, and false otherwise.
func (*LimitedLinkedStack[T]) IsFull ¶ added in v0.2.28
func (stack *LimitedLinkedStack[T]) IsFull() bool
IsFull is a method of the LimitedLinkedStack type. It is used to check if the stack is full.
Returns:
- isFull: true if the stack is full, and false otherwise.
func (*LimitedLinkedStack[T]) Iterator ¶ added in v0.2.28
func (stack *LimitedLinkedStack[T]) Iterator() itf.Iterater[T]
Iterator is a method of the LimitedLinkedStack type. It is used to return an iterator for the elements in the stack.
Returns:
- itf.Iterater[T]: An iterator for the elements in the stack.
func (*LimitedLinkedStack[T]) Peek ¶ added in v0.2.28
func (stack *LimitedLinkedStack[T]) Peek() T
Peek is a method of the LimitedLinkedStack type. It is used to return the last element in the stack without removing it.
Panics with an error of type *ErrCallFailed if the stack is empty.
Returns:
- T: The value of the last element in the stack.
func (*LimitedLinkedStack[T]) Pop ¶ added in v0.2.28
func (stack *LimitedLinkedStack[T]) Pop() T
Pop is a method of the LimitedLinkedStack type. It is used to remove and return the last element in the stack.
Panics with an error of type *ErrCallFailed if the stack is empty.
Returns:
- T: The value of the last element in the stack.
func (*LimitedLinkedStack[T]) Push ¶ added in v0.2.28
func (stack *LimitedLinkedStack[T]) Push(value T)
Push is a method of the LimitedLinkedStack type. It is used to add an element to the end of the stack.
Panics with an error of type *ErrCallFailed if the stack is full.
Parameters:
- value: The value to be added to the stack.
func (*LimitedLinkedStack[T]) Size ¶ added in v0.2.28
func (stack *LimitedLinkedStack[T]) Size() int
Size is a method of the LimitedLinkedStack type. It is used to return the number of elements in the stack.
Returns:
- int: The number of elements in the stack.
func (*LimitedLinkedStack[T]) Slice ¶ added in v0.2.28
func (stack *LimitedLinkedStack[T]) Slice() []T
Slice is a method of the LimitedLinkedStack type. It is used to return a slice of the elements in the stack.
Returns:
- []T: A slice of the elements in the stack.
func (*LimitedLinkedStack[T]) String ¶ added in v0.2.28
func (stack *LimitedLinkedStack[T]) String() string
String is a method of the LimitedLinkedStack type. It is used to return a string representation of the stack, which includes the size, capacity, and elements in the stack.
Returns:
- string: A string representation of the stack.
type LinkedStack ¶
type LinkedStack[T any] struct { // contains filtered or unexported fields }
LinkedStack is a generic type that represents a stack data structure with or without a limited capacity, implemented using a linked list.
func NewLinkedStack ¶
func NewLinkedStack[T any](values ...T) *LinkedStack[T]
NewLinkedStack is a function that creates and returns a new instance of a LinkedStack.
Parameters:
- values: A variadic parameter of type T, which represents the initial values to be stored in the stack.
Returns:
- *LinkedStack[T]: A pointer to the newly created LinkedStack.
func (*LinkedStack[T]) Capacity ¶ added in v0.2.28
func (stack *LinkedStack[T]) Capacity() int
func (*LinkedStack[T]) Clear ¶
func (stack *LinkedStack[T]) Clear()
Clear is a method of the LinkedStack type. It is used to remove aCommon elements from the stack.
func (*LinkedStack[T]) Copy ¶
func (stack *LinkedStack[T]) Copy() itff.Copier
Copy is a method of the LinkedStack type. It is used to create a shaCommonow copy of the stack.
Returns:
- itf.Copier: A copy of the stack.
func (*LinkedStack[T]) CutNilValues ¶
func (stack *LinkedStack[T]) CutNilValues()
CutNilValues is a method of the LinkedStack type. It is used to remove aCommon nil values from the stack.
func (*LinkedStack[T]) IsEmpty ¶
func (stack *LinkedStack[T]) IsEmpty() bool
IsEmpty is a method of the LinkedStack type. It is used to check if the stack is empty.
Returns:
- bool: true if the stack is empty, and false otherwise.
func (*LinkedStack[T]) IsFull ¶ added in v0.2.28
func (stack *LinkedStack[T]) IsFull() bool
func (*LinkedStack[T]) Iterator ¶
func (stack *LinkedStack[T]) Iterator() itf.Iterater[T]
Iterator is a method of the LinkedStack type. It is used to return an iterator for the elements in the stack.
Returns:
- itf.Iterater[T]: An iterator for the elements in the stack.
func (*LinkedStack[T]) Peek ¶
func (stack *LinkedStack[T]) Peek() T
Peek is a method of the LinkedStack type. It is used to return the last element in the stack without removing it.
Panics with an error of type *Common.ErrEmptyList if the stack is empty.
Returns:
- T: The value of the last element in the stack.
func (*LinkedStack[T]) Pop ¶
func (stack *LinkedStack[T]) Pop() T
Pop is a method of the LinkedStack type. It is used to remove and return the last element in the stack.
Panics with an error of type *Common.ErrEmptyList if the stack is empty.
Returns:
- T: The value of the last element in the stack.
func (*LinkedStack[T]) Push ¶
func (stack *LinkedStack[T]) Push(value T)
Push is a method of the LinkedStack type. It is used to add an element to the end of the stack.
Panics with an error of type *ErrCaCommonFailed if the stack is fuCommon.
Parameters:
- value: The value to be added to the stack.
func (*LinkedStack[T]) Size ¶
func (stack *LinkedStack[T]) Size() int
Size is a method of the LinkedStack type. It is used to return the number of elements in the stack.
Returns:
- int: The number of elements in the stack.
func (*LinkedStack[T]) Slice ¶
func (stack *LinkedStack[T]) Slice() []T
Slice is a method of the LinkedStack type. It is used to return a slice of the elements in the stack.
Returns:
- []T: A slice of the elements in the stack.
func (*LinkedStack[T]) String ¶
func (stack *LinkedStack[T]) String() string
String is a method of the LinkedStack type. It is used to return a string representation of the stack, which includes the size, capacity, and elements in the stack.
Returns:
- string: A string representation of the stack.