Documentation
¶
Index ¶
- type ArrayList
- func (l *ArrayList[T]) Add(e T) bool
- func (l *ArrayList[T]) AddAll(c ...T) bool
- func (l *ArrayList[T]) AddAtIndex(i int, e T)
- func (l *ArrayList[T]) Clear()
- func (l *ArrayList[T]) Clone() collection.List[T]
- func (l *ArrayList[T]) Contains(e T) bool
- func (l *ArrayList[T]) ContainsAll(c ...T) bool
- func (l *ArrayList[T]) Equals(o any) bool
- func (l *ArrayList[T]) ForEach(handler func(e T) error) error
- func (l *ArrayList[T]) Get(i int) T
- func (l *ArrayList[T]) IndexOf(e T) int
- func (l *ArrayList[T]) IsEmpty() bool
- func (l *ArrayList[T]) Iter() iter.Seq[T]
- func (l *ArrayList[T]) LastIndexOf(e T) int
- func (l *ArrayList[T]) MarshalJSON() ([]byte, error)
- func (l *ArrayList[T]) Remove(e T) bool
- func (l *ArrayList[T]) RemoveAll(c ...T) bool
- func (l *ArrayList[T]) RemoveAtIndex(i int) T
- func (l *ArrayList[T]) RemoveIf(f func(T) bool) bool
- func (l *ArrayList[T]) RetainAll(c ...T) bool
- func (l *ArrayList[T]) Set(i int, e T) T
- func (l *ArrayList[T]) Size() int
- func (l *ArrayList[T]) String() string
- func (l *ArrayList[T]) ToSlice() []T
- func (l *ArrayList[T]) UnmarshalJSON(b []byte) error
- type CopyOnWriteArrayList
- func (l *CopyOnWriteArrayList[T]) Add(e T) bool
- func (l *CopyOnWriteArrayList[T]) AddAll(c ...T) bool
- func (l *CopyOnWriteArrayList[T]) AddAtIndex(i int, e T)
- func (l *CopyOnWriteArrayList[T]) Clear()
- func (l *CopyOnWriteArrayList[T]) Clone() collection.List[T]
- func (l *CopyOnWriteArrayList[T]) Contains(e T) bool
- func (l *CopyOnWriteArrayList[T]) ContainsAll(c ...T) bool
- func (l *CopyOnWriteArrayList[T]) Equals(o any) bool
- func (l *CopyOnWriteArrayList[T]) ForEach(handler func(T) error) error
- func (l *CopyOnWriteArrayList[T]) Get(i int) T
- func (l *CopyOnWriteArrayList[T]) IndexOf(e T) int
- func (l *CopyOnWriteArrayList[T]) IsEmpty() bool
- func (l *CopyOnWriteArrayList[T]) Iter() iter.Seq[T]
- func (l *CopyOnWriteArrayList[T]) LastIndexOf(e T) int
- func (l *CopyOnWriteArrayList[T]) MarshalJSON() ([]byte, error)
- func (l *CopyOnWriteArrayList[T]) Remove(e T) bool
- func (l *CopyOnWriteArrayList[T]) RemoveAll(c ...T) bool
- func (l *CopyOnWriteArrayList[T]) RemoveAtIndex(i int) T
- func (l *CopyOnWriteArrayList[T]) RemoveIf(f func(T) bool) bool
- func (l *CopyOnWriteArrayList[T]) RetainAll(c ...T) bool
- func (l *CopyOnWriteArrayList[T]) Set(i int, e T) T
- func (l *CopyOnWriteArrayList[T]) Size() int
- func (l *CopyOnWriteArrayList[T]) String() string
- func (l *CopyOnWriteArrayList[T]) ToSlice() []T
- func (l *CopyOnWriteArrayList[T]) UnmarshalJSON(b []byte) error
- type LinkedList
- func (l *LinkedList[T]) Add(e T) bool
- func (l *LinkedList[T]) AddAll(c ...T) bool
- func (l *LinkedList[T]) AddAtIndex(i int, e T)
- func (l *LinkedList[T]) Clear()
- func (l *LinkedList[T]) Clone() collection.List[T]
- func (l *LinkedList[T]) Contains(e T) bool
- func (l *LinkedList[T]) ContainsAll(c ...T) bool
- func (l *LinkedList[T]) Equals(o any) bool
- func (l *LinkedList[T]) ForEach(handler func(e T) error) error
- func (l *LinkedList[T]) Get(i int) T
- func (l *LinkedList[T]) IndexOf(e T) int
- func (l *LinkedList[T]) IsEmpty() bool
- func (l *LinkedList[T]) Iter() iter.Seq[T]
- func (l *LinkedList[T]) LastIndexOf(e T) int
- func (l *LinkedList[T]) MarshalJSON() ([]byte, error)
- func (l *LinkedList[T]) Remove(e T) bool
- func (l *LinkedList[T]) RemoveAll(c ...T) bool
- func (l *LinkedList[T]) RemoveAtIndex(i int) T
- func (l *LinkedList[T]) RemoveIf(f func(T) bool) bool
- func (l *LinkedList[T]) RetainAll(c ...T) bool
- func (l *LinkedList[T]) Set(i int, e T) T
- func (l *LinkedList[T]) Size() int
- func (l *LinkedList[T]) String() string
- func (l *LinkedList[T]) ToSlice() []T
- func (l *LinkedList[T]) UnmarshalJSON(b []byte) error
- type LinkedListNode
- type Stack
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrayList ¶
type ArrayList[T any] []T
func NewArrayList ¶
NewArrayList creates and returns a new empty list.
func (*ArrayList[T]) AddAtIndex ¶
AddAtIndex inserts the specified element at the specified position in this list.
func (*ArrayList[T]) Clear ¶
func (l *ArrayList[T]) Clear()
Clear removes all of the elements from this list.
func (*ArrayList[T]) Clone ¶
func (l *ArrayList[T]) Clone() collection.List[T]
Clone returns a copy of this list.
func (*ArrayList[T]) ContainsAll ¶
ContainsAll returns true if this list contains all of the elements.
func (*ArrayList[T]) ForEach ¶ added in v0.4.1
ForEach performs the given handler for each element in this list until all elements have been processed or the handler returns an error.
func (*ArrayList[T]) IndexOf ¶
IndexOf returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
func (*ArrayList[T]) Iter ¶
Iter returns an iterator over the elements in this list in proper sequence.
func (*ArrayList[T]) LastIndexOf ¶
LastIndexOf returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
func (*ArrayList[T]) MarshalJSON ¶ added in v0.5.0
MarshalJSON marshals the list as a JSON array.
func (*ArrayList[T]) Remove ¶
Remove removes all occurrences of the specified element from this list, if it is present. Returns true if this list contained the specified element.
func (*ArrayList[T]) RemoveAll ¶
RemoveAll removes all occurrences of the specified elements from this list, if they are present. Returns true if this list contained any of the specified elements.
func (*ArrayList[T]) RemoveAtIndex ¶
RemoveAtIndex removes the element at the specified position in this list. Returns the element that was removed from the list.
func (*ArrayList[T]) RemoveIf ¶
RemoveIf removes all of the elements of this list that satisfy the given predicate. Returns true if any elements were removed.
func (*ArrayList[T]) RetainAll ¶
RetainAll retains only the elements in this list that are contained in the specified elements. In other words, removes from this list all of its elements that are not contained in the specified elements. Returns true if this list changed as a result of the call.
func (*ArrayList[T]) Set ¶
Set replaces the element at the specified position in this list with the specified element. Returns the element previously at the specified position. If the index is equal to the size of this list, the element is appended to the end of this list and a zero value is returned.
func (*ArrayList[T]) String ¶ added in v0.5.0
String returns the string representation of this collection.
func (*ArrayList[T]) ToSlice ¶
func (l *ArrayList[T]) ToSlice() []T
ToSlice returns a slice containing all of the elements in this list in proper sequence.
func (*ArrayList[T]) UnmarshalJSON ¶ added in v0.5.0
UnmarshalJSON unmarshals a JSON array into the list.
type CopyOnWriteArrayList ¶ added in v0.4.1
type CopyOnWriteArrayList[T any] struct { // contains filtered or unexported fields }
func NewCopyOnWriteArrayList ¶ added in v0.4.1
func NewCopyOnWriteArrayList[T any]() *CopyOnWriteArrayList[T]
func (*CopyOnWriteArrayList[T]) Add ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) Add(e T) bool
Add adds the specified element to this collection.
func (*CopyOnWriteArrayList[T]) AddAll ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) AddAll(c ...T) bool
AddAll adds all of the elements in the this collection.
func (*CopyOnWriteArrayList[T]) AddAtIndex ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) AddAtIndex(i int, e T)
AddAtIndex inserts the specified element to the specified position in this list.
func (*CopyOnWriteArrayList[T]) Clear ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) Clear()
Clear removes all of the elements from this collection.
func (*CopyOnWriteArrayList[T]) Clone ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) Clone() collection.List[T]
Clone returns a copy of this list.
func (*CopyOnWriteArrayList[T]) Contains ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) Contains(e T) bool
Contains returns true if this collection contains the specified element.
func (*CopyOnWriteArrayList[T]) ContainsAll ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) ContainsAll(c ...T) bool
ContainsAll returns true if this collection contains all of the elements in the specified collection.
func (*CopyOnWriteArrayList[T]) Equals ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) Equals(o any) bool
Equals compares this collection with the object pass from parameter.
func (*CopyOnWriteArrayList[T]) ForEach ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) ForEach(handler func(T) error) error
ForEach performs the given handler for each elements in the collection until all elements have been processed or the handler returns an error.
func (*CopyOnWriteArrayList[T]) Get ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) Get(i int) T
Get returns the element at the specified position in this list.
func (*CopyOnWriteArrayList[T]) IndexOf ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) IndexOf(e T) int
IndexOf returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
func (*CopyOnWriteArrayList[T]) IsEmpty ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) IsEmpty() bool
IsEmpty returns true if this collection contains no elements.
func (*CopyOnWriteArrayList[T]) Iter ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) Iter() iter.Seq[T]
Iter returns an iterator of all elements in this collection.
func (*CopyOnWriteArrayList[T]) LastIndexOf ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) LastIndexOf(e T) int
LastIndexOf returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
func (*CopyOnWriteArrayList[T]) MarshalJSON ¶ added in v0.5.0
func (l *CopyOnWriteArrayList[T]) MarshalJSON() ([]byte, error)
MarshalJSON marshals the copy-on-write list as a JSON array.
func (*CopyOnWriteArrayList[T]) Remove ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) Remove(e T) bool
Remove removes the specified element from this collection.
func (*CopyOnWriteArrayList[T]) RemoveAll ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) RemoveAll(c ...T) bool
RemoveAll removes all of the elements in the specified collection from this collection.
func (*CopyOnWriteArrayList[T]) RemoveAtIndex ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) RemoveAtIndex(i int) T
RemoveAtIndex removes the element at the specified position in this list.
func (*CopyOnWriteArrayList[T]) RemoveIf ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) RemoveIf(f func(T) bool) bool
RemoveIf removes all of the elements of this collection that satisfy the given predicate.
func (*CopyOnWriteArrayList[T]) RetainAll ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) RetainAll(c ...T) bool
RetainAll retains only the elements in this collection that are contained in the specified collection.
func (*CopyOnWriteArrayList[T]) Set ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) Set(i int, e T) T
Set replaces the element at the specified position in this list with the specified element.
func (*CopyOnWriteArrayList[T]) Size ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) Size() int
Size returns the number of elements in this collection.
func (*CopyOnWriteArrayList[T]) String ¶ added in v0.5.0
func (l *CopyOnWriteArrayList[T]) String() string
String returns the string representation of this collection.
func (*CopyOnWriteArrayList[T]) ToSlice ¶ added in v0.4.1
func (l *CopyOnWriteArrayList[T]) ToSlice() []T
ToSlice returns a slice containing all of the elements in this collection.
func (*CopyOnWriteArrayList[T]) UnmarshalJSON ¶ added in v0.5.0
func (l *CopyOnWriteArrayList[T]) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals a JSON array into the copy-on-write list.
type LinkedList ¶ added in v0.4.1
type LinkedList[T any] struct { // contains filtered or unexported fields }
LinkedList represents a doubly linked list.
func NewLinkedList ¶ added in v0.4.1
func NewLinkedList[T any]() *LinkedList[T]
NewLinkedList creates and returns a new empty linked list.
func (*LinkedList[T]) Add ¶ added in v0.4.1
func (l *LinkedList[T]) Add(e T) bool
Add adds the specified element to this collection.
func (*LinkedList[T]) AddAll ¶ added in v0.4.1
func (l *LinkedList[T]) AddAll(c ...T) bool
AddAll adds all of the elements in the this collection.
func (*LinkedList[T]) AddAtIndex ¶ added in v0.4.1
func (l *LinkedList[T]) AddAtIndex(i int, e T)
AddAtIndex inserts the specified element to the specified position in this list.
func (*LinkedList[T]) Clear ¶ added in v0.4.1
func (l *LinkedList[T]) Clear()
Clear removes all of the elements from this collection.
func (*LinkedList[T]) Clone ¶ added in v0.4.1
func (l *LinkedList[T]) Clone() collection.List[T]
Clone returns a copy of this list.
func (*LinkedList[T]) Contains ¶ added in v0.4.1
func (l *LinkedList[T]) Contains(e T) bool
Contains returns true if this collection contains the specified element.
func (*LinkedList[T]) ContainsAll ¶ added in v0.4.1
func (l *LinkedList[T]) ContainsAll(c ...T) bool
ContainsAll returns true if this collection contains all of the elements in the specified collection.
func (*LinkedList[T]) Equals ¶ added in v0.4.1
func (l *LinkedList[T]) Equals(o any) bool
Equals compares this collection with the object pass from parameter.
func (*LinkedList[T]) ForEach ¶ added in v0.4.1
func (l *LinkedList[T]) ForEach(handler func(e T) error) error
ForEach performs the given handler for each elements in the collection until all elements have been processed or the handler returns an error.
func (*LinkedList[T]) Get ¶ added in v0.4.1
func (l *LinkedList[T]) Get(i int) T
Get returns the element at the specified position in this list.
func (*LinkedList[T]) IndexOf ¶ added in v0.4.1
func (l *LinkedList[T]) IndexOf(e T) int
IndexOf returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
func (*LinkedList[T]) IsEmpty ¶ added in v0.4.1
func (l *LinkedList[T]) IsEmpty() bool
IsEmpty returns true if this collection contains no elements.
func (*LinkedList[T]) Iter ¶ added in v0.4.1
func (l *LinkedList[T]) Iter() iter.Seq[T]
Iter returns a channel of all elements in this collection.
func (*LinkedList[T]) LastIndexOf ¶ added in v0.4.1
func (l *LinkedList[T]) LastIndexOf(e T) int
LastIndexOf returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
func (*LinkedList[T]) MarshalJSON ¶ added in v0.5.0
func (l *LinkedList[T]) MarshalJSON() ([]byte, error)
MarshalJSON marshals the linked list as a JSON array.
func (*LinkedList[T]) Remove ¶ added in v0.4.1
func (l *LinkedList[T]) Remove(e T) bool
Remove removes the specified element from this collection.
func (*LinkedList[T]) RemoveAll ¶ added in v0.4.1
func (l *LinkedList[T]) RemoveAll(c ...T) bool
RemoveAll removes all of the elements in the specified collection from this collection.
func (*LinkedList[T]) RemoveAtIndex ¶ added in v0.4.1
func (l *LinkedList[T]) RemoveAtIndex(i int) T
RemoveAtIndex removes the element at the specified position in this list.
func (*LinkedList[T]) RemoveIf ¶ added in v0.4.1
func (l *LinkedList[T]) RemoveIf(f func(T) bool) bool
RemoveIf removes all of the elements of this collection that satisfy the given predicate.
func (*LinkedList[T]) RetainAll ¶ added in v0.4.1
func (l *LinkedList[T]) RetainAll(c ...T) bool
RetainAll retains only the elements in this collection that are contained in the specified collection.
func (*LinkedList[T]) Set ¶ added in v0.4.1
func (l *LinkedList[T]) Set(i int, e T) T
Set replaces the element at the specified position in this list with the specified element.
func (*LinkedList[T]) Size ¶ added in v0.4.1
func (l *LinkedList[T]) Size() int
Size returns the number of elements in this collection.
func (*LinkedList[T]) String ¶ added in v0.5.0
func (l *LinkedList[T]) String() string
String returns the string representation of this collection.
func (*LinkedList[T]) ToSlice ¶ added in v0.4.1
func (l *LinkedList[T]) ToSlice() []T
ToSlice returns a slice containing all of the elements in this collection.
func (*LinkedList[T]) UnmarshalJSON ¶ added in v0.5.0
func (l *LinkedList[T]) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals a JSON array into the linked list.
type LinkedListNode ¶ added in v0.4.1
type LinkedListNode[T any] struct { Value T Next *LinkedListNode[T] Prev *LinkedListNode[T] }
LinkedListNode represents a node in the linked list.
type Stack ¶ added in v0.5.0
Stack represents a stack data structure based on ArrayList.
func (*Stack[T]) Peek ¶ added in v0.5.0
func (s *Stack[T]) Peek() T
Peek returns the element at the top of this stack without removing it.