collections

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

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)
}

type Iterator

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

func NewCoreIterator added in v0.7.0

func NewCoreIterator(
	valVar,
	keyVar string,
	values 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 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)

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)

Jump to

Keyboard shortcuts

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