Documentation ¶
Index ¶
- 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
- type Wrapper
- func (w *Wrapper[T]) Append(value T)
- func (w *Wrapper[T]) Clear()
- func (w *Wrapper[T]) Clone() cols.Collection[T]
- func (w *Wrapper[T]) CollectionIterator() cols.Iterator[T]
- func (w *Wrapper[T]) FindIndex(predicate predication.Predicate[T]) (int, bool)
- func (w *Wrapper[T]) FindRef(predicate predication.Predicate[T]) (*T, bool)
- func (w *Wrapper[T]) Get(index int) T
- func (w *Wrapper[T]) GetRef(index int) *T
- func (w *Wrapper[T]) Insert(index int, value T)
- func (w *Wrapper[T]) Iterator() iter.Iterator[T]
- func (w *Wrapper[T]) Join(other cols.Collection[T])
- func (w *Wrapper[T]) Prepend(value T)
- func (w *Wrapper[T]) RefsStream(yield func(*T) bool)
- func (w *Wrapper[T]) Remove(index int)
- func (w *Wrapper[T]) Reverse()
- func (w *Wrapper[T]) Set(index int, value T)
- func (w *Wrapper[T]) Size() int
- func (w *Wrapper[T]) Sort(comparator comparison.Comparator[T])
- func (w *Wrapper[T]) Stream(yield func(T) bool)
- func (w *Wrapper[T]) Transaction(updateFunction func(collection cols.Collection[T]))
- func (w *Wrapper[T]) Update(index int, updateFunction func(value T) T)
- func (w *Wrapper[T]) UpdateRef(index int, updateFunction func(value *T))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Iterator ¶
type Iterator[T any] struct { // contains filtered or unexported fields }
Iterator is a wrapper around a cols.Iterator that provides thread-safe access to the underlying collection.
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.
func (Iterator[T]) InsertBefore ¶
func (it Iterator[T]) InsertBefore(value T)
InsertBefore inserts the specified element before the current element.
type Wrapper ¶
type Wrapper[T any] struct { // contains filtered or unexported fields }
Wrapper is a wrapper around a cols.Collection that provides thread-safe access. Locking is done through read-write mutex. This means that multiple goroutines can read at the same time, but only one goroutine can write at the same time.
func From ¶
func From[T any](collection cols.Collection[T]) *Wrapper[T]
From creates a new Wrapper around the given cols.Collection.
func (*Wrapper[T]) Append ¶
func (w *Wrapper[T]) Append(value T)
Append appends the given value to the collection.
func (*Wrapper[T]) Clone ¶
func (w *Wrapper[T]) Clone() cols.Collection[T]
Clone returns a copy of a Wrapper with the new underlying collection that is also cloned.
func (*Wrapper[T]) CollectionIterator ¶
CollectionIterator returns a cols.Iterator over the elements.
func (*Wrapper[T]) FindIndex ¶
func (w *Wrapper[T]) FindIndex(predicate predication.Predicate[T]) (int, bool)
FindIndex returns the index of the first element that satisfies the given predicate. If no element satisfies the predicate, 0 and false are returned.
func (*Wrapper[T]) FindRef ¶
func (w *Wrapper[T]) FindRef(predicate predication.Predicate[T]) (*T, bool)
FindRef returns a reference to the first element that satisfies the given predicate. If no element satisfies the predicate, nil and false are returned. Lock will not be held while the reference is used, so it is possible that the value of the element changes while the reference is used.
func (*Wrapper[T]) GetRef ¶
GetRef returns a reference to the element at the given index. Usage of this method is discouraged, as it breaks the thread-safety. Lock will not be held while the reference is used, so it is possible that the value of the element changes while the reference is used.
func (*Wrapper[T]) Join ¶
func (w *Wrapper[T]) Join(other cols.Collection[T])
Join joins the collection with the given collection.
func (*Wrapper[T]) Prepend ¶
func (w *Wrapper[T]) Prepend(value T)
Prepend prepends the given value to the collection.
func (*Wrapper[T]) RefsStream ¶
RefsStream streams the references to the elements of the collection.
func (*Wrapper[T]) Sort ¶
func (w *Wrapper[T]) Sort(comparator comparison.Comparator[T])
Sort sorts the elements using the given comparator.
func (*Wrapper[T]) Transaction ¶
func (w *Wrapper[T]) Transaction(updateFunction func(collection cols.Collection[T]))
Transaction executes the given function with the cols.Collection as an argument. Wrapped cols.Collection will be locked for writing while the function is executed.