collections

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: Apache-2.0 Imports: 5 Imported by: 20

Documentation

Index

Constants

View Source
const (
	DefaultValueVar = "value"
	DefaultKeyVar   = "key"
)

Variables

This section is empty.

Functions

func ForEach added in v0.13.0

func ForEach(ctx context.Context, scope *core.Scope, iter Iterator, predicate func(ctx context.Context, scope *core.Scope) bool) error

func IsValidSortDirection

func IsValidSortDirection(direction SortDirection) bool

func ToSlice

func ToSlice(ctx context.Context, scope *core.Scope, iterator Iterator) ([]*core.Scope, error)

Types

type Comparator

type Comparator func(ctx context.Context, first, second *core.Scope) (int64, error)

type FilterIterator

type FilterIterator struct {
	// contains filtered or unexported fields
}

func NewFilterIterator

func NewFilterIterator(values Iterator, predicate FilterPredicate) (*FilterIterator, error)

func (*FilterIterator) Next

func (iterator *FilterIterator) Next(ctx context.Context, scope *core.Scope) (*core.Scope, error)

type FilterPredicate

type FilterPredicate func(ctx context.Context, scope *core.Scope) (bool, error)

type IndexedCollection added in v0.4.0

type IndexedCollection interface {
	core.Value
	Measurable
	Get(idx values.Int) core.Value
	Set(idx values.Int, value core.Value) error
}

type IndexedIterator added in v0.4.0

type IndexedIterator struct {
	// contains filtered or unexported fields
}

func (*IndexedIterator) Next added in v0.4.0

func (iterator *IndexedIterator) Next(_ context.Context, scope *core.Scope) (*core.Scope, error)

type Iterable

type Iterable interface {
	Iterate(ctx context.Context, scope *core.Scope) (Iterator, error)
}

func AsIterable added in v0.16.0

func AsIterable(fn func(ctx context.Context, scope *core.Scope) (Iterator, error)) Iterable

func FromCoreIterable added in v0.16.0

func FromCoreIterable(valVar, keyVar string, iterable core.Iterable) (Iterable, error)

type IterableFn added in v0.16.0

type IterableFn struct {
	// contains filtered or unexported fields
}

func (*IterableFn) Iterate added in v0.16.0

func (i *IterableFn) Iterate(ctx context.Context, scope *core.Scope) (Iterator, error)

type Iterator

type Iterator interface {
	Next(ctx context.Context, scope *core.Scope) (*core.Scope, error)
}

func AsIterator added in v0.16.0

func AsIterator(fn func(ctx context.Context, scope *core.Scope) (*core.Scope, error)) Iterator

func FromCoreIterator added in v0.16.0

func FromCoreIterator(valVar, keyVar string, iterator core.Iterator) (Iterator, error)

func NewDefaultIndexedIterator added in v0.4.0

func NewDefaultIndexedIterator(
	values IndexedCollection,
) (Iterator, error)

func NewDefaultKeyedIterator added in v0.4.0

func NewDefaultKeyedIterator(input KeyedCollection) (Iterator, error)

func NewDefaultMapIterator added in v0.4.0

func NewDefaultMapIterator(values map[string]core.Value) (Iterator, error)

func NewDefaultSliceIterator added in v0.4.0

func NewDefaultSliceIterator(input []core.Value) (Iterator, error)

func NewDefaultWhileIterator added in v0.13.0

func NewDefaultWhileIterator(mode WhileMode, predicate WhilePredicate) (Iterator, error)

func NewIndexedIterator added in v0.4.0

func NewIndexedIterator(
	valVar,
	keyVar string,
	values IndexedCollection,
) (Iterator, error)

func NewKeyedIterator added in v0.4.0

func NewKeyedIterator(
	valVar,
	keyVar string,
	values KeyedCollection,
) (Iterator, error)

func NewMapIterator

func NewMapIterator(
	valVar,
	keyVar string,
	values map[string]core.Value,
) (Iterator, error)

func NewSliceIterator

