Documentation ¶
Index ¶
- func Swap[T any](list List[T], i, j int)
- type ArrayList
- func (a *ArrayList[T]) Add(elems ...T)
- func (a *ArrayList[T]) Clear()
- func (a *ArrayList[T]) Clone() List[T]
- func (a *ArrayList[T]) Contains(elem T, equal containers.Equal[T]) bool
- func (a *ArrayList[T]) Get(i int) (_ T, _ bool)
- func (a *ArrayList[T]) IndexOf(elem T, equal containers.Equal[T]) int
- func (a *ArrayList[T]) Insert(i int, elem ...T)
- func (a *ArrayList[T]) Iterator() containers.IndexIterator[T]
- func (a *ArrayList[T]) Join(list List[T])
- func (a *ArrayList[T]) Remove(i int)
- func (a *ArrayList[T]) RemoveElem(elem T, equal containers.Equal[T])
- func (a *ArrayList[T]) Set(i int, elem T)
- func (a *ArrayList[T]) Size() int
- func (a *ArrayList[T]) String() string
- func (a *ArrayList[T]) Values() (_ []T)
- type Iterator
- type LinkedList
- func (l *LinkedList[T]) Add(elems ...T)
- func (l *LinkedList[T]) Clear()
- func (l *LinkedList[T]) Clone() List[T]
- func (l *LinkedList[T]) Contains(elem T, equal containers.Equal[T]) bool
- func (l *LinkedList[T]) Get(i int) (val T, found bool)
- func (l *LinkedList[T]) IndexOf(elem T, equal containers.Equal[T]) int
- func (l *LinkedList[T]) Insert(i int, elems ...T)
- func (l *LinkedList[T]) Iterator() containers.IndexIterator[T]
- func (l *LinkedList[T]) Join(list List[T])
- func (l *LinkedList[T]) Remove(i int)
- func (l *LinkedList[T]) RemoveElem(elem T, equal containers.Equal[T])
- func (l *LinkedList[T]) Set(i int, elem T)
- func (l *LinkedList[T]) Size() int
- func (l *LinkedList[T]) String() string
- func (l *LinkedList[T]) Values() []T
- type List
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ArrayList ¶
type ArrayList[T any] struct { // contains filtered or unexported fields }
func NewArrayList ¶
NewArrayList returns a new ArrayList with the given capacity
func (*ArrayList[T]) Contains ¶
func (a *ArrayList[T]) Contains(elem T, equal containers.Equal[T]) bool
func (*ArrayList[T]) IndexOf ¶
func (a *ArrayList[T]) IndexOf(elem T, equal containers.Equal[T]) int
func (*ArrayList[T]) Iterator ¶
func (a *ArrayList[T]) Iterator() containers.IndexIterator[T]
func (*ArrayList[T]) RemoveElem ¶
func (a *ArrayList[T]) RemoveElem(elem T, equal containers.Equal[T])
type Iterator ¶
type Iterator[T any] struct { // contains filtered or unexported fields }
Iterator returns a basic list iterator
type LinkedList ¶ added in v0.0.3
type LinkedList[T any] struct { // contains filtered or unexported fields }
LinkedList implements the list interface by linked nodes which is more efficient to insert and remove nodes.
func NewLinkedList ¶ added in v0.0.3
func NewLinkedList[T any]() *LinkedList[T]
func (*LinkedList[T]) Add ¶ added in v0.0.3
func (l *LinkedList[T]) Add(elems ...T)
func (*LinkedList[T]) Clear ¶ added in v0.0.3
func (l *LinkedList[T]) Clear()
func (*LinkedList[T]) Clone ¶ added in v0.0.3
func (l *LinkedList[T]) Clone() List[T]
func (*LinkedList[T]) Contains ¶ added in v0.0.3
func (l *LinkedList[T]) Contains(elem T, equal containers.Equal[T]) bool
func (*LinkedList[T]) Get ¶ added in v0.0.3
func (l *LinkedList[T]) Get(i int) (val T, found bool)
func (*LinkedList[T]) IndexOf ¶ added in v0.0.3
func (l *LinkedList[T]) IndexOf(elem T, equal containers.Equal[T]) int
func (*LinkedList[T]) Insert ¶ added in v0.0.3
func (l *LinkedList[T]) Insert(i int, elems ...T)
func (*LinkedList[T]) Iterator ¶ added in v0.0.3
func (l *LinkedList[T]) Iterator() containers.IndexIterator[T]
func (*LinkedList[T]) Join ¶ added in v0.0.3
func (l *LinkedList[T]) Join(list List[T])
func (*LinkedList[T]) Remove ¶ added in v0.0.3
func (l *LinkedList[T]) Remove(i int)
func (*LinkedList[T]) RemoveElem ¶ added in v0.0.3
func (l *LinkedList[T]) RemoveElem(elem T, equal containers.Equal[T])
func (*LinkedList[T]) Set ¶ added in v0.0.3
func (l *LinkedList[T]) Set(i int, elem T)
func (*LinkedList[T]) Size ¶ added in v0.0.3
func (l *LinkedList[T]) Size() int
func (*LinkedList[T]) String ¶ added in v0.0.3
func (l *LinkedList[T]) String() string
func (*LinkedList[T]) Values ¶ added in v0.0.3
func (l *LinkedList[T]) Values() []T
type List ¶
type List[T any] interface { // Get returns the elem at the given index Get(i int) (T, bool) // IndexOf returns the index of first element that matches the given element. if not found, return -1 IndexOf(elem T, equal containers.Equal[T]) int // Set replaces the elem at the given index Set(i int, elem T) // Add appends the given element to the end of the list Add(elem ...T) // Insert inserts the given elems into the list at the given index Insert(i int, elem ...T) // Remove removes the elem match given index from the list Remove(i int) // RemoveElem removes the first element matches the given from the list, RemoveElem(elem T, equal containers.Equal[T]) // Contains check if list contains the given elements Contains(elem T, equal containers.Equal[T]) bool // Clone returns a value-copy of the original list, not the deep-copy list Clone() List[T] // Join joins the given list into the original list Join(list List[T]) containers.IndexIterable[T] containers.Container[T] }
List is the base interface of all lists
Click to show internal directories.
Click to hide internal directories.