Collections

package
v1.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2025 License: OSL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyMap

func CopyMap(m *map[any]bool) *map[any]bool

func GroupBy

func GroupBy[T any, R comparable, M ~map[R]List[T]](col Iterable[T], groupFunc func(item1 T) R) M

This was supposed to be a method, but due to limitations of Go generics we are forced to have it as function

Types

type Cloneable

type Cloneable[T any] interface {
	Clone() T
}

type Hashset

type Hashset[K any] struct {
	// contains filtered or unexported fields
}

func NewHashset

func NewHashset[K any]() *Hashset[K]

func NewHashsetFromIterable

func NewHashsetFromIterable[K any](items Iterable[K]) *Hashset[K]

func NewHashsetFromSlice

func NewHashsetFromSlice[K any](items *[]K) *Hashset[K]

func (*Hashset[K]) Add

func (this *Hashset[K]) Add(item K)

func (*Hashset[K]) Clear

func (this *Hashset[K]) Clear()

func (*Hashset[K]) Clone

func (this *Hashset[K]) Clone() *Hashset[K]

func (*Hashset[K]) Contains

func (this *Hashset[K]) Contains(key K) bool

func (*Hashset[K]) ExceptWith

func (this *Hashset[K]) ExceptWith(other *[]K)

func (*Hashset[K]) ExceptWithHS

func (this *Hashset[K]) ExceptWithHS(other *Hashset[K])

func (*Hashset[K]) GetSeq

func (this *Hashset[K]) GetSeq() iter.Seq[K]

func (*Hashset[K]) IntersectWith

func (this *Hashset[K]) IntersectWith(other *[]K)

func (*Hashset[K]) IntersectWithHS

func (this *Hashset[K]) IntersectWithHS(other *Hashset[K])

func (*Hashset[K]) Remove

func (this *Hashset[K]) Remove(item K)

func (*Hashset[K]) Size

func (this *Hashset[K]) Size() int

func (*Hashset[K]) ToList

func (this *Hashset[K]) ToList() List[K]

func (*Hashset[K]) UnionWith

func (this *Hashset[K]) UnionWith(other *[]K)

func (*Hashset[K]) UnionWithHS

func (this *Hashset[K]) UnionWithHS(other *Hashset[K])

type InternalList

type InternalList[T any] struct {
	// contains filtered or unexported fields
}

InternalList Internal structure. Do not use in your code directly.

type Iterable

type Iterable[T any] interface {
	GetSeq() iter.Seq[T]
}

type LinkedList

type LinkedList[T any] struct {
	// contains filtered or unexported fields
}

func NewLinkedList

func NewLinkedList[T any]() *LinkedList[T]

func NewLinkedListFromIterable

func NewLinkedListFromIterable[T any](items Iterable[T]) *LinkedList[T]

func NewLinkedListFromSlice

func NewLinkedListFromSlice[T any](items *[]T) *LinkedList[T]

func (*LinkedList[T]) AddAfter

func (this *LinkedList[T]) AddAfter(item T, after *LinkedListNode[T]) *LinkedListNode[T]

func (*LinkedList[T]) AddBefore

func (this *LinkedList[T]) AddBefore(item T, before *LinkedListNode[T]) *LinkedListNode[T]

func (*LinkedList[T]) AddFirst

func (this *LinkedList[T]) AddFirst(item T) *LinkedListNode[T]

func (*LinkedList[T]) AddLast

func (this *LinkedList[T]) AddLast(item T) *LinkedListNode[T]

func (*LinkedList[T]) Clone

func (this *LinkedList[T]) Clone() *LinkedList[T]

func (*LinkedList[T]) Find

func (this *LinkedList[T]) Find(chk func(a T) bool) *LinkedListNode[T]

func (*LinkedList[T]) First

func (this *LinkedList[T]) First() *LinkedListNode[T]

func (*LinkedList[K]) GetSeq

func (this *LinkedList[K]) GetSeq() iter.Seq[K]

func (*LinkedList[T]) Last

func (this *LinkedList[T]) Last() *LinkedListNode[T]

func (*LinkedList[T]) Remove

func (this *LinkedList[T]) Remove(eq func(a T, b T) bool, value T)

func (*LinkedList[T]) RemoveFirst

func (this *LinkedList[T]) RemoveFirst()

func (*LinkedList[T]) RemoveLast

func (this *LinkedList[T]) RemoveLast()

func (*LinkedList[T]) RemoveNode

func (this *LinkedList[T]) RemoveNode(node *LinkedListNode[T])

func (*LinkedList[T]) Size

func (this *LinkedList[T]) Size() int

type LinkedListNode

type LinkedListNode[T any] struct {
	// contains filtered or unexported fields
}

func (*LinkedListNode[T]) GetBefore

func (this *LinkedListNode[T]) GetBefore() *LinkedListNode[T]

func (*LinkedListNode[T]) GetNext

func (this *LinkedListNode[T]) GetNext() *LinkedListNode[T]

func (*LinkedListNode[T]) GetValue

