Documentation ¶
Index ¶
- type List
- func (instance *List[T]) Clear() *List[T]
- func (instance *List[T]) Decode(byteData []byte) (err error)
- func (instance *List[T]) Encode() (response []byte, err error)
- func (instance *List[T]) First() (response T)
- func (instance *List[T]) For(callback func(item T, index int, arr []T) error)
- func (instance *List[T]) Get(index int) (response T)
- func (instance *List[T]) GetFIFO() (response bool)
- func (instance *List[T]) GetLIFO() (response bool)
- func (instance *List[T]) Insert(index int, items ...T)
- func (instance *List[T]) Items() (response []T)
- func (instance *List[T]) Last() (response T)
- func (instance *List[T]) Len() (response int)
- func (instance *List[T]) LoadFromFile(filename string) (err error)
- func (instance *List[T]) Map(callback func(item T, index int, arr []T) (selected T, err error)) (response []T)
- func (instance *List[T]) MapToFile(filename string, ...) (err error)
- func (instance *List[T]) Pop() (response T)
- func (instance *List[T]) Push(item T) *List[T]
- func (instance *List[T]) Remove(index int)
- func (instance *List[T]) Reverse() *List[T]
- func (instance *List[T]) SaveToFile(filename string) (err error)
- func (instance *List[T]) SetFIFO(v bool) *List[T]
- func (instance *List[T]) SetLIFO(v bool) *List[T]
- func (instance *List[T]) Shuffle() *List[T]
- func (instance *List[T]) Sort(sortFunc func(a, b T) bool) *List[T]
- func (instance *List[T]) String() string
- type Queue
- type Stack
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type List ¶ added in v0.2.111
type List[T any] struct { Data []T `json:"data"` // list data MaxSize int `json:"max_size"` // max size of the list FIFO bool `json:"fifo"` // first in - first out // contains filtered or unexported fields }
List is a generic container that stores elements of any type T. It supports a maximum size and can operate as a FIFO r LIFO. Elements are stored in a slice, and access to the container is synchronized using a mutex to ensure thread safety. LIFO mode is default (Last In - First Out). Order of elements depends on "FIFO" or "LIFO" mode. If "LIFO", this object works as a normal array (stack) where items are appended at the end with Push() method. If "FIFO", this object works as a reversed array (queue) where items are inserted into first place with Push().
func NewListFIFO ¶ added in v0.2.111
func NewListLIFO ¶ added in v0.2.111
func (*List[T]) LoadFromFile ¶ added in v0.2.111
func (*List[T]) SaveToFile ¶ added in v0.2.111
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is a basic FIFO queue based on a circular list that resizes as needed.