Documentation ¶
Index ¶
- type ErrEmptyList
- type ErrFullList
- type LimitedSafeList
- func (list *LimitedSafeList[T]) Append(value T) error
- func (list *LimitedSafeList[T]) Capacity() (int, bool)
- func (list *LimitedSafeList[T]) Clear()
- func (list *LimitedSafeList[T]) Copy() itff.Copier
- func (list *LimitedSafeList[T]) CutNilValues()
- func (list *LimitedSafeList[T]) DeleteFirst() (T, error)
- func (list *LimitedSafeList[T]) DeleteLast() (T, error)
- func (list *LimitedSafeList[T]) IsEmpty() bool
- func (list *LimitedSafeList[T]) IsFull() (isFull bool)
- func (list *LimitedSafeList[T]) Iterator() itf.Iterater[T]
- func (list *LimitedSafeList[T]) PeekFirst() (T, error)
- func (list *LimitedSafeList[T]) PeekLast() (T, error)
- func (list *LimitedSafeList[T]) Prepend(value T) error
- func (list *LimitedSafeList[T]) Size() int
- func (list *LimitedSafeList[T]) Slice() []T
- func (list *LimitedSafeList[T]) String() string
- type LimitedSafeQueue
- func (queue *LimitedSafeQueue[T]) Capacity() (int, bool)
- func (queue *LimitedSafeQueue[T]) Clear()
- func (queue *LimitedSafeQueue[T]) Copy() itff.Copier
- func (queue *LimitedSafeQueue[T]) CutNilValues()
- func (queue *LimitedSafeQueue[T]) Dequeue() (T, error)
- func (queue *LimitedSafeQueue[T]) Enqueue(value T) error
- func (queue *LimitedSafeQueue[T]) IsEmpty() bool
- func (queue *LimitedSafeQueue[T]) IsFull() (isFull bool)
- func (queue *LimitedSafeQueue[T]) Iterator() itf.Iterater[T]
- func (queue *LimitedSafeQueue[T]) Peek() (T, error)
- func (queue *LimitedSafeQueue[T]) Size() int
- func (queue *LimitedSafeQueue[T]) Slice() []T
- func (queue *LimitedSafeQueue[T]) String() string
- type ListLike
- type SafeList
- func (list *SafeList[T]) Append(value T)
- func (list *SafeList[T]) Capacity() (int, bool)
- func (list *SafeList[T]) Clear()
- func (list *SafeList[T]) Copy() itff.Copier
- func (list *SafeList[T]) CutNilValues()
- func (list *SafeList[T]) DeleteFirst() (T, error)
- func (list *SafeList[T]) DeleteLast() (T, error)
- func (list *SafeList[T]) IsEmpty() bool
- func (list *SafeList[T]) IsFull() bool
- func (list *SafeList[T]) Iterator() itf.Iterater[T]
- func (list *SafeList[T]) PeekFirst() (T, error)
- func (list *SafeList[T]) PeekLast() (T, error)
- func (list *SafeList[T]) Prepend(value T)
- func (list *SafeList[T]) Size() int
- func (list *SafeList[T]) Slice() []T
- func (list *SafeList[T]) String() string
- type SafeQueue
- func (queue *SafeQueue[T]) Clear()
- func (queue *SafeQueue[T]) Copy() itff.Copier
- func (queue *SafeQueue[T]) CutNilValues()
- func (queue *SafeQueue[T]) Dequeue() (T, error)
- func (queue *SafeQueue[T]) Enqueue(value T)
- func (queue *SafeQueue[T]) IsEmpty() bool
- func (queue *SafeQueue[T]) Iterator() itf.Iterater[T]
- func (queue *SafeQueue[T]) Peek() (T, error)
- func (queue *SafeQueue[T]) Size() int
- func (queue *SafeQueue[T]) Slice() []T
- func (queue *SafeQueue[T]) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrEmptyList ¶
type ErrEmptyList[T any] struct { // contains filtered or unexported fields }
func NewErrEmptyList ¶
func NewErrEmptyList[T any](list ListLike[T]) *ErrEmptyList[T]
func (*ErrEmptyList[T]) Error ¶
func (e *ErrEmptyList[T]) Error() string
type ErrFullList ¶
type ErrFullList[T any] struct { // contains filtered or unexported fields }
func NewErrFullList ¶
func NewErrFullList[T any](list ListLike[T]) *ErrFullList[T]
func (*ErrFullList[T]) Error ¶
func (e *ErrFullList[T]) Error() string
type LimitedSafeList ¶
type LimitedSafeList[T any] struct { // contains filtered or unexported fields }
LimitedSafeList is a generic type that represents a thread-safe list data structure with or without a maximum capacity, implemented using a linked list.
func NewLimitedSafeList ¶
func NewLimitedSafeList[T any](values ...T) *LimitedSafeList[T]
NewLimitedSafeList is a function that creates and returns a new instance of a LimitedSafeList.
Parameters:
- values: A variadic parameter of type T, which represents the initial values to be stored in the list.
Returns:
- *LimitedSafeList[T]: A pointer to the newly created LimitedSafeList.
func (*LimitedSafeList[T]) Append ¶
func (list *LimitedSafeList[T]) Append(value T) error
Append is a method of the LimitedSafeList type. It is used to add an element to the end of the list.
Panics with an error of type *ErrCallFailed if the list is fu
Parameters:
- value: The value of type T to be added to the list.
func (*LimitedSafeList[T]) Capacity ¶
func (list *LimitedSafeList[T]) Capacity() (int, bool)
Capacity is a method of the LimitedSafeList type. It returns the maximum number of elements that the list can hold.
Returns:
- optional.Int: An optional integer that represents the maximum number of elements the list can hold.
func (*LimitedSafeList[T]) Clear ¶
func (list *LimitedSafeList[T]) Clear()
Clear is a method of the LimitedSafeList type. It is used to remove all elements from the list.
func (*LimitedSafeList[T]) Copy ¶
func (list *LimitedSafeList[T]) Copy() itff.Copier
Copy is a method of the LimitedSafeList type. It is used to create a shallow copy of the list.
Returns:
- itff.Copier: A copy of the list.
func (*LimitedSafeList[T]) CutNilValues ¶
func (list *LimitedSafeList[T]) CutNilValues()
CutNilValues is a method of the LimitedSafeList type. It is used to remove all nil values from the list.
func (*LimitedSafeList[T]) DeleteFirst ¶
func (list *LimitedSafeList[T]) DeleteFirst() (T, error)
DeleteFirst is a method of the LimitedSafeList type. It is used to remove and return the first element from the list.
Panics with an error of type *ErrCallFailed if the list is empty.
Returns:
- T: The first element in the list.
func (*LimitedSafeList[T]) DeleteLast ¶
func (list *LimitedSafeList[T]) DeleteLast() (T, error)
DeleteLast is a method of the LimitedSafeList type. It is used to remove and return the last element from the list.
Panics with an error of type *ErrCallFailed if the list is empty.
Returns:
- T: The last element in the list.
func (*LimitedSafeList[T]) IsEmpty ¶
func (list *LimitedSafeList[T]) IsEmpty() bool
IsEmpty is a method of the LimitedSafeList type. It checks if the list is empty.
Returns:
- bool: A boolean value that is true if the list is empty, and false otherwise.
func (*LimitedSafeList[T]) IsFull ¶
func (list *LimitedSafeList[T]) IsFull() (isFull bool)
IsFull is a method of the LimitedSafeList type. It checks if the list is fu
Returns:
- isFull: A boolean value that is true if the list is full, and false otherwise.
func (*LimitedSafeList[T]) Iterator ¶
func (list *LimitedSafeList[T]) Iterator() itf.Iterater[T]
Iterator is a method of the LimitedSafeList type. It is used to return an iterator for the list. However, the iterator does not share the list's thread safety.
Returns:
- itf.Iterater[T]: An iterator for the list.
func (*LimitedSafeList[T]) PeekFirst ¶
func (list *LimitedSafeList[T]) PeekFirst() (T, error)
PeekFirst is a method of the LimitedSafeList type. It is used to return the first element from the list without removing it.
Panics with an error of type *ErrCallFailed if the list is empty.
Returns:
- T: The first element in the list.
func (*LimitedSafeList[T]) PeekLast ¶
func (list *LimitedSafeList[T]) PeekLast() (T, error)
PeekLast is a method of the LimitedSafeList type. It is used to return the last element from the list without removing it.
Panics with an error of type *ErrCallFailed if the list is empty.
Returns:
- T: The last element in the list.
func (*LimitedSafeList[T]) Prepend ¶
func (list *LimitedSafeList[T]) Prepend(value T) error
Prepend is a method of the LimitedSafeList type. It is used to add an element to the front of the list.
Panics with an error of type *ErrCallFailed if the list is fu
Parameters:
- value: The value of type T to be added to the list.
func (*LimitedSafeList[T]) Size ¶
func (list *LimitedSafeList[T]) Size() int
Size is a method of the LimitedSafeList type. It returns the number of elements in the list.
Returns:
- int: An integer that represents the number of elements in the list.
func (*LimitedSafeList[T]) Slice ¶
func (list *LimitedSafeList[T]) Slice() []T
Slice is a method of the LimitedSafeList type. It is used to return a slice of the elements in the list.
Returns:
- []T: A slice of type T containing the elements of the list.
func (*LimitedSafeList[T]) String ¶
func (list *LimitedSafeList[T]) String() string
String is a method of the LimitedSafeList type. It returns a string representation of the list including information about its size, capacity, and elements.
Returns:
- string: A string representation of the list.
type LimitedSafeQueue ¶
type LimitedSafeQueue[T any] struct { // contains filtered or unexported fields }
LimitedSafeQueue is a generic type that represents a thread-safe queue data structure with or without a limited capacity, implemented using a linked list.
func NewLimitedSafeQueue ¶
func NewLimitedSafeQueue[T any](values ...T) *LimitedSafeQueue[T]
NewLimitedSafeQueue is a function that creates and returns a new instance of a LimitedSafeQueue.
Parameters:
- values: A variadic parameter of type T, which represents the initial values to be stored in the queue.
Return:
- *LimitedSafeQueue[T]: A pointer to the newly created LimitedSafeQueue.
func (*LimitedSafeQueue[T]) Capacity ¶
func (queue *LimitedSafeQueue[T]) Capacity() (int, bool)
Capacity is a method of the LimitedSafeQueue type. It is used to return the maximum number of elements the queue can hold.
Returns:
- optional.Int: An optional integer that represents the maximum number of elements the queue can hold.
func (*LimitedSafeQueue[T]) Clear ¶
func (queue *LimitedSafeQueue[T]) Clear()
Clear is a method of the LimitedSafeQueue type. It is used to remove all elements from the queue, making it empty.
func (*LimitedSafeQueue[T]) Copy ¶
func (queue *LimitedSafeQueue[T]) Copy() itff.Copier
Copy is a method of the LimitedSafeQueue type. It is used to create a shallow copy of the queue.
Returns:
- itf.Copier: A copy of the queue.
func (*LimitedSafeQueue[T]) CutNilValues ¶
func (queue *LimitedSafeQueue[T]) CutNilValues()
CutNilValues is a method of the LimitedSafeQueue type. It is used to remove all nil values from the queue.
func (*LimitedSafeQueue[T]) Dequeue ¶
func (queue *LimitedSafeQueue[T]) Dequeue() (T, error)
Dequeue is a method of the LimitedSafeQueue type. It is used to remove and return the element at the front of the queue.
Panics with an error of type *ErrCallFailed if the queue is empty.
Returns:
- T: The value of the element at the front of the queue.
func (*LimitedSafeQueue[T]) Enqueue ¶
func (queue *LimitedSafeQueue[T]) Enqueue(value T) error
Enqueue is a method of the LimitedSafeQueue type. It is used to add an element to the back of the queue.
Panics with an error of type *ErrCallFailed if the queue is fu
Parameters:
- value: The value of type T to be added to the queue.
func (*LimitedSafeQueue[T]) IsEmpty ¶
func (queue *LimitedSafeQueue[T]) IsEmpty() bool
IsEmpty is a method of the LimitedSafeQueue type. It is used to check if the queue is empty.
Returns:
- bool: A boolean value that is true if the queue is empty, and false otherwise.
func (*LimitedSafeQueue[T]) IsFull ¶
func (queue *LimitedSafeQueue[T]) IsFull() (isFull bool)
IsFull is a method of the LimitedSafeQueue type. It is used to check if the queue is full, meaning it has reached its maximum capacity and cannot accept any more elements.
Returns:
- isFull: A boolean value that is true if the queue is full, and false otherwise.
func (*LimitedSafeQueue[T]) Iterator ¶
func (queue *LimitedSafeQueue[T]) Iterator() itf.Iterater[T]
Iterator is a method of the LimitedSafeQueue type. It is used to return an iterator that can be used to iterate over the elements in the queue. However, the iterator does not share the queue's thread-safety.
Returns:
- itf.Iterater[T]: An iterator that can be used to iterate over the elements in the queue.
func (*LimitedSafeQueue[T]) Peek ¶
func (queue *LimitedSafeQueue[T]) Peek() (T, error)
Peek is a method of the LimitedSafeQueue type. It is used to return the element at the front of the queue without removing it.
Panics with an error of type *ErrCallFailed if the queue is empty.
Returns:
- T: The value of the element at the front of the queue.
func (*LimitedSafeQueue[T]) Size ¶
func (queue *LimitedSafeQueue[T]) Size() int
Size is a method of the LimitedSafeQueue type. It is used to return the number of elements in the queue.
Returns:
- int: An integer that represents the number of elements in the queue.
func (*LimitedSafeQueue[T]) Slice ¶
func (queue *LimitedSafeQueue[T]) Slice() []T
Slice is a method of the LimitedSafeQueue type. It is used to return a slice of the elements in the queue.
Returns:
- []T: A slice of the elements in the queue.
func (*LimitedSafeQueue[T]) String ¶
func (queue *LimitedSafeQueue[T]) String() string
String is a method of the LimitedSafeQueue type. It returns a string representation of the queue, including its size, capacity, and the elements it contains.
type ListLike ¶
type ListLike[T any] interface { // The IsEmpty method checks if the list is empty and returns a boolean value // indicating whether it is empty or not. IsEmpty() bool // The Size method returns the number of elements currently in the list. Size() int // The Clear method is used to remove all elements from the list, making it empty. Clear() // The String method returns a string representation of the list. // It is useful for debugging and logging purposes. fmt.Stringer // CutNilValues is a method that removes all nil values from the list. // It is useful for cleaning up the list and removing any empty or nil elements. CutNilValues() // The itf.Iterable interface is used to provide an iterator for the list. itf.Iterable[T] // The itf.Slicer interface is used to provide a slicer for the list. itff.Slicer[T] // The itf.Copier interface is used to provide a method for copying the list. itff.Copier }
type SafeList ¶
type SafeList[T any] struct { // contains filtered or unexported fields }
SafeList is a generic type that represents a thread-safe list data structure with or without a maximum capacity, implemented using a linked list.
func NewSafeList ¶
NewSafeList is a function that creates and returns a new instance of a SafeList.
Parameters:
- values: A variadic parameter of type T, which represents the initial values to be stored in the list.
Returns:
- *SafeList[T]: A pointer to the newly created SafeList.
func (*SafeList[T]) Append ¶
func (list *SafeList[T]) Append(value T)
Append is a method of the SafeList type. It is used to add an element to the end of the list.
Panics with an error of type *ErrCallFailed if the list is fu
Parameters:
- value: The value of type T to be added to the list.
func (*SafeList[T]) Capacity ¶
Capacity is a method of the SafeList type. It returns the maximum number of elements that the list can hold.
Returns:
- optional.Int: An optional integer that represents the maximum number of elements the list can hold.
func (*SafeList[T]) Clear ¶
func (list *SafeList[T]) Clear()
Clear is a method of the SafeList type. It is used to remove all elements from the list.
func (*SafeList[T]) Copy ¶
Copy is a method of the SafeList type. It is used to create a shallow copy of the list.
Returns:
- itf.Copier: A copy of the list.
func (*SafeList[T]) CutNilValues ¶
func (list *SafeList[T]) CutNilValues()
CutNilValues is a method of the SafeList type. It is used to remove all nil values from the list.
func (*SafeList[T]) DeleteFirst ¶
DeleteFirst is a method of the SafeList type. It is used to remove and return the first element from the list.
Panics with an error of type *ErrCallFailed if the list is empty.
Returns:
- T: The first element in the list.
func (*SafeList[T]) DeleteLast ¶
DeleteLast is a method of the SafeList type. It is used to remove and return the last element from the list.
Panics with an error of type *ErrCallFailed if the list is empty.
Returns:
- T: The last element in the list.
func (*SafeList[T]) IsEmpty ¶
IsEmpty is a method of the SafeList type. It checks if the list is empty.
Returns:
- bool: A boolean value that is true if the list is empty, and false otherwise.
func (*SafeList[T]) IsFull ¶
IsFull is a method of the SafeList type. It checks if the list is fu
Returns:
- isFull: A boolean value that is true if the list is full, and false otherwise.
func (*SafeList[T]) Iterator ¶
Iterator is a method of the SafeList type. It is used to return an iterator for the list. However, the iterator does not share the list's thread safety.
Returns:
- itf.Iterater[T]: An iterator for the list.
func (*SafeList[T]) PeekFirst ¶
PeekFirst is a method of the SafeList type. It is used to return the first element from the list without removing it.
Panics with an error of type *ErrCallFailed if the list is empty.
Returns:
- T: The first element in the list.
func (*SafeList[T]) PeekLast ¶
PeekLast is a method of the SafeList type. It is used to return the last element from the list without removing it.
Panics with an error of type *ErrCallFailed if the list is empty.
Returns:
- T: The last element in the list.
func (*SafeList[T]) Prepend ¶
func (list *SafeList[T]) Prepend(value T)
Prepend is a method of the SafeList type. It is used to add an element to the front of the list.
Panics with an error of type *ErrCallFailed if the list is fu
Parameters:
- value: The value of type T to be added to the list.
func (*SafeList[T]) Size ¶
Size is a method of the SafeList type. It returns the number of elements in the list.
Returns:
- int: An integer that represents the number of elements in the list.
type SafeQueue ¶
type SafeQueue[T any] struct { // contains filtered or unexported fields }
SafeQueue is a generic type that represents a thread-safe queue data structure with or without a limited capacity, implemented using a linked list.
func NewSafeQueue ¶
NewSafeQueue is a function that creates and returns a new instance of a SafeQueue.
Parameters:
- values: A variadic parameter of type T, which represents the initial values to be stored in the queue.
Return:
- *SafeQueue[T]: A pointer to the newly created SafeQueue.
func (*SafeQueue[T]) Clear ¶
func (queue *SafeQueue[T]) Clear()
Clear is a method of the SafeQueue type. It is used to remove all elements from the queue, making it empty.
func (*SafeQueue[T]) Copy ¶
Copy is a method of the SafeQueue type. It is used to create a shallow copy of the queue.
Returns:
- itf.Copier: A copy of the queue.
func (*SafeQueue[T]) CutNilValues ¶
func (queue *SafeQueue[T]) CutNilValues()
CutNilValues is a method of the SafeQueue type. It is used to remove all nil values from the queue.
func (*SafeQueue[T]) Dequeue ¶
Dequeue is a method of the SafeQueue type. It is used to remove and return the element at the front of the queue.
Panics with an error of type *ErrCallFailed if the queue is empty.
Returns:
- T: The value of the element at the front of the queue.
func (*SafeQueue[T]) Enqueue ¶
func (queue *SafeQueue[T]) Enqueue(value T)
Enqueue is a method of the SafeQueue type. It is used to add an element to the back of the queue.
Panics with an error of type *ErrCallFailed if the queue is fu
Parameters:
- value: The value of type T to be added to the queue.
func (*SafeQueue[T]) IsEmpty ¶
IsEmpty is a method of the SafeQueue type. It is used to check if the queue is empty.
Returns:
- bool: A boolean value that is true if the queue is empty, and false otherwise.
func (*SafeQueue[T]) Iterator ¶
Iterator is a method of the SafeQueue type. It is used to return an iterator that can be used to iterate over the elements in the queue. However, the iterator does not share the queue's thread-safety.
Returns:
- itf.Iterater[T]: An iterator that can be used to iterate over the elements in the queue.
func (*SafeQueue[T]) Peek ¶
Peek is a method of the SafeQueue type. It is used to return the element at the front of the queue without removing it.
Panics with an error of type *ErrCallFailed if the queue is empty.
Returns:
- T: The value of the element at the front of the queue.
func (*SafeQueue[T]) Size ¶
Size is a method of the SafeQueue type. It is used to return the number of elements in the queue.
Returns:
- int: An integer that represents the number of elements in the queue.