func (this *LinkedListNode[T]) GetValue() T

type List

type List[T any] struct {
	// contains filtered or unexported fields
}

List is a wrapper, that provides number of common methods.

func NewList

func NewList[T any]() List[T]

New creates new instance of List.

func NewListFromIterable

func NewListFromIterable[T any](items Iterable[T]) List[T]

func NewListFromSlice

func NewListFromSlice[T any](items *[]T) List[T]

func NewListWSize

func NewListWSize[T any](size int) List[T]

New creates new instance of List.

func (List[T]) Add

func (list List[T]) Add(item T)

Add adds new item.

func (List[T]) AddRange

func (list List[T]) AddRange(items []T)

AddRange adds slice of items to the list

func (List[T]) AddSeq

func (list List[T]) AddSeq(seq iter.Seq[T])

Adds all items from iterable

func (List[T]) All

func (list List[T]) All(f func(item1 T) bool) bool

All iterates all elements of the list and checks if it satisfies condition specified in the function f

func (List[T]) Any

func (list List[T]) Any(cmpfunc func(item1 T) bool) bool

Any iterates all elements of the list and invokes a function until that function returns True for any element, then Any returns true, otherwise it returns False

func (List[T]) Clear

func (list List[T]) Clear()

Clear removes all items from the list

func (*List[T]) Clone

func (list *List[T]) Clone() *List[T]

Clone returns new instance of the list.

func (List[T]) First

func (list List[T]) First() T

First returns the first element.

func (List[T]) ForEach

func (list List[T]) ForEach(f func(item T))

ForEach iterates all elements of the list and invokes specified function f for each element in the list.

func (List[T]) ForEachIndexed

func (list List[T]) ForEachIndexed(f func(item T, index int))

ForEachIndexed iterates all elements of the list and invokes specified function f for each element in the list.

func (List[T]) Get

func (list List[T]) Get(index int) T

Get gets an item by index.

func (List[T]) GetRange

func (list List[T]) GetRange(index int, count int) List[T]

GetRange returns new list with elements specified by range.

func (*List[T]) GetSeq

func (list *List[T]) GetSeq() iter.Seq[T]

func (*List[T]) GetSeq2

func (list *List[T]) GetSeq2() iter.Seq2[T, int]

func (List[T]) IndexOf

func (list List[T]) IndexOf(f func(item T) bool) int

IndexOf finds first occurrence of an element in the list.

func (List[T]) IndexOfInRange

func (list List[T]) IndexOfInRange(f func(item T) bool, startIndex int, endIndex int) int

IndexOfInRange finds first occurrence of an element in the list in specified index range

func (List[T]) Insert

func (list List[T]) Insert(item T, index int)

Insert inserts an element at specified index.

func (List[T]) Last

func (list List[T]) Last() T

Last returns the last element.

func (*List[T]) Max

func (list *List[T]) Max(cmpfunc func(item1 T, item2 T) int) *T

func (*List[T]) Min

func (list *List[T]) Min(cmpfunc func(item1 T, item2 T) int) *T

func (List[T]) RemoveAt

func (list List[T]) RemoveAt(index int)

RemoveAt removes an element in the list

func (List[T]) RemoveRange

func (list List[T]) RemoveRange(index int, count int)

RemoveRange removes specified number of elements in the list starting from index.

func (List[T]) Set

func (list List[T]) Set(index int, value T)

Set sets an item to index.

func (List[T]) Size

func (list List[T]) Size() int

Size returns size of the list

func (List[T]) Sort

func (list List[T]) Sort(cmpfunc func(item1 T, item2 T) int)

Sort sorts all elements of the list

func (List[T]) ToSlice

func (list List[T]) ToSlice() []T

ToSlice returns a copy of the slice.

type Queue

type Queue[T any] struct {
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue[T any]() *Queue[T]

func NewQueueFromIterable

func NewQueueFromIterable[T any](items Iterable[T]) *Queue[T]

func NewQueueFromSlice

func NewQueueFromSlice[T any](items *[]T) *Queue[T]

func (*Queue[T]) Dequeue

func (this *Queue[T]) Dequeue() *T

func (*Queue[T]) Enqueue

func (this *Queue[T]) Enqueue(item T)

func (*Queue[T]) Peek

func (this *Queue[T]) Peek() *T

func (*Queue[T]) Size

func (this *Queue[T]) Size() int

type Stack

type Stack[T any] struct {
	// contains filtered or unexported fields
}

func NewStack

func NewStack[T any]() *Stack[T]

func NewStackFromIterable

func NewStackFromIterable[T any](items Iterable[T]) *Stack[T]

func NewStackFromSlice

func NewStackFromSlice[T any](items *[]T) *Stack[T]

func (*Stack[T]) Peek

func (this *Stack[T]) Peek() *T

func (*Stack[T]) Pop

func (this *Stack[T]) Pop() *T

func (*Stack[T]) Push

func (this *Stack[T]) Push(item T)

func (*Stack[T]) Size

func (this *Stack[T]) Size() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL