Documentation ¶
Index ¶
- type Array
- func (arr *Array[T]) Append(value T)
- func (arr *Array[T]) AppendMany(values ...T)
- func (arr *Array[T]) Capacity() int
- func (arr *Array[T]) Clear()
- func (arr *Array[T]) Clone() cols.Collection[T]
- func (arr *Array[T]) CollectionIterator() cols.Iterator[T]
- func (arr *Array[T]) FindIndex(predicate predication.Predicate[T]) (int, bool)
- func (arr *Array[T]) FindRef(predicate predication.Predicate[T]) (*T, bool)
- func (arr *Array[T]) Get(index int) T
- func (arr *Array[T]) GetRef(index int) *T
- func (arr *Array[T]) Insert(index int, value T)
- func (arr *Array[T]) InsertMany(index int, values ...T)
- func (arr *Array[T]) Iterator() iter.Iterator[T]
- func (arr *Array[T]) Join(other cols.Collection[T])
- func (arr *Array[T]) Prepend(value T)
- func (arr *Array[T]) PrependMany(values ...T)
- func (arr *Array[T]) RefsStream(yield func(*T) bool)
- func (arr *Array[T]) Remove(index int)
- func (arr *Array[T]) Reserve(additionalCapacity int)
- func (arr *Array[T]) Reverse()
- func (arr *Array[T]) Set(index int, value T)
- func (arr *Array[T]) Shrink()
- func (arr *Array[T]) Size() int
- func (arr *Array[T]) Slice() []T
- func (arr *Array[T]) SliceRange(from, to int) []T
- func (arr *Array[T]) Sort(comparator comparison.Comparator[T])
- func (arr *Array[T]) Stream(yield func(T) bool)
- type Iterator
- func (it *Iterator[T]) Get() T
- func (it *Iterator[T]) GetRef() *T
- func (it *Iterator[T]) Index() int
- func (it *Iterator[T]) InsertAfter(value T)
- func (it *Iterator[T]) InsertBefore(value T)
- func (it *Iterator[T]) Move()
- func (it *Iterator[T]) Remove()
- func (it *Iterator[T]) Set(value T)
- func (it *Iterator[T]) Valid() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Array ¶
type Array[T any] struct { // contains filtered or unexported fields }
Array is a collection that stores elements in a contiguous memory block. The zero value is ready to use. Do not copy a non-zero Array.
func NewFromIterable ¶ added in v1.6.1
NewFromIterable creates a new Array from the specified iter.Iterable.
func NewWithCapacity ¶
NewWithCapacity creates an empty Array with the specified initial capacity.
func NewWithSize ¶
NewWithSize creates an empty Array with the specified initial size.
func (*Array[T]) Append ¶
func (arr *Array[T]) Append(value T)
Append appends the specified element to the end of the Array.
func (*Array[T]) AppendMany ¶
func (arr *Array[T]) AppendMany(values ...T)
AppendMany appends the specified elements to the end of the Array.
func (*Array[T]) Capacity ¶
Capacity returns the number of elements that the Array can hold without reallocating.
func (*Array[T]) Clone ¶
func (arr *Array[T]) Clone() cols.Collection[T]
Clone returns a copy of the Array.
func (*Array[T]) CollectionIterator ¶
CollectionIterator returns an iterator over the elements in the Array.
func (*Array[T]) FindIndex ¶
func (arr *Array[T]) FindIndex(predicate predication.Predicate[T]) (int, bool)
FindIndex returns the index of the first element that matches the specified predicate.
func (*Array[T]) FindRef ¶
func (arr *Array[T]) FindRef(predicate predication.Predicate[T]) (*T, bool)
FindRef returns a reference to the first element that matches the specified predicate.
func (*Array[T]) Get ¶
Get returns the element at the specified index. Negative indices are interpreted as relative to the end of the Array. Panics if the index is out of bounds.
func (*Array[T]) GetRef ¶
GetRef returns a reference to the element at the specified index. Negative indices are interpreted as relative to the end of the Array. Panics if the index is out of bounds.
func (*Array[T]) Insert ¶
Insert inserts the specified element at the specified index. Negative indices are interpreted as relative to the end of the Array. Panics if the index is out of bounds.
func (*Array[T]) InsertMany ¶
InsertMany inserts the specified elements at the specified index. Negative indices are interpreted as relative to the end of the Array. Panics if the index is out of bounds.
func (*Array[T]) Join ¶
func (arr *Array[T]) Join(other cols.Collection[T])
Join appends all elements from the other collection to the Array. The other collection is cleared.
func (*Array[T]) Prepend ¶
func (arr *Array[T]) Prepend(value T)
Prepend inserts the specified element at the beginning of the Array.
func (*Array[T]) PrependMany ¶
func (arr *Array[T]) PrependMany(values ...T)
PrependMany inserts the specified elements at the beginning of the Array.
func (*Array[T]) RefsStream ¶
RefsStream streams references to the elements in the Array.
func (*Array[T]) Remove ¶
Remove removes the element at the specified index. Negative indices are interpreted as relative to the end of the Array. Panics if the index is out of bounds.
func (*Array[T]) Reserve ¶
Reserve reserves additional capacity for the Array. If additionalCapacity is negative, the function does nothing.
func (*Array[T]) Reverse ¶
func (arr *Array[T]) Reverse()
Reverse reverses the order of the elements in the Array.
func (*Array[T]) Set ¶
Set sets the element at the specified index. Negative indices are interpreted as relative to the end of the Array. Panics if the index is out of bounds.
func (*Array[T]) Shrink ¶
func (arr *Array[T]) Shrink()
Shrink shrinks the capacity of the Array to match its size.
func (*Array[T]) Slice ¶
func (arr *Array[T]) Slice() []T
Slice returns a slice of elements in the Array.
func (*Array[T]) SliceRange ¶
SliceRange returns a slice of elements in the Array in the specified range.
func (*Array[T]) Sort ¶
func (arr *Array[T]) Sort(comparator comparison.Comparator[T])
Sort sorts the elements in the Array by the specified comparator. The sorting algorithm is stable.
type Iterator ¶
type Iterator[T any] struct { // contains filtered or unexported fields }
Iterator is an iterator over an Array.
func (*Iterator[T]) GetRef ¶
func (it *Iterator[T]) GetRef() *T
GetRef returns a reference to the current element.
func (*Iterator[T]) InsertAfter ¶
func (it *Iterator[T]) InsertAfter(value T)
InsertAfter inserts the specified element after the current element. Iterator keeps pointing to the current element.
func (*Iterator[T]) InsertBefore ¶
func (it *Iterator[T]) InsertBefore(value T)
InsertBefore inserts the specified element before the current element. Iterator then points to the inserted element.
func (*Iterator[T]) Move ¶
func (it *Iterator[T]) Move()
Move moves the iterator to the next element.