containers

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2016 License: BSD-2-Clause Imports: 1 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSortedValues

func GetSortedValues(container Container, comparator utils.Comparator) []interface{}

Returns sorted container's elements with respect to the passed comparator. Does not effect the ordering of elements within the container. Uses timsort.

Types

type Container

type Container interface {
	Empty() bool
	Size() int
	Clear()
	Values() []interface{}
}

type EnumerableWithIndex

type EnumerableWithIndex interface {
	// Calls the given function once for each element, passing that element's index and value.
	Each(func(index int, value interface{}))

	// Passes each element of the container to the given function and
	// returns true if the function ever returns true for any element.
	Any(func(index int, value interface{}) bool) bool

	// Passes each element of the container to the given function and
	// returns true if the function returns true for all elements.
	All(func(index int, value interface{}) bool) bool

	// Passes each element of the container to the given function and returns
	// the first (index,value) for which the function is true or -1,nil otherwise
	// if no element matches the criteria.
	Find(func(index int, value interface{}) bool) (int, interface{})
}

Enumerable functions for ordered containers whose values can be fetched by an index.

type EnumerableWithKey

type EnumerableWithKey interface {
	// Calls the given function once for each element, passing that element's key and value.
	Each(func(key interface{}, value interface{}))

	// Passes each element of the container to the given function and
	// returns true if the function ever returns true for any element.
	Any(func(key interface{}, value interface{}) bool) bool

	// Passes each element of the container to the given function and
	// returns true if the function returns true for all elements.
	All(func(key interface{}, value interface{}) bool) bool

	// Passes each element of the container to the given function and returns
	// the first (key,value) for which the function is true or nil,nil otherwise if no element
	// matches the criteria.
	Find(func(key interface{}, value interface{}) bool) (interface{}, interface{})
}

Enumerable functions for ordered containers whose values whose elements are key/value pairs.

type IteratorWithIndex

type IteratorWithIndex interface {
	// Moves the iterator to the next element and returns true if there was a next element in the container.
	// If Next() returns true, then next element's index and value can be retrieved by Index() and Value().
	// Modifies the state of the iterator.
	Next() bool
	// Returns the current element's value.
	// Does not modify the state of the iterator.
	Value() interface{}
	// Returns the current element's index.
	// Does not modify the state of the iterator.
	Index() int
}

Stateful iterator for ordered containers whose values can be fetched by an index.

type IteratorWithKey

type IteratorWithKey interface {
	// Moves the iterator to the next element and returns true if there was a next element in the container.
	// If Next() returns true, then next element's key and value can be retrieved by Key() and Value().
	// Modifies the state of the iterator.
	Next() bool
	// Returns the current element's value.
	// Does not modify the state of the iterator.
	Value() interface{}
	// Returns the current element's key.
	// Does not modify the state of the iterator.
	Key() interface{}
}

Stateful iterator for ordered containers whose elements are key value pairs.

Jump to

Keyboard shortcuts

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