func NewSliceIterator(
	valVar,
	keyVar string,
	values []core.Value,
) (Iterator, error)

func NewTapIterator added in v0.5.0

func NewTapIterator(values Iterator, predicate core.Expression) (Iterator, error)

func NewWhileIterator added in v0.13.0

func NewWhileIterator(
	mode WhileMode,
	valVar string,
	predicate WhilePredicate,
) (Iterator, error)

type IteratorFn added in v0.16.0

type IteratorFn struct {
	// contains filtered or unexported fields
}

func (*IteratorFn) Next added in v0.16.0

func (i *IteratorFn) Next(ctx context.Context, scope *core.Scope) (*core.Scope, error)

type KeyedCollection added in v0.4.0

type KeyedCollection interface {
	core.Value
	Measurable
	Keys() []values.String
	Get(key values.String) (core.Value, values.Boolean)
	Set(key values.String, value core.Value)
}

type KeyedIterator added in v0.4.0

type KeyedIterator struct {
	// contains filtered or unexported fields
}

func (*KeyedIterator) Next added in v0.4.0

func (iterator *KeyedIterator) Next(_ context.Context, scope *core.Scope) (*core.Scope, error)

type LimitIterator

type LimitIterator struct {
	// contains filtered or unexported fields
}

func NewLimitIterator

func NewLimitIterator(values Iterator, count, offset int) (*LimitIterator, error)

func (*LimitIterator) Next

func (iterator *LimitIterator) Next(ctx context.Context, scope *core.Scope) (*core.Scope, error)

type MapIterator

type MapIterator struct {
	// contains filtered or unexported fields
}

func (*MapIterator) Next

func (iterator *MapIterator) Next(_ context.Context, scope *core.Scope) (*core.Scope, error)

type Measurable added in v0.7.0

type Measurable interface {
	Length() values.Int
}

Measurable represents an interface of a value that can has length.

type SliceIterator

type SliceIterator struct {
	// contains filtered or unexported fields
}

func (*SliceIterator) Next

func (iterator *SliceIterator) Next(_ context.Context, scope *core.Scope) (*core.Scope, error)

type SortDirection

type SortDirection int
const (
	SortDirectionAsc  SortDirection = 1
	SortDirectionDesc SortDirection = -1
)

func SortDirectionFromString

func SortDirectionFromString(str string) SortDirection

type SortIterator

type SortIterator struct {
	// contains filtered or unexported fields
}

func NewSortIterator

func NewSortIterator(
	values Iterator,
	comparators ...*Sorter,
) (*SortIterator, error)

func (*SortIterator) Next

func (iterator *SortIterator) Next(ctx context.Context, scope *core.Scope) (*core.Scope, error)

type Sorter

type Sorter struct {
	// contains filtered or unexported fields
}

func NewSorter

func NewSorter(fn Comparator, direction SortDirection) (*Sorter, error)

type TapIterator added in v0.5.0

type TapIterator struct {
	// contains filtered or unexported fields
}

func (*TapIterator) Next added in v0.5.0

func (iterator *TapIterator) Next(ctx context.Context, scope *core.Scope) (*core.Scope, error)

type UniqueIterator

type UniqueIterator struct {
	// contains filtered or unexported fields
}

func NewUniqueIterator

func NewUniqueIterator(values Iterator, hashKey string) (*UniqueIterator, error)

func (*UniqueIterator) Next

func (iterator *UniqueIterator) Next(ctx context.Context, scope *core.Scope) (*core.Scope, error)

type WhileIterator added in v0.13.0

type WhileIterator struct {
	// contains filtered or unexported fields
}

func (*WhileIterator) Next added in v0.13.0

func (iterator *WhileIterator) Next(ctx context.Context, scope *core.Scope) (*core.Scope, error)

type WhileMode added in v0.13.0

type WhileMode int
var (
	WhileModePost WhileMode
	WhileModePre  WhileMode = 1
)

type WhilePredicate added in v0.13.0

type WhilePredicate func(ctx context.Context, scope *core.Scope) (bool, error)

Jump to

Keyboard shortcuts

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