collection

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GroupBy

func GroupBy[K comparable, T any](ts []T, getKey func(t T) K) map[K][]T

Types

type ArrayList

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

func NewArrayList

func NewArrayList[T any](options ...ArrayListOption[T]) (*ArrayList[T], error)

func (*ArrayList[T]) Add

func (l *ArrayList[T]) Add(t ...T) error

func (*ArrayList[T]) Clear

func (l *ArrayList[T]) Clear()

func (*ArrayList[T]) Equals

func (l *ArrayList[T]) Equals(o *ArrayList[T]) bool

func (*ArrayList[T]) Get

func (l *ArrayList[T]) Get(i int) gocommon.Optional[T]

func (*ArrayList[T]) IsEmpty

func (l *ArrayList[T]) IsEmpty() bool

func (*ArrayList[T]) Remove

func (l *ArrayList[T]) Remove(index int) gocommon.Optional[T]

func (*ArrayList[T]) Size

func (l *ArrayList[T]) Size() int

func (*ArrayList[T]) Stream

func (l *ArrayList[T]) Stream() Stream[T]

func (*ArrayList[T]) ToArray

func (l *ArrayList[T]) ToArray() []T

type ArrayListOption

type ArrayListOption[T any] func(*ArrayList[T]) error

func ArrayListWithInitialCapacity

func ArrayListWithInitialCapacity[T any](capacity int) ArrayListOption[T]

func ArrayListWithLimit

func ArrayListWithLimit[T any](limit int) ArrayListOption[T]

func ArrayListWithSlice

func ArrayListWithSlice[T any](slice []T) ArrayListOption[T]

type Collection

type Collection[T any] interface {
	Add(t ...T) error
	Size() int
	IsEmpty() bool
	Clear()
	Stream() Stream[T]
}

type Error

type Error error
var (
	ErrorCollectionLimit Error = errors.New("collection limit reached. unable to add new element")
)

type FifoQueue

type FifoQueue[T any] LinkedList[T]

func NewFifoQueue

func NewFifoQueue[T any]() *FifoQueue[T]

func (*FifoQueue[T]) Add

func (q *FifoQueue[T]) Add(t ...T) error

func (*FifoQueue[T]) Clear

func (q *FifoQueue[T]) Clear()

func (*FifoQueue[T]) IsEmpty

func (q *FifoQueue[T]) IsEmpty() bool

func (*FifoQueue[T]) Peek

func (q *FifoQueue[T]) Peek() gocommon.Optional[T]

func (*FifoQueue[T]) Remove

func (q *FifoQueue[T]) Remove() gocommon.Optional[T]

func (*FifoQueue[T]) Size

func (q *FifoQueue[T]) Size() int

func (*FifoQueue[T]) Stream

func (q *FifoQueue[T]) Stream() Stream[T]

type LinkedList

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

func NewLinkedList

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

func (*LinkedList[T]) Add

func (l *LinkedList[T]) Add(t ...T) error

func (*LinkedList[T]) Clear

func (l *LinkedList[T]) Clear()

func (*LinkedList[T]) Get

func (l *LinkedList[T]) Get(index int) gocommon.Optional[T]

func (*LinkedList[T]) IsEmpty

func (l *LinkedList[T]) IsEmpty() bool

func (*LinkedList[T]) Peek

func (l *LinkedList[T]) Peek() gocommon.Optional[T]

func (*LinkedList[T]) Remove

func (l *LinkedList[T]) Remove(index int) gocommon.Optional[T]

func (*LinkedList[T]) Size

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

func (*LinkedList[T]) Stream

func (l *LinkedList[T]) Stream() Stream[T]

func (*LinkedList[T]) ToArray

func (l *LinkedList[T]) ToArray() []T

type List

type List[T any] interface {
	Collection[T]
	Remove(index int) gocommon.Optional[T]
	Get(index int) gocommon.Optional[T]
}

type Queue

type Queue[T any] interface {
	Collection[T]
	Remove() gocommon.Optional[T]
	Peek() gocommon.Optional[T]
}

type Set

type Set[T comparable] struct {
	// contains filtered or unexported fields
}

func (*Set[T]) Add

func (s *Set[T]) Add(t T) bool

func (*Set[T]) Contains

func (s *Set[T]) Contains(t T) bool

func (*Set[T]) Size

func (s *Set[T]) Size() int

func (*Set[T]) ToArray

func (s *Set[T]) ToArray() []T

type Stream

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

func FlatMap

func FlatMap[T any](input [][]T) Stream[T]

func Map

func Map[F, T any](fs []F, mapper func(f F) T) Stream[T]

func StreamOf

func StreamOf[T any](ts []T) Stream[T]

func (Stream[T]) AnyMatch

func (stream Stream[T]) AnyMatch(anyFunction func(t T) bool) bool

func (Stream[T]) Filter

func (stream Stream[T]) Filter(filter func(t T) bool) Stream[T]

func (Stream[T]) FindFirst

func (stream Stream[T]) FindFirst() gocommon.Optional[T]

func (Stream[T]) ForEach

func (stream Stream[T]) ForEach(forEach func(t T))

func (Stream[T]) NoneMatch

func (stream Stream[T]) NoneMatch(anyFunction func(t T) bool) bool

func (Stream[T]) Peek

func (stream Stream[T]) Peek(peekFunc func(t T)) Stream[T]

func (Stream[T]) Reduce

func (stream Stream[T]) Reduce(identity T, reduce func(a, b T) T) T

func (Stream[T]) Slice

func (stream Stream[T]) Slice() []T

func (Stream[T]) Sort

func (stream Stream[T]) Sort(sortFunction func(a, b T) bool) Stream[T]

func (Stream[T]) ToList

func (stream Stream[T]) ToList() List[T]

Jump to

Keyboard shortcuts

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