Documentation ¶
Index ¶
- type ArrayList
- func (list *ArrayList[T]) Append(value T) error
- func (list *ArrayList[T]) Capacity() int
- func (list *ArrayList[T]) Clear()
- func (list *ArrayList[T]) Copy() uc.Copier
- func (list *ArrayList[T]) CutNilValues()
- func (list *ArrayList[T]) DeleteFirst() (T, error)
- func (list *ArrayList[T]) DeleteLast() (T, error)
- func (list *ArrayList[T]) GoString() string
- func (list *ArrayList[T]) IsEmpty() bool
- func (list *ArrayList[T]) IsFull() (isFull bool)
- func (list *ArrayList[T]) Iterator() itf.Iterater[T]
- func (list *ArrayList[T]) PeekFirst() (T, error)
- func (list *ArrayList[T]) PeekLast() (T, error)
- func (list *ArrayList[T]) Prepend(value T) error
- func (list *ArrayList[T]) Size() int
- func (list *ArrayList[T]) Slice() []T
- type ErrFullList
- type LimitedArrayList
- func (list *LimitedArrayList[T]) Append(value T) error
- func (list *LimitedArrayList[T]) Capacity() int
- func (list *LimitedArrayList[T]) Clear()
- func (list *LimitedArrayList[T]) Copy() uc.Copier
- func (list *LimitedArrayList[T]) CutNilValues()
- func (list *LimitedArrayList[T]) DeleteFirst() (T, error)
- func (list *LimitedArrayList[T]) DeleteLast() (T, error)
- func (list *LimitedArrayList[T]) GoString() string
- func (list *LimitedArrayList[T]) IsEmpty() bool
- func (list *LimitedArrayList[T]) IsFull() bool
- func (list *LimitedArrayList[T]) Iterator() itf.Iterater[T]
- func (list *LimitedArrayList[T]) PeekFirst() (T, error)
- func (list *LimitedArrayList[T]) PeekLast() (T, error)
- func (list *LimitedArrayList[T]) Prepend(value T) error
- func (list *LimitedArrayList[T]) Size() int
- func (list *LimitedArrayList[T]) Slice() []T
- type LimitedLinkedList
- func (list *LimitedLinkedList[T]) Append(value T) error
- func (list *LimitedLinkedList[T]) Capacity() int
- func (list *LimitedLinkedList[T]) Clear()
- func (list *LimitedLinkedList[T]) Copy() uc.Copier
- func (list *LimitedLinkedList[T]) CutNilValues()
- func (list *LimitedLinkedList[T]) DeleteFirst() (T, error)
- func (list *LimitedLinkedList[T]) DeleteLast() (T, error)
- func (list *LimitedLinkedList[T]) GoString() string
- func (list *LimitedLinkedList[T]) IsEmpty() bool
- func (list *LimitedLinkedList[T]) IsFull() bool
- func (list *LimitedLinkedList[T]) Iterator() itf.Iterater[T]
- func (list *LimitedLinkedList[T]) PeekFirst() (T, error)
- func (list *LimitedLinkedList[T]) PeekLast() (T, error)
- func (list *LimitedLinkedList[T]) Prepend(value T) error
- func (list *LimitedLinkedList[T]) Size() int
- func (list *LimitedLinkedList[T]) Slice() []T
- type LimitedSafeList
- func (list *LimitedSafeList[T]) Append(value T) error
- func (list *LimitedSafeList[T]) Capacity() int
- func (list *LimitedSafeList[T]) Clear()
- func (list *LimitedSafeList[T]) Copy() uc.Copier
- func (list *LimitedSafeList[T]) CutNilValues()
- func (list *LimitedSafeList[T]) DeleteFirst() (T, error)
- func (list *LimitedSafeList[T]) DeleteLast() (T, error)
- func (list *LimitedSafeList[T]) GoString() string
- 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
- type LinkedList
- func (list *LinkedList[T]) Append(value T) error
- func (list *LinkedList[T]) Capacity() int
- func (list *LinkedList[T]) Clear()
- func (list *LinkedList[T]) Copy() uc.Copier
- func (list *LinkedList[T]) CutNilValues()
- func (list *LinkedList[T]) DeleteFirst() (T, error)
- func (list *LinkedList[T]) DeleteLast() (T, error)
- func (list *LinkedList[T]) GoString() string
- func (list *LinkedList[T]) IsEmpty() bool
- func (list *LinkedList[T]) IsFull() bool
- func (list *LinkedList[T]) Iterator() itf.Iterater[T]
- func (list *LinkedList[T]) PeekFirst() (T, error)
- func (list *LinkedList[T]) PeekLast() (T, error)
- func (list *LinkedList[T]) Prepend(value T) error
- func (list *LinkedList[T]) Size() int
- func (list *LinkedList[T]) Slice() []T
- type ListNode
- type ListSafeNode
- type Lister
- type SafeList
- func (list *SafeList[T]) Append(value T) error
- func (list *SafeList[T]) Capacity() int
- func (list *SafeList[T]) Clear()
- func (list *SafeList[T]) Copy() uc.Copier
- func (list *SafeList[T]) CutNilValues()
- func (list *SafeList[T]) DeleteFirst() (T, error)
- func (list *SafeList[T]) DeleteLast() (T, error)
- func (list *SafeList[T]) GoString() string
- 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) error
- func (list *SafeList[T]) Size() int
- func (list *SafeList[T]) Slice() []T
- type SafeLister
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrayList ¶
type ArrayList[T any] struct { // contains filtered or unexported fields }
ArrayList is a generic type that represents a list data structure with or without a limited capacity. It is implemented using an array.
func NewArrayList ¶
NewArrayList is a function that creates and returns a new instance of a ArrayList.
Parameters:
- values: A variadic parameter of type T, which represents the initial values to be stored in the list.
Returns:
- *ArrayList[T]: A pointer to the newly created ArrayList.
func (*ArrayList[T]) Append ¶
Append is a method of the ArrayList type. It is used to add an element to the end of the list.
Panics with an error of type *ErrFullList if the list is full.
Parameters:
- value: A pointer to an element of type T to be added to the list.
func (*ArrayList[T]) Capacity ¶
Capacity is a method of the ArrayList type. It returns the maximum number of elements the list can hold.
Returns:
- optional.Int: An optional integer that represents the maximum number of elements the list can hold.
func (*ArrayList[T]) Clear ¶
func (list *ArrayList[T]) Clear()
Clear is a method of the ArrayList type. It is used to remove all elements from the list.
func (*ArrayList[T]) Copy ¶
Copy is a method of the ArrayList type. It is used to create a shallow copy of the list.
Returns:
- itf.Copier: A copy of the list.
func (*ArrayList[T]) CutNilValues ¶
func (list *ArrayList[T]) CutNilValues()
CutNilValues is a method of the ArrayList type. It is used to remove all nil values from the list.
func (*ArrayList[T]) DeleteFirst ¶
DeleteFirst is a method of the ArrayList type. It is used to remove and return the first element in the list.
Panics with an error of type *ErrInvalidOperation if the list is empty.
Returns:
- T: The first element in the list.
func (*ArrayList[T]) DeleteLast ¶
DeleteLast is a method of the ArrayList type. It is used to remove and return the last element in the list.
Panics with an error of type *ErrInvalidOperation if the list is empty.
Returns:
- T: The last element in the list.
func (*ArrayList[T]) IsEmpty ¶
IsEmpty is a method of the ArrayList 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 (*ArrayList[T]) IsFull ¶
IsFull is a method of the ArrayList type. It checks if the list is full.
Returns:
- isFull: A boolean value that is true if the list is full, and false otherwise.
func (*ArrayList[T]) Iterator ¶
Iterator is a method of the ArrayList type. It returns an iterator for the list.
Returns:
- itf.Iterater[T]: An iterator for the list.
func (*ArrayList[T]) PeekFirst ¶
PeekFirst is a method of the ArrayList type. It is used to return the first element in the list without removing it.
Panics with an error of type *ErrInvalidOperation if the list is empty.
Returns:
- T: A pointer to the first element in the list.
func (*ArrayList[T]) PeekLast ¶
PeekLast is a method of the ArrayList type. It is used to return the last element in the list without removing it.
Panics with an error of type *ErrInvalidOperation if the list is empty.
Returns:
- T: The last element in the list.
func (*ArrayList[T]) Prepend ¶
Prepend is a method of the ArrayList type. It is used to add an element to the end of the list.
Panics with an error of type *ErrFullList if the list is full.
Parameters:
- value: A pointer to an element of type T to be added to the list.
type ErrFullList ¶
ErrFullList is an error type for a full list.
func NewErrFullList ¶
func NewErrFullList[T any](list Lister[T]) *ErrFullList[T]
NewErrFullList is a constructor for ErrFullList.
Parameters:
- list: The list that is full.
Returns:
- *ErrFullList: The error.
func (*ErrFullList[T]) Error ¶
func (e *ErrFullList[T]) Error() string
Error returns the error message: "list (%T) is full".
Returns:
- string: The error message.
Behaviors:
- If the list is nil, the error message is "list is full".
type LimitedArrayList ¶
type LimitedArrayList[T any] struct { // contains filtered or unexported fields }
LimitedArrayList is a generic type that represents a list data structure with or without a limited capacity. It is implemented using an array.
func NewLimitedArrayList ¶
func NewLimitedArrayList[T any](capacity int, values ...T) *LimitedArrayList[T]
NewLimitedArrayList is a function that creates and returns a new instance of a LimitedArrayList.
Parameters:
- capacity: An integer that represents the maximum number of elements the list. can hold. If the capacity is negative, the value is converted to a positive value.
- values: A variadic parameter of type T, which represents the initial values to be stored in the list.
Returns:
- *LimitedArrayList[T]: A pointer to the newly created LimitedArrayList.
func (*LimitedArrayList[T]) Append ¶
func (list *LimitedArrayList[T]) Append(value T) error
Append is a method of the LimitedArrayList type. It is used to add an element to the end of the list.
Parameters:
- value: An element of type T to be added to the list.
Returns:
- error: An error if the list is full.
func (*LimitedArrayList[T]) Capacity ¶
func (list *LimitedArrayList[T]) Capacity() int
Capacity is a method of the LimitedArrayList type. It returns the maximum number of elements the list can hold.
Returns:
- optional.Int: An optional integer that represents the maximum number of elements the list can hold.
func (*LimitedArrayList[T]) Clear ¶
func (list *LimitedArrayList[T]) Clear()
Clear is a method of the LimitedArrayList type. It is used to remove all elements from the list.
func (*LimitedArrayList[T]) Copy ¶
func (list *LimitedArrayList[T]) Copy() uc.Copier
Copy is a method of the LimitedArrayList type. It is used to create a shallow copy of the list.
Returns:
- itf.Copier: A copy of the list.
func (*LimitedArrayList[T]) CutNilValues ¶
func (list *LimitedArrayList[T]) CutNilValues()
CutNilValues is a method of the LimitedArrayList type. It is used to remove all nil values from the list.
func (*LimitedArrayList[T]) DeleteFirst ¶
func (list *LimitedArrayList[T]) DeleteFirst() (T, error)
DeleteFirst is a method of the LimitedArrayList type. It is used to remove and return the first element in the list. If the list is empty, it will panic.
Returns:
- T: The first element in the list.
func (*LimitedArrayList[T]) DeleteLast ¶
func (list *LimitedArrayList[T]) DeleteLast() (T, error)
DeleteLast is a method of the LimitedArrayList type. It is used to remove and return the last element in the list. If the list is empty, it will panic.
Returns:
- T: The last element in the list.
func (*LimitedArrayList[T]) GoString ¶ added in v0.3.8
func (list *LimitedArrayList[T]) GoString() string
GoString implements the fmt.GoStringer interface.
func (*LimitedArrayList[T]) IsEmpty ¶
func (list *LimitedArrayList[T]) IsEmpty() bool
IsEmpty is a method of the LimitedArrayList 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 (*LimitedArrayList[T]) IsFull ¶
func (list *LimitedArrayList[T]) IsFull() bool
IsFull is a method of the LimitedArrayList type. It checks if the list is full.
Returns:
- isFull: A boolean value that is true if the list is full, and false otherwise.
func (*LimitedArrayList[T]) Iterator ¶
func (list *LimitedArrayList[T]) Iterator() itf.Iterater[T]
Iterator is a method of the LimitedArrayList type. It returns an iterator for the list.
Returns:
- itf.Iterater[T]: An iterator for the list.
func (*LimitedArrayList[T]) PeekFirst ¶
func (list *LimitedArrayList[T]) PeekFirst() (T, error)
PeekFirst is a method of the LimitedArrayList type. It is used to return the first element in the list without removing it. If the list is empty, it will panic.
Returns:
- T: A pointer to the first element in the list.
func (*LimitedArrayList[T]) PeekLast ¶
func (list *LimitedArrayList[T]) PeekLast() (T, error)
PeekLast is a method of the LimitedArrayList type. It is used to return the last element in the list without removing it. If the list is empty, it will panic.
Returns:
- T: The last element in the list.
func (*LimitedArrayList[T]) Prepend ¶
func (list *LimitedArrayList[T]) Prepend(value T) error
Prepend is a method of the LimitedArrayList type. It is used to add an element to the end of the list.
Parameters:
- value: A pointer to an element of type T to be added to the list.
- error: An error if the list is full.
func (*LimitedArrayList[T]) Size ¶
func (list *LimitedArrayList[T]) Size() int
Size is a method of the LimitedArrayList type. It returns the number of elements in the list.
Returns:
- int: An integer that represents the number of elements in the list.
func (*LimitedArrayList[T]) Slice ¶
func (list *LimitedArrayList[T]) Slice() []T
Slice is a method of the LimitedArrayList type that returns a slice of type T containing the elements of the list.
Returns:
- []T: A slice of type T containing the elements of the list.
type LimitedLinkedList ¶
type LimitedLinkedList[T any] struct { // contains filtered or unexported fields }
LimitedLinkedList is a generic type that represents a list data structure with or without a limited capacity, implemented using a linked list.
func NewLimitedLinkedList ¶
func NewLimitedLinkedList[T any](values ...T) *LimitedLinkedList[T]
NewLimitedLinkedList is a function that creates and returns a new instance of a LimitedLinkedList.
Parameters:
- values: A variadic parameter of type T, which represents the initial values to be stored in the list.
Returns:
- *LimitedLinkedList[T]: A pointer to the newly created LimitedLinkedList.
func (*LimitedLinkedList[T]) Append ¶
func (list *LimitedLinkedList[T]) Append(value T) error
Append is a method of the LimitedLinkedList type. It is used to add an element to the end of the list.
Parameters:
- value: An element of type T to be added to the list.
Returns:
- error: An error if the list is full.
func (*LimitedLinkedList[T]) Capacity ¶
func (list *LimitedLinkedList[T]) Capacity() int
Capacity is a method of the LimitedLinkedList type. It is used to return the maximum number of elements the list can hold.
Returns:
- optional.Int: An optional integer that represents the maximum number of elements the list can hold.
func (*LimitedLinkedList[T]) Clear ¶
func (list *LimitedLinkedList[T]) Clear()
Clear is a method of the LimitedLinkedList type. It is used to remove all elements from the list.
func (*LimitedLinkedList[T]) Copy ¶
func (list *LimitedLinkedList[T]) Copy() uc.Copier
Copy is a method of the LimitedLinkedList type. It is used to create a shallow copy of the list.
Returns:
- itf.Copier: A copy of the list.
func (*LimitedLinkedList[T]) CutNilValues ¶
func (list *LimitedLinkedList[T]) CutNilValues()
CutNilValues is a method of the LimitedLinkedList type. It is used to remove all nil values from the list.
func (*LimitedLinkedList[T]) DeleteFirst ¶
func (list *LimitedLinkedList[T]) DeleteFirst() (T, error)
DeleteFirst is a method of the LimitedLinkedList type. It is used to remove and return the first element in the list. Panics if the list is empty.
Returns:
- T: The first element in the list.
func (*LimitedLinkedList[T]) DeleteLast ¶
func (list *LimitedLinkedList[T]) DeleteLast() (T, error)
DeleteLast is a method of the LimitedLinkedList type. It is used to remove and return the last element in the list.
Panics with an error of type *ErrCallFailed if the list is empty.
Returns:
- T: The last element in the list.
func (*LimitedLinkedList[T]) GoString ¶ added in v0.3.8
func (list *LimitedLinkedList[T]) GoString() string
GoString implements the fmt.GoStringer interface.
func (*LimitedLinkedList[T]) IsEmpty ¶
func (list *LimitedLinkedList[T]) IsEmpty() bool
IsEmpty is a method of the LimitedLinkedList type. It is used to check if the list is empty.
Returns:
- bool: A boolean value that is true if the list is empty, and false otherwise.
func (*LimitedLinkedList[T]) IsFull ¶
func (list *LimitedLinkedList[T]) IsFull() bool
IsFull is a method of the LimitedLinkedList type. It is used to check if the list is full.
Returns:
- isFull: A boolean value that is true if the list is full, and false otherwise.
func (*LimitedLinkedList[T]) Iterator ¶
func (list *LimitedLinkedList[T]) Iterator() itf.Iterater[T]
Iterator is a method of the LimitedLinkedList type. It is used to return an iterator for the list.
Returns:
- itf.Iterater[T]: An iterator for the list.
func (*LimitedLinkedList[T]) PeekFirst ¶
func (list *LimitedLinkedList[T]) PeekFirst() (T, error)
PeekFirst is a method of the LimitedLinkedList type. It is used to return the first element in the list without removing it.
Returns:
- value: The first element in the list.
func (*LimitedLinkedList[T]) PeekLast ¶
func (list *LimitedLinkedList[T]) PeekLast() (T, error)
PeekLast is a method of the LimitedLinkedList type. It is used to return the last element in the list without removing it.
Panics with an error of type *ErrCallFailed if the list is empty.
Returns:
- value: The last element in the list.
func (*LimitedLinkedList[T]) Prepend ¶
func (list *LimitedLinkedList[T]) Prepend(value T) error
Prepend is a method of the LimitedLinkedList type. It is used to add an element to the end of the list.
Panics with an error of type *ErrInvalidOperation if the list is full.
Parameters:
- value: An element of type T to be added to the list.
func (*LimitedLinkedList[T]) Size ¶
func (list *LimitedLinkedList[T]) Size() int
Size is a method of the LimitedLinkedList type. It is used to return the current number of elements in the list.
Returns:
- int: An integer that represents the current number of elements in the list.
func (*LimitedLinkedList[T]) Slice ¶
func (list *LimitedLinkedList[T]) Slice() []T
Slice is a method of the LimitedLinkedList type that returns a slice of type T
Returns:
- []T: A slice of type T.
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
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() uc.Copier
Copy is a method of the LimitedSafeList type. It is used to create a shallow copy of the list.
Returns:
- uc.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]) GoString ¶ added in v0.3.8
func (list *LimitedSafeList[T]) GoString() string
GoString implements the fmt.GoStringer interface.
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.
type LinkedList ¶
type LinkedList[T any] struct { // contains filtered or unexported fields }
LinkedList is a generic type that represents a list data structure with or without a limited capacity, implemented using a linked list.
func NewLinkedList ¶
func NewLinkedList[T any](values ...T) *LinkedList[T]
NewLinkedList is a function that creates and returns a new instance of a LinkedList.
Parameters:
- values: A variadic parameter of type T, which represents the initial values to be stored in the list.
Returns:
- *LinkedList[T]: A pointer to the newly created LinkedList.
func (*LinkedList[T]) Append ¶
func (list *LinkedList[T]) Append(value T) error
Append is a method of the LinkedList type. It is used to add an element to the end of the list.
Panics with an error of type *ErrFullList if the list is full.
Parameters:
- value: An element of type T to be added to the list.
func (*LinkedList[T]) Capacity ¶
func (list *LinkedList[T]) Capacity() int
Capacity is a method of the LinkedList type. It is used to return the maximum number of elements the list can hold.
Returns:
- optional.Int: An optional integer that represents the maximum number of elements the list can hold.
func (*LinkedList[T]) Clear ¶
func (list *LinkedList[T]) Clear()
Clear is a method of the LinkedList type. It is used to remove all elements from the list.
func (*LinkedList[T]) Copy ¶
func (list *LinkedList[T]) Copy() uc.Copier
Copy is a method of the LinkedList type. It is used to create a shallow copy of the list.
Returns:
- itf.Copier: A copy of the list.
func (*LinkedList[T]) CutNilValues ¶
func (list *LinkedList[T]) CutNilValues()
CutNilValues is a method of the LinkedList type. It is used to remove all nil values from the list.
func (*LinkedList[T]) DeleteFirst ¶
func (list *LinkedList[T]) DeleteFirst() (T, error)
DeleteFirst is a method of the LinkedList type. It is used to remove and return the first element in the list.
Panics with an error of type *ErrCallFailed if the list is empty.
Returns:
- T: The first element in the list.
func (*LinkedList[T]) DeleteLast ¶
func (list *LinkedList[T]) DeleteLast() (T, error)
DeleteLast is a method of the LinkedList type. It is used to remove and return the last element in the list.
Panics with an error of type *ErrCallFailed if the list is empty.
Returns:
- T: The last element in the list.
func (*LinkedList[T]) GoString ¶ added in v0.3.8
func (list *LinkedList[T]) GoString() string
GoString implements the fmt.GoStringer interface.
func (*LinkedList[T]) IsEmpty ¶
func (list *LinkedList[T]) IsEmpty() bool
IsEmpty is a method of the LinkedList type. It is used to check if the list is empty.
Returns:
- bool: A boolean value that is true if the list is empty, and false otherwise.
func (*LinkedList[T]) IsFull ¶
func (list *LinkedList[T]) IsFull() bool
IsFull is a method of the LinkedList type. It is used to check if the list is full.
Returns:
- isFull: A boolean value that is true if the list is full, and false otherwise.
func (*LinkedList[T]) Iterator ¶
func (list *LinkedList[T]) Iterator() itf.Iterater[T]
Iterator is a method of the LinkedList type. It is used to return an iterator for the list.
Returns:
- itf.Iterater[T]: An iterator for the list.
func (*LinkedList[T]) PeekFirst ¶
func (list *LinkedList[T]) PeekFirst() (T, error)
PeekFirst is a method of the LinkedList type. It is used to return the first element in the list without removing it.
Panics with an error of type *ErrCallFailed if the list is empty.
Returns:
- value: The first element in the list.
func (*LinkedList[T]) PeekLast ¶
func (list *LinkedList[T]) PeekLast() (T, error)
PeekLast is a method of the LinkedList type. It is used to return the last element in the list without removing it.
Panics with an error of type *ErrCallFailed if the list is empty.
Returns:
- value: The last element in the list.
func (*LinkedList[T]) Prepend ¶
func (list *LinkedList[T]) Prepend(value T) error
Prepend is a method of the LinkedList type. It is used to add an element to the end of the list.
Panics with an error of type *ErrInvalidOperation if the list is full.
Parameters:
- value: An element of type T to be added to the list.
func (*LinkedList[T]) Size ¶
func (list *LinkedList[T]) Size() int
Size is a method of the LinkedList type. It is used to return the current number of elements in the list.
Returns:
- int: An integer that represents the current number of elements in the list.
func (*LinkedList[T]) Slice ¶
func (list *LinkedList[T]) Slice() []T
Slice is a method of the LinkedList type that returns a slice of type T
Returns:
- []T: A slice of type T.
type ListNode ¶
type ListNode[T any] struct { // The Value stored in the node. Value T // contains filtered or unexported fields }
ListNode represents a node in a linked list. It holds a value of a generic type and a reference to the next node in the list.
func NewListNode ¶
NewListNode creates a new LinkedNode with the given value.
Parameters:
- value: The value to store in the node.
Returns:
- *ListNode: A pointer to the new node.
func (*ListNode[T]) Next ¶
Next returns the next node in the list.
Returns:
- *ListNode: The next node in the list.
func (*ListNode[T]) Prev ¶
Prev returns the previous node in the list.
Returns:
- *ListNode: The previous node in the list.
type ListSafeNode ¶
type ListSafeNode[T any] struct { // The Value stored in the node. Value T // contains filtered or unexported fields }
ListSafeNode represents a node in a linked list. It holds a value of a generic type and a reference to the next and previous nodes in the list.
func NewListSafeNode ¶
func NewListSafeNode[T any](value T) *ListSafeNode[T]
NewListSafeNode creates a new ListSafeNode with the given value.
Parameters:
- value: The value to store in the node.
Returns:
- *ListSafeNode: A pointer to the new node.
func (*ListSafeNode[T]) Next ¶
func (node *ListSafeNode[T]) Next() *ListSafeNode[T]
Next returns the next node in the list.
Returns:
- *ListSafeNode: The next node in the list.
func (*ListSafeNode[T]) Prev ¶
func (node *ListSafeNode[T]) Prev() *ListSafeNode[T]
Prev returns the previous node in the list.
Returns:
- *ListSafeNode: The previous node in the list.
func (*ListSafeNode[T]) SetNext ¶
func (node *ListSafeNode[T]) SetNext(next *ListSafeNode[T])
SetNext sets the next node in the list.
Parameters:
- next: The next node in the list.
func (*ListSafeNode[T]) SetPrev ¶
func (node *ListSafeNode[T]) SetPrev(prev *ListSafeNode[T])
SetPrev sets the previous node in the list.
Parameters:
- prev: The previous node in the list.
type Lister ¶
type Lister[T any] interface { // Append is a method that adds a value of type T to the end of the list. // // Parameters: // // - value: The value of type T to add to the list. // // Returns: // // - error: An error if the list is full. Append(value T) error // DeleteFirst is a method that deletes an element from the front of the list and // returns it. If the list is empty, it will panic. // // Returns: // // - T: The value of type T that was deleted. DeleteFirst() (T, error) // PeekFirst is a method that returns the value at the front of the list without // removing it. If the list is empty, it will panic. // // Returns: // // - T: The value of type T at the front of the list. PeekFirst() (T, error) // Prepend is a method that adds a value of type T to the end of the list. // // Parameters: // // - value: The value of type T to add to the list. // // Returns: // // - error: An error if the list is full. Prepend(value T) error // DeleteLast is a method that deletes an element from the end of the list and // returns it. If the list is empty, it will panic. // // Returns: // // - T: The value of type T that was deleted. DeleteLast() (T, error) // PeekLast is a method that returns the value at the end of the list without // removing it. If the list is empty, it will panic. // // Returns: // // - T: The value of type T at the end of the list. PeekLast() (T, error) ListLike.ListLike[T] }
Lister is an interface that defines methods for a list data structure.
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 ¶
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 ¶
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.
type SafeLister ¶
type SafeLister[T any] interface { // Append is a method that adds a value of type T to the end of the list. // // Parameters: // // - value: The value of type T to add to the list. // // Returns: // // - error: An error if the list is full. Append(value T) error // DeleteFirst is a method that deletes an element from the front of the list and // returns it. If the list is empty, it will panic. // // Returns: // // - T: The value of type T that was deleted. DeleteFirst() (T, error) // PeekFirst is a method that returns the value at the front of the list without // removing it. If the list is empty, it will panic. // // Returns: // // - T: The value of type T at the front of the list. PeekFirst() (T, error) // Prepend is a method that adds a value of type T to the end of the list. // // Parameters: // // - value: The value of type T to add to the list. // // Returns: // // - error: An error if the list is full. Prepend(value T) error // DeleteLast is a method that deletes an element from the end of the list and // returns it. If the list is empty, it will panic. // // Returns: // // - T: The value of type T that was deleted. DeleteLast() (T, error) // PeekLast is a method that returns the value at the end of the list without // removing it. If the list is empty, it will panic. // // Returns: // // - T: The value of type T at the end of the list. PeekLast() (T, error) ListLike.ListLike[T] }
Lister is an interface that defines methods for a list data structure.