collection

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2021 License: MIT Imports: 8 Imported by: 3

README

collection

GoDoc Build Status Issues

A suite of general-purpose collections for Go.

This consists of regular types generated automatically from templates using Runtemplate v3.

Three categories of collections are provided:

  • simple lists, sets & maps - these are wrappers around the equivalent built-in Go language features
  • shared lists, sets & maps - these all use structs that have mutex locking for each method
  • immutable lists, sets & maps - these all have structs containing the data but do not have any mutation methods.

Currently, the following built-in types are supported:

  • string
  • int
  • uint
  • int64
  • uint64

Tests

Note that extensive tests are present in the [code generator](https://github.com/rickb777/runtemplate/tree/master/v3 /builtintest). Because all the Go source files here are auto-generated, no additional tests are needed here.

Documentation

Overview

package collection provides lightweight collection types for core Go built-in types. These are not safe for sharing across multiple goroutines.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnyCollection added in v0.4.0

type AnyCollection interface {
	AnySizer
	AnyMkStringer

	// IsSequence returns true for lists and queues.
	IsSequence() bool

	// IsSet returns false for lists and queues.
	IsSet() bool

	// ToSlice returns a shallow copy as a plain slice.
	ToSlice() []interface{}

	// ToInterfaceSlice returns a shallow copy as a slice of arbitrary type.
	ToInterfaceSlice() []interface{}

	// Exists verifies that one or more elements of AnyCollection return true for the predicate p.
	Exists(p func(interface{}) bool) bool

	// Forall verifies that all elements of AnyCollection return true for the predicate p.
	Forall(p func(interface{}) bool) bool

	// Foreach iterates over AnyCollection and executes the function f against each element.
	Foreach(f func(interface{}))

	// Find returns the first interface{} that returns true for the predicate p.
	// False is returned if none match.
	Find(p func(interface{}) bool) (interface{}, bool)

	// Send returns a channel that will send all the elements in order. Can be used with the plumbing code, for example.
	// A goroutine is created to send the elements; this only terminates when all the elements have been consumed
	Send() <-chan interface{}

	// CountBy gives the number elements of AnyCollection that return true for the predicate p.
	CountBy(p func(interface{}) bool) int

	// Contains determines whether a given item is already in the collection, returning true if so.
	Contains(v interface{}) bool

	// ContainsAll determines whether the given items are all in the collection, returning true if so.
	ContainsAll(v ...interface{}) bool

	// MinBy returns an element of AnyCollection containing the minimum value, when compared to other elements
	// using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such
	// element is returned. Panics if there are no elements.
	MinBy(less func(interface{}, interface{}) bool) interface{}

	// MaxBy returns an element of AnyCollection containing the maximum value, when compared to other elements
	// using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such
	// element is returned. Panics if there are no elements.
	MaxBy(less func(interface{}, interface{}) bool) interface{}

	// Fold aggregates all the values in the collection using a supplied function, starting from some initial value.
	Fold(initial interface{}, fn func(interface{}, interface{}) interface{}) interface{}
}

AnyCollection defines an interface for common collection methods on interface{}.

type AnyList added in v0.4.0

type AnyList []interface{}

AnyList is a slice of type interface{}. Use it where you would use []interface{}. To add items to the list, simply use the normal built-in append function.

List values follow a similar pattern to Scala Lists and LinearSeqs in particular. For comparison with Scala, see e.g. http://www.scala-lang.org/api/2.11.7/#scala.collection.LinearSeq

func BuildAnyListFromChan added in v0.4.0

func BuildAnyListFromChan(source <-chan interface{}) AnyList

BuildAnyListFromChan constructs a new AnyList from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func ConvertAnyList added in v0.4.0

func ConvertAnyList(values ...interface{}) (AnyList, bool)

ConvertAnyList constructs a new list containing the supplied values, if any. The returned boolean will be false if any of the values could not be converted correctly. The returned list will contain all the values that were correctly converted.

func MakeAnyList added in v0.4.0

func MakeAnyList(length, capacity int) AnyList

MakeAnyList makes an empty list with both length and capacity initialised.

func NewAnyList added in v0.4.0

func NewAnyList(values ...interface{}) AnyList

NewAnyList constructs a new list containing the supplied values, if any.

func (AnyList) Clone added in v0.4.0

func (list AnyList) Clone() AnyList

Clone returns a shallow copy of the list. It does not clone the underlying elements.

func (AnyList) Contains added in v0.6.0

func (list AnyList) Contains(v interface{}) bool

Contains determines whether a given item is already in the list, returning true if so.

func (AnyList) ContainsAll added in v0.6.0

func (list AnyList) ContainsAll(i ...interface{}) bool

ContainsAll determines whether the given items are all in the list, returning true if so. This is potentially a slow method and should only be used rarely.

func (AnyList) CountBy added in v0.4.0

func (list AnyList) CountBy(p func(interface{}) bool) (result int)

CountBy gives the number elements of AnyList that return true for the predicate p.

func (AnyList) DistinctBy added in v0.4.0

func (list AnyList) DistinctBy(equal func(interface{}, interface{}) bool) AnyList

DistinctBy returns a new AnyList whose elements are unique, where equality is defined by the equal function.

func (AnyList) DoReverse added in v0.4.0

func (list AnyList) DoReverse() AnyList

DoReverse alters a AnyList with all elements in the reverse order. Unlike Reverse, it does not allocate new memory.

The list is modified and the modified list is returned.

func (AnyList) DoShuffle added in v0.4.0

func (list AnyList) DoShuffle() AnyList

DoShuffle returns a shuffled AnyList, using a version of the Fisher-Yates shuffle.

The list is modified and the modified list is returned.

func (AnyList) Drop added in v0.4.0

func (list AnyList) Drop(n int) AnyList

Drop returns a slice of AnyList without the leading n elements of the source list. If n is greater than or equal to the size of the list, an empty list is returned.

The original list is not modified.

func (AnyList) DropLast added in v0.4.0

func (list AnyList) DropLast(n int) AnyList

DropLast returns a slice of AnyList without the trailing n elements of the source list. If n is greater than or equal to the size of the list, an empty list is returned.

The original list is not modified.

func (AnyList) DropWhile added in v0.4.0

func (list AnyList) DropWhile(p func(interface{}) bool) AnyList

DropWhile returns a new AnyList containing the trailing elements of the source list. Whilst the predicate p returns true, elements are excluded from the result. Once predicate p returns false, all remaining elements are added.

The original list is not modified.

func (AnyList) Equals added in v0.6.0

func (list AnyList) Equals(other AnyList) bool

Equals determines if two lists are equal to each other. If they both are the same size and have the same items in the same order, they are considered equal. Order of items is not relevent for sets to be equal.

func (AnyList) Exists added in v0.4.0

func (list AnyList) Exists(p func(interface{}) bool) bool

Exists verifies that one or more elements of AnyList return true for the predicate p.

func (AnyList) Filter added in v0.4.0

func (list AnyList) Filter(p func(interface{}) bool) AnyList

Filter returns a new AnyList whose elements return true for predicate p.

The original list is not modified.

func (AnyList) Find added in v0.4.0

func (list AnyList) Find(p func(interface{}) bool) (interface{}, bool)

Find returns the first interface{} that returns true for predicate p. False is returned if none match.

func (AnyList) FlatMap added in v0.4.0

func (list AnyList) FlatMap(f func(interface{}) []interface{}) AnyList

FlatMap returns a new AnyList by transforming every element with function f that returns zero or more items in a slice. The resulting list may have a different size to the original list. The original list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (AnyList) Fold added in v0.9.0

func (list AnyList) Fold(initial interface{}, fn func(interface{}, interface{}) interface{}) interface{}

Fold aggregates all the values in the list using a supplied function, starting from some initial value.

func (AnyList) Forall added in v0.4.0

func (list AnyList) Forall(p func(interface{}) bool) bool

Forall verifies that all elements of AnyList return true for the predicate p.

func (AnyList) Foreach added in v0.4.0

func (list AnyList) Foreach(f func(interface{}))

Foreach iterates over AnyList and executes function f against each element.

func (AnyList) Get added in v0.4.0

func (list AnyList) Get(i int) interface{}

Get gets the specified element in the list. Panics if the index is out of range or the list is nil. The simple list is a dressed-up slice and normal slice operations will also work.

func (AnyList) GobDecode added in v0.6.0

func (list AnyList) GobDecode(b []byte) error

GobDecode implements 'gob' decoding for this list type. You must register interface{} with the 'gob' package before this method is used.

func (AnyList) GobEncode added in v0.6.0

func (list AnyList) GobEncode() ([]byte, error)

GobEncode implements 'gob' encoding for this list type. You must register interface{} with the 'gob' package before this method is used.

func (AnyList) Head added in v0.4.0

func (list AnyList) Head() interface{}

Head gets the first element in the list. Head plus Tail include the whole list. Head is the opposite of Last. Panics if list is empty or nil.

func (AnyList) HeadOption added in v0.4.0

func (list AnyList) HeadOption() (interface{}, bool)

HeadOption gets the first element in the list, if possible. Otherwise returns the zero value.

func (AnyList) IndexWhere added in v0.4.0

func (list AnyList) IndexWhere(p func(interface{}) bool) int

IndexWhere finds the index of the first element satisfying predicate p. If none exists, -1 is returned.

func (AnyList) IndexWhere2 added in v0.4.0

func (list AnyList) IndexWhere2(p func(interface{}) bool, from int) int

IndexWhere2 finds the index of the first element satisfying predicate p at or after some start index. If none exists, -1 is returned.

func (AnyList) Init added in v0.4.0

func (list AnyList) Init() AnyList

Init gets everything except the last. Init plus Last include the whole list. Init is the opposite of Tail. Panics if list is empty or nil.

func (AnyList) IsEmpty added in v0.4.0

func (list AnyList) IsEmpty() bool

IsEmpty tests whether AnyList is empty.

func (AnyList) IsSequence added in v0.4.0

func (list AnyList) IsSequence() bool

IsSequence returns true for lists and queues.

func (AnyList) IsSet added in v0.4.0

func (list AnyList) IsSet() bool

IsSet returns false for lists or queues.

func (AnyList) Last added in v0.4.0

func (list AnyList) Last() interface{}

Last gets the last element in the list. Init plus Last include the whole list. Last is the opposite of Head. Panics if list is empty or nil.

func (AnyList) LastIndexWhere added in v0.4.0

func (list AnyList) LastIndexWhere(p func(interface{}) bool) int

LastIndexWhere finds the index of the last element satisfying predicate p. If none exists, -1 is returned.

func (AnyList) LastIndexWhere2 added in v0.4.0

func (list AnyList) LastIndexWhere2(p func(interface{}) bool, before int) int

LastIndexWhere2 finds the index of the last element satisfying predicate p at or before some start index. If none exists, -1 is returned.

func (AnyList) LastOption added in v0.4.0

func (list AnyList) LastOption() (interface{}, bool)

LastOption gets the last element in the list, if possible. Otherwise returns the zero value.

func (AnyList) Len added in v0.4.0

func (list AnyList) Len() int

Len returns the number of items in the list - an alias of Size(). This is one of the three methods in the standard sort.Interface.

func (AnyList) Map added in v0.4.0

func (list AnyList) Map(f func(interface{}) interface{}) AnyList

Map returns a new AnyList by transforming every element with function f. The resulting list is the same size as the original list. The original list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (AnyList) MaxBy added in v0.4.0

func (list AnyList) MaxBy(less func(interface{}, interface{}) bool) interface{}

MaxBy returns an element of AnyList containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (AnyList) MinBy added in v0.4.0

func (list AnyList) MinBy(less func(interface{}, interface{}) bool) interface{}

MinBy returns an element of AnyList containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (AnyList) MkString added in v0.6.0

func (list AnyList) MkString(sep string) string

MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.

func (AnyList) MkString3 added in v0.6.0

func (list AnyList) MkString3(before, between, after string) string

MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.

func (AnyList) NonEmpty added in v0.4.0

func (list AnyList) NonEmpty() bool

NonEmpty tests whether AnyList is empty.

func (AnyList) Partition added in v0.4.0

func (list AnyList) Partition(p func(interface{}) bool) (AnyList, AnyList)

Partition returns two new AnyLists whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't. The relative order of the elements in the results is the same as in the original list.

The original list is not modified.

func (AnyList) Reverse added in v0.4.0

func (list AnyList) Reverse() AnyList

Reverse returns a copy of AnyList with all elements in the reverse order.

The original list is not modified.

func (AnyList) Send added in v0.4.0

func (list AnyList) Send() <-chan interface{}

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed. The channel will be closed when all the elements have been sent.

func (AnyList) Shuffle added in v0.4.0

func (list AnyList) Shuffle() AnyList

Shuffle returns a shuffled copy of AnyList, using a version of the Fisher-Yates shuffle.

The original list is not modified.

func (AnyList) Size added in v0.4.0

func (list AnyList) Size() int

Size returns the number of items in the list - an alias of Len().

func (AnyList) SortBy added in v0.4.0

func (list AnyList) SortBy(less func(i, j interface{}) bool) AnyList

SortBy alters the list so that the elements are sorted by a specified ordering. Sorting happens in-place; the modified list is returned.

func (AnyList) StableSortBy added in v0.4.0

func (list AnyList) StableSortBy(less func(i, j interface{}) bool) AnyList

StableSortBy alters the list so that the elements are sorted by a specified ordering. Sorting happens in-place; the modified list is returned. The algorithm keeps the original order of equal elements.

func (AnyList) String added in v0.6.0

func (list AnyList) String() string

String implements the Stringer interface to render the list as a comma-separated string enclosed in square brackets.

func (AnyList) StringList added in v0.6.0

func (list AnyList) StringList() []string

StringList gets a list of strings that depicts all the elements.

func (AnyList) Swap added in v0.4.0

func (list AnyList) Swap(i, j int)

Swap exchanges two elements, which is necessary during sorting etc. This is one of the three methods in the standard sort.Interface.

func (AnyList) Tail added in v0.4.0

func (list AnyList) Tail() AnyList

Tail gets everything except the head. Head plus Tail include the whole list. Tail is the opposite of Init. Panics if list is empty or nil.

func (AnyList) Take added in v0.4.0

func (list AnyList) Take(n int) AnyList

Take returns a slice of AnyList containing the leading n elements of the source list. If n is greater than or equal to the size of the list, the whole original list is returned.

func (AnyList) TakeLast added in v0.4.0

func (list AnyList) TakeLast(n int) AnyList

TakeLast returns a slice of AnyList containing the trailing n elements of the source list. If n is greater than or equal to the size of the list, the whole original list is returned.

The original list is not modified.

func (AnyList) TakeWhile added in v0.4.0

func (list AnyList) TakeWhile(p func(interface{}) bool) AnyList

TakeWhile returns a new AnyList containing the leading elements of the source list. Whilst the predicate p returns true, elements are added to the result. Once predicate p returns false, all remaining elements are excluded.

The original list is not modified.

func (AnyList) ToInterfaceSlice added in v0.4.0

func (list AnyList) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the current list as a slice of arbitrary type.

func (AnyList) ToList added in v0.4.0

func (list AnyList) ToList() AnyList

ToList returns the elements of the list as a list, which is an identity operation in this case.

func (AnyList) ToSet added in v0.4.0

func (list AnyList) ToSet() AnySet

ToSet returns the elements of the list as a set. The returned set is a shallow copy; the list is not altered.

func (AnyList) ToSlice added in v0.4.0

func (list AnyList) ToSlice() []interface{}

ToSlice returns the elements of the list as a slice, which is an identity operation in this case, because the simple list is merely a dressed-up slice.

type AnyMkStringer added in v0.6.0

type AnyMkStringer interface {
	// String implements the Stringer interface to render the collection as a comma-separated string enclosed
	// in square brackets.
	String() string

	// MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.
	MkString(sep string) string

	// MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.
	MkString3(before, between, after string) string

	// StringList gets a collection of strings that depicts all the elements.
	StringList() []string
}

AnyMkStringer defines an interface for stringer methods on interface{} collections.

type AnyQueue added in v0.9.0

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

AnyQueue is a ring buffer containing a slice of type interface{}. It is optimised for FIFO operations.

func BuildAnyQueueFromChan added in v0.9.0

func BuildAnyQueueFromChan(source <-chan interface{}) *AnyQueue

BuildAnyQueueFromChan constructs a new AnyQueue from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func NewAnyQueue added in v0.9.0

func NewAnyQueue(capacity int, overwrite bool) *AnyQueue

NewAnyQueue returns a new queue of interface{}. The behaviour when adding to the queue depends on overwrite. If true, the push operation overwrites oldest values up to the space available, when the queue is full. Otherwise, it refuses to overfill the queue.

func NewAnySortedQueue added in v0.9.0

func NewAnySortedQueue(capacity int, overwrite bool, less func(i, j interface{}) bool) *AnyQueue

NewAnySortedQueue returns a new queue of interface{}. The behaviour when adding to the queue depends on overwrite. If true, the push operation overwrites oldest values up to the space available, when the queue is full. Otherwise, it refuses to overfill the queue. If the 'less' comparison function is not nil, elements can be easily sorted.

func (*AnyQueue) Add added in v0.9.0

func (queue *AnyQueue) Add(more ...interface{})

Add adds items to the queue. This is a synonym for Push.

func (*AnyQueue) Cap added in v0.9.0

func (queue *AnyQueue) Cap() int

Cap gets the capacity of this queue.

func (*AnyQueue) Clear added in v0.9.0

func (queue *AnyQueue) Clear()

Clear the entire queue.

func (*AnyQueue) Clone added in v0.9.0

func (queue *AnyQueue) Clone() *AnyQueue

Clone returns a shallow copy of the queue. It does not clone the underlying elements.

func (*AnyQueue) Contains added in v0.9.0

func (queue *AnyQueue) Contains(v interface{}) bool

Contains determines whether a given item is already in the queue, returning true if so.

func (*AnyQueue) ContainsAll added in v0.9.0

func (queue *AnyQueue) ContainsAll(i ...interface{}) bool

ContainsAll determines whether the given items are all in the queue, returning true if so. This is potentially a slow method and should only be used rarely.

func (*AnyQueue) CountBy added in v0.9.0

func (queue *AnyQueue) CountBy(p func(interface{}) bool) (result int)

CountBy gives the number elements of AnyQueue that return true for the predicate p.

func (*AnyQueue) DoKeepWhere added in v0.9.0

func (queue *AnyQueue) DoKeepWhere(p func(interface{}) bool) *AnyQueue

DoKeepWhere modifies a AnyQueue by retaining only those elements that match the predicate p. This is very similar to Filter but alters the queue in place.

The queue is modified and the modified queue is returned.

func (*AnyQueue) Equals added in v0.9.0

func (queue *AnyQueue) Equals(other *AnyQueue) bool

Equals determines if two queues are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for sets to be equal. Nil queues are considered to be empty.

func (*AnyQueue) Exists added in v0.9.0

func (queue *AnyQueue) Exists(p func(interface{}) bool) bool

Exists verifies that one or more elements of AnyQueue return true for the predicate p. The function should not alter the values via side-effects.

func (*AnyQueue) Filter added in v0.9.0

func (queue *AnyQueue) Filter(p func(interface{}) bool) *AnyQueue

Filter returns a new AnyQueue whose elements return true for predicate p.

The original queue is not modified. See also DoKeepWhere (which does modify the original queue).

func (*AnyQueue) Find added in v0.9.0

func (queue *AnyQueue) Find(p func(interface{}) bool) (interface{}, bool)

Find returns the first interface{} that returns true for predicate p. False is returned if none match.

func (*AnyQueue) FlatMap added in v0.9.0

func (queue *AnyQueue) FlatMap(f func(interface{}) []interface{}) *AnyQueue

FlatMap returns a new AnyQueue by transforming every element with function f that returns zero or more items in a slice. The resulting queue may have a different size to the original queue. The original queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (*AnyQueue) Fold added in v0.9.0

func (queue *AnyQueue) Fold(initial interface{}, fn func(interface{}, interface{}) interface{}) interface{}

Fold aggregates all the values in the queue using a supplied function, starting from some initial value.

func (*AnyQueue) Forall added in v0.9.0

func (queue *AnyQueue) Forall(p func(interface{}) bool) bool

Forall verifies that all elements of AnyQueue return true for the predicate p. The function should not alter the values via side-effects.

func (*AnyQueue) Foreach added in v0.9.0

func (queue *AnyQueue) Foreach(f func(interface{}))

Foreach iterates over AnyQueue and executes function f against each element. The function can safely alter the values via side-effects.

func (*AnyQueue) Get added in v0.9.0

func (queue *AnyQueue) Get(i int) interface{}

Get gets the specified element in the queue. Panics if the index is out of range or the queue is nil.

func (*AnyQueue) Head added in v0.9.0

func (queue *AnyQueue) Head() interface{}

Head gets the first element in the queue. Head is the opposite of Last. Panics if queue is empty or nil.

func (*AnyQueue) HeadOption added in v0.9.0

func (queue *AnyQueue) HeadOption() (interface{}, bool)

HeadOption returns the oldest item in the queue without removing it. If the queue is nil or empty, it returns the zero value instead.

func (*AnyQueue) IsEmpty added in v0.9.0

func (queue *AnyQueue) IsEmpty() bool

IsEmpty returns true if the queue is empty.

func (*AnyQueue) IsFull added in v0.9.0

func (queue *AnyQueue) IsFull() bool

IsFull returns true if the queue is full.

func (*AnyQueue) IsOverwriting added in v0.9.0

func (queue *AnyQueue) IsOverwriting() bool

IsOverwriting returns true if the queue is overwriting, false if refusing.

func (*AnyQueue) IsSequence added in v0.9.0

func (queue *AnyQueue) IsSequence() bool

IsSequence returns true for ordered lists and queues.

func (*AnyQueue) IsSet added in v0.9.0

func (queue *AnyQueue) IsSet() bool

IsSet returns false for lists or queues.

func (*AnyQueue) Last added in v0.9.0

func (queue *AnyQueue) Last() interface{}

Last gets the the newest item in the queue (i.e. last element pushed) without removing it. Last is the opposite of Head. Panics if queue is empty or nil.

func (*AnyQueue) LastOption added in v0.9.0

func (queue *AnyQueue) LastOption() (interface{}, bool)

LastOption returns the newest item in the queue without removing it. If the queue is nil empty, it returns the zero value instead.

func (*AnyQueue) Len added in v0.9.0

func (queue *AnyQueue) Len() int

Len gets the current length of this queue. This is an alias for Size.

func (*AnyQueue) Less added in v0.9.0

func (queue *AnyQueue) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j. The queue must have been created with a non-nil 'less' comparison function and it must not be empty.

func (*AnyQueue) Map added in v0.9.0

func (queue *AnyQueue) Map(f func(interface{}) interface{}) *AnyQueue

Map returns a new AnyQueue by transforming every element with function f. The resulting queue is the same size as the original queue. The original queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (AnyQueue) MarshalJSON added in v0.9.0

func (queue AnyQueue) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this queue type.

func (*AnyQueue) MaxBy added in v0.9.0

func (queue *AnyQueue) MaxBy(less func(interface{}, interface{}) bool) interface{}

MaxBy returns an element of AnyQueue containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (*AnyQueue) MinBy added in v0.9.0

func (queue *AnyQueue) MinBy(less func(interface{}, interface{}) bool) interface{}

MinBy returns an element of AnyQueue containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (*AnyQueue) MkString added in v0.9.0

func (queue *AnyQueue) MkString(sep string) string

MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.

func (*AnyQueue) MkString3 added in v0.9.0

func (queue *AnyQueue) MkString3(before, between, after string) string

MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.

func (*AnyQueue) NonEmpty added in v0.9.0

func (queue *AnyQueue) NonEmpty() bool

NonEmpty returns true if the queue is not empty.

func (*AnyQueue) Offer added in v0.9.0

func (queue *AnyQueue) Offer(items ...interface{}) []interface{}

Offer appends as many items to the end of the queue as it can. If the queue is already full, what happens depends on whether the queue is configured to overwrite. If it is, the oldest items will be overwritten. Otherwise, it will be filled to capacity and any unwritten items are returned.

If the capacity is too small for the number of items, the excess items are returned. The queue capacity is never altered.

func (*AnyQueue) Partition added in v0.9.0

func (queue *AnyQueue) Partition(p func(interface{}) bool) (*AnyQueue, *AnyQueue)

Partition returns two new AnyQueues whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't. The relative order of the elements in the results is the same as in the original queue.

The original queue is not modified

func (*AnyQueue) Pop added in v0.9.0

func (queue *AnyQueue) Pop(n int) []interface{}

Pop removes and returns the oldest items from the queue. If the queue is empty, it returns a nil slice. If n is larger than the current queue length, it returns all the available elements, so in this case the returned slice will be shorter than n.

func (*AnyQueue) Pop1 added in v0.9.0

func (queue *AnyQueue) Pop1() (interface{}, bool)

Pop1 removes and returns the oldest item from the queue. If the queue is empty, it returns the zero value instead. The boolean is true only if the element was available.

func (*AnyQueue) Push added in v0.9.0

func (queue *AnyQueue) Push(items ...interface{}) *AnyQueue

Push appends items to the end of the queue. If the queue does not have enough space, more will be allocated: how this happens depends on the overwriting mode.

When overwriting, the oldest items are overwritten with the new data; it expands the queue only if there is still not enough space.

Otherwise, the queue might be reallocated if necessary, ensuring that all the data is pushed without any older items being affected.

The modified queue is returned.

func (*AnyQueue) Reallocate added in v0.9.0

func (queue *AnyQueue) Reallocate(capacity int, overwrite bool) *AnyQueue

Reallocate adjusts the allocated capacity of the queue and allows the overwriting behaviour to be changed.

If the new queue capacity is different to the current capacity, the queue is re-allocated to the new capacity. If this is less than the current number of elements, the oldest items in the queue are discarded so that the remaining data can fit in the new space available.

If the new queue capacity is the same as the current capacity, the queue is not altered except for adopting the new overwrite flag's value. Therefore this is the means to change the overwriting behaviour.

Reallocate adjusts the storage space but does not clone the underlying elements.

The queue must not be nil.

func (*AnyQueue) Send added in v0.9.0

func (queue *AnyQueue) Send() <-chan interface{}

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed. The channel will be closed when all the elements have been sent.

func (*AnyQueue) Size added in v0.9.0

func (queue *AnyQueue) Size() int

Size gets the number of elements currently in this queue. This is an alias for Len.

func (*AnyQueue) Sort added in v0.9.0

func (queue *AnyQueue) Sort()

Sort sorts the queue using the 'less' comparison function, which must not be nil. This function will panic if the collection was created with a nil 'less' function (see NewAnySortedQueue).

func (*AnyQueue) Space added in v0.9.0

func (queue *AnyQueue) Space() int

Space returns the space available in the queue.

func (*AnyQueue) StableSort added in v0.9.0

func (queue *AnyQueue) StableSort()

StableSort sorts the queue using the 'less' comparison function, which must not be nil. The result is stable so that repeated calls will not arbitrarily swap equal items. This function will panic if the collection was created with a nil 'less' function (see NewAnySortedQueue).

func (*AnyQueue) String added in v0.9.0

func (queue *AnyQueue) String() string

String implements the Stringer interface to render the queue as a comma-separated string enclosed in square brackets.

func (*AnyQueue) StringList added in v0.9.0

func (queue *AnyQueue) StringList() []string

StringList gets a list of strings that depicts all the elements.

func (*AnyQueue) Swap added in v0.9.0

func (queue *AnyQueue) Swap(i, j int)

Swap swaps the elements with indexes i and j. The queue must not be empty.

func (*AnyQueue) ToInterfaceSlice added in v0.9.0

func (queue *AnyQueue) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the queue as a slice of arbitrary type. The queue is not altered.

func (*AnyQueue) ToSlice added in v0.9.0

func (queue *AnyQueue) ToSlice() []interface{}

ToSlice returns the elements of the queue as a slice. The queue is not altered.

func (*AnyQueue) UnmarshalJSON added in v0.9.0

func (queue *AnyQueue) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this queue type.

type AnySequence added in v0.9.0

type AnySequence interface {
	AnyCollection

	// Head gets the first element in the sequence. Head plus Tail include the whole sequence. Head is the opposite of Last.
	Head() interface{}

	// HeadOption gets the first element in the sequence, if possible.
	HeadOption() (interface{}, bool)

	// Last gets the last element in the sequence. Init plus Last include the whole sequence. Last is the opposite of Head.
	Last() interface{}

	// LastOption gets the last element in the sequence, if possible.
	LastOption() (interface{}, bool)
}

AnySequence defines an interface for sequence methods on interface{}.

type AnySet added in v0.4.0

type AnySet map[interface{}]struct{}

AnySet is the primary type that represents a set

func BuildAnySetFromChan added in v0.4.0

func BuildAnySetFromChan(source <-chan interface{}) AnySet

BuildAnySetFromChan constructs a new AnySet from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func ConvertAnySet added in v0.4.0

func ConvertAnySet(values ...interface{}) (AnySet, bool)

ConvertAnySet constructs a new set containing the supplied values, if any. The returned boolean will be false if any of the values could not be converted correctly. The returned set will contain all the values that were correctly converted.

func NewAnySet added in v0.4.0

func NewAnySet(values ...interface{}) AnySet

NewAnySet creates and returns a reference to an empty set.

func (AnySet) Add added in v0.4.0

func (set AnySet) Add(more ...interface{}) AnySet

Add adds items to the current set, returning the modified set.

func (AnySet) Append added in v0.4.0

func (set AnySet) Append(more ...interface{}) AnySet

Append inserts more items into a clone of the set. It returns the augmented set. The original set is unmodified.

func (AnySet) Cardinality added in v0.4.0

func (set AnySet) Cardinality() int

Cardinality returns how many items are currently in the set. This is a synonym for Size.

func (*AnySet) Clear added in v0.4.0

func (set *AnySet) Clear()

Clear the entire set. Aterwards, it will be an empty set.

func (AnySet) Clone added in v0.4.0

func (set AnySet) Clone() AnySet

Clone returns a shallow copy of the set. It does not clone the underlying elements.

func (AnySet) Contains added in v0.4.0

func (set AnySet) Contains(i interface{}) bool

Contains determines whether a given item is already in the set, returning true if so.

func (AnySet) ContainsAll added in v0.4.0

func (set AnySet) ContainsAll(i ...interface{}) bool

ContainsAll determines whether a given item is already in the set, returning true if so.

func (AnySet) CountBy added in v0.4.0

func (set AnySet) CountBy(p func(interface{}) bool) (result int)

CountBy gives the number elements of AnySet that return true for the predicate p.

func (AnySet) Difference added in v0.4.0

func (set AnySet) Difference(other AnySet) AnySet

Difference returns a new set with items in the current set but not in the other set

func (AnySet) Equals added in v0.4.0

func (set AnySet) Equals(other AnySet) bool

Equals determines whether two sets are equal to each other, returning true if so. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for sets to be equal.

func (AnySet) Exists added in v0.4.0

func (set AnySet) Exists(p func(interface{}) bool) bool

Exists applies a predicate p to every element in the set. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (AnySet) Filter added in v0.4.0

func (set AnySet) Filter(p func(interface{}) bool) AnySet

Filter returns a new AnySet whose elements return true for the predicate p.

The original set is not modified

func (AnySet) Find added in v0.4.0

func (set AnySet) Find(p func(interface{}) bool) (interface{}, bool)

Find returns the first interface{} that returns true for the predicate p. If there are many matches one is arbtrarily chosen. False is returned if none match.

func (AnySet) FlatMap added in v0.4.0

func (set AnySet) FlatMap(f func(interface{}) []interface{}) AnySet

FlatMap returns a new AnySet by transforming every element with a function f that returns zero or more items in a slice. The resulting set may have a different size to the original set. The original set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (AnySet) Fold added in v0.9.0

func (set AnySet) Fold(initial interface{}, fn func(interface{}, interface{}) interface{}) interface{}

Fold aggregates all the values in the set using a supplied function, starting from some initial value.

func (AnySet) Forall added in v0.4.0

func (set AnySet) Forall(p func(interface{}) bool) bool

Forall applies a predicate function p to every element in the set. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (AnySet) Foreach added in v0.4.0

func (set AnySet) Foreach(f func(interface{}))

Foreach iterates over the set and executes the function f against each element.

func (AnySet) Intersect added in v0.4.0

func (set AnySet) Intersect(other AnySet) AnySet

Intersect returns a new set with items that exist only in both sets.

func (AnySet) IsEmpty added in v0.4.0

func (set AnySet) IsEmpty() bool

IsEmpty returns true if the set is empty.

func (AnySet) IsSequence added in v0.4.0

func (set AnySet) IsSequence() bool

IsSequence returns true for lists and queues.

func (AnySet) IsSet added in v0.4.0

func (set AnySet) IsSet() bool

IsSet returns false for lists or queues.

func (AnySet) IsSubset added in v0.4.0

func (set AnySet) IsSubset(other AnySet) bool

IsSubset determines whether every item in the other set is in this set, returning true if so.

func (AnySet) IsSuperset added in v0.4.0

func (set AnySet) IsSuperset(other AnySet) bool

IsSuperset determines whether every item of this set is in the other set, returning true if so.

func (AnySet) Map added in v0.4.0

func (set AnySet) Map(f func(interface{}) interface{}) AnySet

Map returns a new AnySet by transforming every element with a function f. The original set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (AnySet) MarshalJSON added in v0.6.0

func (set AnySet) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this set type.

func (AnySet) MaxBy added in v0.4.0

func (set AnySet) MaxBy(less func(interface{}, interface{}) bool) interface{}

MaxBy returns an element of AnySet containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (AnySet) MinBy added in v0.4.0

func (set AnySet) MinBy(less func(interface{}, interface{}) bool) interface{}

MinBy returns an element of AnySet containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (AnySet) MkString added in v0.6.0

func (set AnySet) MkString(sep string) string

MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.

func (AnySet) MkString3 added in v0.6.0

func (set AnySet) MkString3(before, between, after string) string

MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.

func (AnySet) NonEmpty added in v0.4.0

func (set AnySet) NonEmpty() bool

NonEmpty returns true if the set is not empty.

func (AnySet) Partition added in v0.4.0

func (set AnySet) Partition(p func(interface{}) bool) (AnySet, AnySet)

Partition returns two new AnySets whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't.

The original set is not modified

func (AnySet) Remove added in v0.4.0

func (set AnySet) Remove(i interface{})

Remove a single item from the set.

func (AnySet) Send added in v0.4.0

func (set AnySet) Send() <-chan interface{}

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed

func (AnySet) Size added in v0.4.0

func (set AnySet) Size() int

Size returns how many items are currently in the set. This is a synonym for Cardinality.

func (AnySet) String added in v0.6.0

func (set AnySet) String() string

String implements the Stringer interface to render the set as a comma-separated string enclosed in square brackets.

func (AnySet) StringList added in v0.6.0

func (set AnySet) StringList() []string

StringList gets a list of strings that depicts all the elements.

func (AnySet) StringMap added in v0.6.0

func (set AnySet) StringMap() map[string]bool

StringMap renders the set as a map of strings. The value of each item in the set becomes stringified as a key in the resulting map.

func (AnySet) SymmetricDifference added in v0.4.0

func (set AnySet) SymmetricDifference(other AnySet) AnySet

SymmetricDifference returns a new set with items in the current set or the other set but not in both.

func (AnySet) ToInterfaceSlice added in v0.4.0

func (set AnySet) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the current set as a slice of arbitrary type.

func (AnySet) ToList added in v0.4.0

func (set AnySet) ToList() AnyList

ToList returns the elements of the set as a list. The returned list is a shallow copy; the set is not altered.

func (AnySet) ToSet added in v0.4.0

func (set AnySet) ToSet() AnySet

ToSet returns the set; this is an identity operation in this case.

func (AnySet) ToSlice added in v0.4.0

func (set AnySet) ToSlice() []interface{}

ToSlice returns the elements of the current set as a slice.

func (AnySet) Union added in v0.4.0

func (set AnySet) Union(other AnySet) AnySet

Union returns a new set with all items in both sets.

func (AnySet) UnmarshalJSON added in v0.6.0

func (set AnySet) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this set type.

type AnySizer added in v0.4.0

type AnySizer interface {
	// IsEmpty tests whether AnyCollection is empty.
	IsEmpty() bool

	// NonEmpty tests whether AnyCollection is empty.
	NonEmpty() bool

	// Size returns the number of items in the collection - an alias of Len().
	Size() int
}

AnySizer defines an interface for sizing methods on interface{} collections.

type Int64Collection

type Int64Collection interface {
	Int64Sizer
	Int64MkStringer

	// IsSequence returns true for lists and queues.
	IsSequence() bool

	// IsSet returns false for lists and queues.
	IsSet() bool

	// ToSlice returns a shallow copy as a plain slice.
	ToSlice() []int64

	// ToInterfaceSlice returns a shallow copy as a slice of arbitrary type.
	ToInterfaceSlice() []interface{}

	// Exists verifies that one or more elements of Int64Collection return true for the predicate p.
	Exists(p func(int64) bool) bool

	// Forall verifies that all elements of Int64Collection return true for the predicate p.
	Forall(p func(int64) bool) bool

	// Foreach iterates over Int64Collection and executes the function f against each element.
	Foreach(f func(int64))

	// Find returns the first int64 that returns true for the predicate p.
	// False is returned if none match.
	Find(p func(int64) bool) (int64, bool)

	// Send returns a channel that will send all the elements in order. Can be used with the plumbing code, for example.
	// A goroutine is created to send the elements; this only terminates when all the elements have been consumed
	Send() <-chan int64

	// CountBy gives the number elements of Int64Collection that return true for the predicate p.
	CountBy(p func(int64) bool) int

	// Contains determines whether a given item is already in the collection, returning true if so.
	Contains(v int64) bool

	// ContainsAll determines whether the given items are all in the collection, returning true if so.
	ContainsAll(v ...int64) bool

	// Min returns the minimum value of all the items in the collection. Panics if there are no elements.
	Min() int64

	// Max returns the minimum value of all the items in the collection. Panics if there are no elements.
	Max() int64

	// MinBy returns an element of Int64Collection containing the minimum value, when compared to other elements
	// using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such
	// element is returned. Panics if there are no elements.
	MinBy(less func(int64, int64) bool) int64

	// MaxBy returns an element of Int64Collection containing the maximum value, when compared to other elements
	// using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such
	// element is returned. Panics if there are no elements.
	MaxBy(less func(int64, int64) bool) int64

	// Fold aggregates all the values in the collection using a supplied function, starting from some initial value.
	Fold(initial int64, fn func(int64, int64) int64) int64

	// Sum returns the sum of all the elements in the collection.
	Sum() int64
}

Int64Collection defines an interface for common collection methods on int64.

type Int64Int64Map

type Int64Int64Map map[int64]int64

Int64Int64Map is the primary type that represents a map

func NewInt64Int64Map

func NewInt64Int64Map(kv ...Int64Int64Tuple) Int64Int64Map

NewInt64Int64Map creates and returns a reference to a map, optionally containing some items.

func NewInt64Int64Map1

func NewInt64Int64Map1(k int64, v int64) Int64Int64Map

NewInt64Int64Map1 creates and returns a reference to a map containing one item.

func (*Int64Int64Map) Clear

func (mm *Int64Int64Map) Clear()

Clear clears the entire map.

func (Int64Int64Map) Clone

func (mm Int64Int64Map) Clone() Int64Int64Map

Clone returns a shallow copy of the map. It does not clone the underlying elements.

func (Int64Int64Map) ContainsAllKeys

func (mm Int64Int64Map) ContainsAllKeys(kk ...int64) bool

ContainsAllKeys determines if the given items are all in the map.

func (Int64Int64Map) ContainsKey

func (mm Int64Int64Map) ContainsKey(k int64) bool

ContainsKey determines if a given item is already in the map.

func (Int64Int64Map) DropWhere

func (mm Int64Int64Map) DropWhere(fn func(int64, int64) bool) Int64Int64Tuples

DropWhere applies a predicate function to every element in the map. If the function returns true, the element is dropped from the map. This is similar to Filter except that the map is modified.

func (Int64Int64Map) Equals

func (mm Int64Int64Map) Equals(other Int64Int64Map) bool

Equals determines if two maps are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for maps to be equal.

func (Int64Int64Map) Exists

func (mm Int64Int64Map) Exists(p func(int64, int64) bool) bool

Exists applies the predicate p to every element in the map. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (Int64Int64Map) Filter

func (mm Int64Int64Map) Filter(p func(int64, int64) bool) Int64Int64Map

Filter applies the predicate p to every element in the map and returns a copied map containing only the elements for which the predicate returned true. The original map is not modified.

func (Int64Int64Map) Find

func (mm Int64Int64Map) Find(p func(int64, int64) bool) (Int64Int64Tuple, bool)

Find returns the first int64 that returns true for the predicate p. False is returned if none match. The original map is not modified.

func (Int64Int64Map) FlatMap

func (mm Int64Int64Map) FlatMap(f func(int64, int64) []Int64Int64Tuple) Int64Int64Map

FlatMap returns a new Int64Map by transforming every element with the function f that returns zero or more items in a slice. The resulting map may have a different size to the original map. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Int64Int64Map) Forall

func (mm Int64Int64Map) Forall(p func(int64, int64) bool) bool

Forall applies the predicate p to every element in the map. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (Int64Int64Map) Foreach

func (mm Int64Int64Map) Foreach(f func(int64, int64))

Foreach applies the function f to every element in the map. The function can safely alter the values via side-effects.

func (Int64Int64Map) Get

func (mm Int64Int64Map) Get(k int64) (int64, bool)

Get returns one of the items in the map, if present.

func (Int64Int64Map) IsEmpty

func (mm Int64Int64Map) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (Int64Int64Map) Keys

func (mm Int64Int64Map) Keys() Int64List

Keys returns the keys of the current map as a slice.

func (Int64Int64Map) Map

func (mm Int64Int64Map) Map(f func(int64, int64) (int64, int64)) Int64Int64Map

Map returns a new Int64Map by transforming every element with the function f. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Int64Int64Map) MkString

func (mm Int64Int64Map) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (Int64Int64Map) MkString4 added in v0.7.0

func (mm Int64Int64Map) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (Int64Int64Map) NonEmpty

func (mm Int64Int64Map) NonEmpty() bool

NonEmpty returns true if the map is not empty.

func (Int64Int64Map) OrderedSlice added in v0.6.0

func (mm Int64Int64Map) OrderedSlice(keys Int64List) Int64Int64Tuples

OrderedSlice returns the key/value pairs as a slice in the order specified by keys.

func (Int64Int64Map) Partition

func (mm Int64Int64Map) Partition(p func(int64, int64) bool) (matching Int64Int64Map, others Int64Int64Map)

Partition applies the predicate p to every element in the map. It divides the map into two copied maps, the first containing all the elements for which the predicate returned true, and the second containing all the others. The original map is not modified.

func (Int64Int64Map) Pop

func (mm Int64Int64Map) Pop(k int64) (int64, bool)

Pop removes a single item from the map, returning the value present prior to removal.

func (Int64Int64Map) Put

func (mm Int64Int64Map) Put(k int64, v int64) bool

Put adds an item to the current map, replacing any prior value.

func (Int64Int64Map) Remove

func (mm Int64Int64Map) Remove(k int64)

Remove a single item from the map.

func (Int64Int64Map) Size

func (mm Int64Int64Map) Size() int

Size returns how many items are currently in the map. This is a synonym for Len.

func (Int64Int64Map) String

func (mm Int64Int64Map) String() string

String implements the Stringer interface to render the set as a comma-separated string enclosed in square brackets.

func (Int64Int64Map) ToSlice

func (mm Int64Int64Map) ToSlice() Int64Int64Tuples

ToSlice returns the key/value pairs as a slice.

func (Int64Int64Map) Values

func (mm Int64Int64Map) Values() Int64List

Values returns the values of the current map as a slice.

type Int64Int64Tuple

type Int64Int64Tuple struct {
	Key int64
	Val int64
}

Int64Int64Tuple represents a key/value pair.

func (Int64Int64Tuple) MarshalJSON added in v0.6.0

func (t Int64Int64Tuple) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding.Marshaler interface.

func (Int64Int64Tuple) UnmarshalJSON added in v0.6.0

func (t Int64Int64Tuple) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this tuple type.

type Int64Int64Tuples

type Int64Int64Tuples []Int64Int64Tuple

Int64Int64Tuples can be used as a builder for unmodifiable maps.

func Int64Int64Zip

func Int64Int64Zip(keys ...int64) Int64Int64Tuples

Int64Int64Zip is used with the Values method to zip (i.e. interleave) a slice of keys with a slice of values. These can then be passed in to the NewInt64Int64Map constructor function.

func (Int64Int64Tuples) Append1

func (ts Int64Int64Tuples) Append1(k int64, v int64) Int64Int64Tuples

Append1 adds one item.

func (Int64Int64Tuples) Append2

func (ts Int64Int64Tuples) Append2(k1 int64, v1 int64, k2 int64, v2 int64) Int64Int64Tuples

Append2 adds two items.

func (Int64Int64Tuples) Append3

func (ts Int64Int64Tuples) Append3(k1 int64, v1 int64, k2 int64, v2 int64, k3 int64, v3 int64) Int64Int64Tuples

Append3 adds three items.

func (Int64Int64Tuples) MkString added in v0.6.0

func (ts Int64Int64Tuples) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (Int64Int64Tuples) MkString4 added in v0.7.0

func (ts Int64Int64Tuples) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (Int64Int64Tuples) String added in v0.6.0

func (ts Int64Int64Tuples) String() string

func (Int64Int64Tuples) ToMap added in v0.6.0

func (ts Int64Int64Tuples) ToMap() Int64Int64Map

ToMap converts the tuples to a map.

func (Int64Int64Tuples) Values

func (ts Int64Int64Tuples) Values(values ...int64) Int64Int64Tuples

Values sets the values in a tuple slice. Use this with Int64Int64Zip.

type Int64List

type Int64List []int64

Int64List is a slice of type int64. Use it where you would use []int64. To add items to the list, simply use the normal built-in append function.

List values follow a similar pattern to Scala Lists and LinearSeqs in particular. For comparison with Scala, see e.g. http://www.scala-lang.org/api/2.11.7/#scala.collection.LinearSeq

func BuildInt64ListFromChan

func BuildInt64ListFromChan(source <-chan int64) Int64List

BuildInt64ListFromChan constructs a new Int64List from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func ConvertInt64List

func ConvertInt64List(values ...interface{}) (Int64List, bool)

ConvertInt64List constructs a new list containing the supplied values, if any. The returned boolean will be false if any of the values could not be converted correctly. The returned list will contain all the values that were correctly converted. Conversions are provided from all built-in numeric types.

func MakeInt64List

func MakeInt64List(length, capacity int) Int64List

MakeInt64List makes an empty list with both length and capacity initialised.

func NewInt64List

func NewInt64List(values ...int64) Int64List

NewInt64List constructs a new list containing the supplied values, if any.

func (Int64List) Clone

func (list Int64List) Clone() Int64List

Clone returns a shallow copy of the list. It does not clone the underlying elements.

func (Int64List) Contains

func (list Int64List) Contains(v int64) bool

Contains determines whether a given item is already in the list, returning true if so.

func (Int64List) ContainsAll

func (list Int64List) ContainsAll(i ...int64) bool

ContainsAll determines whether the given items are all in the list, returning true if so. This is potentially a slow method and should only be used rarely.

func (Int64List) CountBy

func (list Int64List) CountBy(p func(int64) bool) (result int)

CountBy gives the number elements of Int64List that return true for the predicate p.

func (Int64List) DistinctBy

func (list Int64List) DistinctBy(equal func(int64, int64) bool) Int64List

DistinctBy returns a new Int64List whose elements are unique, where equality is defined by the equal function.

func (Int64List) DoReverse

func (list Int64List) DoReverse() Int64List

DoReverse alters a Int64List with all elements in the reverse order. Unlike Reverse, it does not allocate new memory.

The list is modified and the modified list is returned.

func (Int64List) DoShuffle

func (list Int64List) DoShuffle() Int64List

DoShuffle returns a shuffled Int64List, using a version of the Fisher-Yates shuffle.

The list is modified and the modified list is returned.

func (Int64List) Drop

func (list Int64List) Drop(n int) Int64List

Drop returns a slice of Int64List without the leading n elements of the source list. If n is greater than or equal to the size of the list, an empty list is returned.

The original list is not modified.

func (Int64List) DropLast

func (list Int64List) DropLast(n int) Int64List

DropLast returns a slice of Int64List without the trailing n elements of the source list. If n is greater than or equal to the size of the list, an empty list is returned.

The original list is not modified.

func (Int64List) DropWhile

func (list Int64List) DropWhile(p func(int64) bool) Int64List

DropWhile returns a new Int64List containing the trailing elements of the source list. Whilst the predicate p returns true, elements are excluded from the result. Once predicate p returns false, all remaining elements are added.

The original list is not modified.

func (Int64List) Equals

func (list Int64List) Equals(other Int64List) bool

Equals determines if two lists are equal to each other. If they both are the same size and have the same items in the same order, they are considered equal. Order of items is not relevent for sets to be equal.

func (Int64List) Exists

func (list Int64List) Exists(p func(int64) bool) bool

Exists verifies that one or more elements of Int64List return true for the predicate p.

func (Int64List) Filter

func (list Int64List) Filter(p func(int64) bool) Int64List

Filter returns a new Int64List whose elements return true for predicate p.

The original list is not modified.

func (Int64List) Find

func (list Int64List) Find(p func(int64) bool) (int64, bool)

Find returns the first int64 that returns true for predicate p. False is returned if none match.

func (Int64List) FlatMap

func (list Int64List) FlatMap(f func(int64) []int64) Int64List

FlatMap returns a new Int64List by transforming every element with function f that returns zero or more items in a slice. The resulting list may have a different size to the original list. The original list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Int64List) FlatMapToString added in v0.3.0

func (list Int64List) FlatMapToString(f func(int64) []string) []string

FlatMapToString returns a new []string by transforming every element with function f that returns zero or more items in a slice. The resulting slice may have a different size to the list. The list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Int64List) Fold added in v0.9.0

func (list Int64List) Fold(initial int64, fn func(int64, int64) int64) int64

Fold aggregates all the values in the list using a supplied function, starting from some initial value.

func (Int64List) Forall

func (list Int64List) Forall(p func(int64) bool) bool

Forall verifies that all elements of Int64List return true for the predicate p.

func (Int64List) Foreach

func (list Int64List) Foreach(f func(int64))

Foreach iterates over Int64List and executes function f against each element.

func (Int64List) Get

func (list Int64List) Get(i int) int64

Get gets the specified element in the list. Panics if the index is out of range or the list is nil. The simple list is a dressed-up slice and normal slice operations will also work.

func (Int64List) GobDecode

func (list Int64List) GobDecode(b []byte) error

GobDecode implements 'gob' decoding for this list type. You must register int64 with the 'gob' package before this method is used.

func (Int64List) GobEncode

func (list Int64List) GobEncode() ([]byte, error)

GobEncode implements 'gob' encoding for this list type. You must register int64 with the 'gob' package before this method is used.

func (Int64List) Head

func (list Int64List) Head() int64

Head gets the first element in the list. Head plus Tail include the whole list. Head is the opposite of Last. Panics if list is empty or nil.

func (Int64List) HeadOption

func (list Int64List) HeadOption() (int64, bool)

HeadOption gets the first element in the list, if possible. Otherwise returns the zero value.

func (Int64List) IndexWhere

func (list Int64List) IndexWhere(p func(int64) bool) int

IndexWhere finds the index of the first element satisfying predicate p. If none exists, -1 is returned.

func (Int64List) IndexWhere2

func (list Int64List) IndexWhere2(p func(int64) bool, from int) int

IndexWhere2 finds the index of the first element satisfying predicate p at or after some start index. If none exists, -1 is returned.

func (Int64List) Init

func (list Int64List) Init() Int64List

Init gets everything except the last. Init plus Last include the whole list. Init is the opposite of Tail. Panics if list is empty or nil.

func (Int64List) IsEmpty

func (list Int64List) IsEmpty() bool

IsEmpty tests whether Int64List is empty.

func (Int64List) IsSequence

func (list Int64List) IsSequence() bool

IsSequence returns true for lists and queues.

func (Int64List) IsSet

func (list Int64List) IsSet() bool

IsSet returns false for lists or queues.

func (Int64List) Last

func (list Int64List) Last() int64

Last gets the last element in the list. Init plus Last include the whole list. Last is the opposite of Head. Panics if list is empty or nil.

func (Int64List) LastIndexWhere

func (list Int64List) LastIndexWhere(p func(int64) bool) int

LastIndexWhere finds the index of the last element satisfying predicate p. If none exists, -1 is returned.

func (Int64List) LastIndexWhere2

func (list Int64List) LastIndexWhere2(p func(int64) bool, before int) int

LastIndexWhere2 finds the index of the last element satisfying predicate p at or before some start index. If none exists, -1 is returned.

func (Int64List) LastOption

func (list Int64List) LastOption() (int64, bool)

LastOption gets the last element in the list, if possible. Otherwise returns the zero value.

func (Int64List) Len

func (list Int64List) Len() int

Len returns the number of items in the list - an alias of Size(). This is one of the three methods in the standard sort.Interface.

func (Int64List) Map

func (list Int64List) Map(f func(int64) int64) Int64List

Map returns a new Int64List by transforming every element with function f. The resulting list is the same size as the original list. The original list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Int64List) MapToString added in v0.3.0

func (list Int64List) MapToString(f func(int64) string) []string

MapToString returns a new []string by transforming every element with function f. The resulting slice is the same size as the list. The list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Int64List) Max

func (list Int64List) Max() (result int64)

Max returns the first element containing the maximum value, when compared to other elements. Panics if the collection is empty.

func (Int64List) MaxBy

func (list Int64List) MaxBy(less func(int64, int64) bool) int64

MaxBy returns an element of Int64List containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (Int64List) Min

func (list Int64List) Min() int64

Min returns the first element containing the minimum value, when compared to other elements. Panics if the collection is empty.

func (Int64List) MinBy

func (list Int64List) MinBy(less func(int64, int64) bool) int64

MinBy returns an element of Int64List containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (Int64List) MkString

func (list Int64List) MkString(sep string) string

MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.

func (Int64List) MkString3

func (list Int64List) MkString3(before, between, after string) string

MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.

func (Int64List) NonEmpty

func (list Int64List) NonEmpty() bool

NonEmpty tests whether Int64List is empty.

func (Int64List) Partition

func (list Int64List) Partition(p func(int64) bool) (Int64List, Int64List)

Partition returns two new Int64Lists whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't. The relative order of the elements in the results is the same as in the original list.

The original list is not modified.

func (Int64List) Reverse

func (list Int64List) Reverse() Int64List

Reverse returns a copy of Int64List with all elements in the reverse order.

The original list is not modified.

func (Int64List) Send

func (list Int64List) Send() <-chan int64

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed. The channel will be closed when all the elements have been sent.

func (Int64List) Shuffle

func (list Int64List) Shuffle() Int64List

Shuffle returns a shuffled copy of Int64List, using a version of the Fisher-Yates shuffle.

The original list is not modified.

func (Int64List) Size

func (list Int64List) Size() int

Size returns the number of items in the list - an alias of Len().

func (Int64List) SortBy

func (list Int64List) SortBy(less func(i, j int64) bool) Int64List

SortBy alters the list so that the elements are sorted by a specified ordering. Sorting happens in-place; the modified list is returned.

func (Int64List) Sorted

func (list Int64List) Sorted() Int64List

Sorted alters the list so that the elements are sorted by their natural ordering. Sorting happens in-place; the modified list is returned.

func (Int64List) StableSortBy

func (list Int64List) StableSortBy(less func(i, j int64) bool) Int64List

StableSortBy alters the list so that the elements are sorted by a specified ordering. Sorting happens in-place; the modified list is returned. The algorithm keeps the original order of equal elements.

func (Int64List) StableSorted

func (list Int64List) StableSorted() Int64List

StableSorted alters the list so that the elements are sorted by their natural ordering. Sorting happens in-place; the modified list is returned.

func (Int64List) String

func (list Int64List) String() string

String implements the Stringer interface to render the list as a comma-separated string enclosed in square brackets.

func (Int64List) StringList

func (list Int64List) StringList() []string

StringList gets a list of strings that depicts all the elements.

func (Int64List) Sum

func (list Int64List) Sum() int64

Sum returns the sum of all the elements in the list.

func (Int64List) Swap

func (list Int64List) Swap(i, j int)

Swap exchanges two elements, which is necessary during sorting etc. This is one of the three methods in the standard sort.Interface.

func (Int64List) Tail

func (list Int64List) Tail() Int64List

Tail gets everything except the head. Head plus Tail include the whole list. Tail is the opposite of Init. Panics if list is empty or nil.

func (Int64List) Take

func (list Int64List) Take(n int) Int64List

Take returns a slice of Int64List containing the leading n elements of the source list. If n is greater than or equal to the size of the list, the whole original list is returned.

func (Int64List) TakeLast

func (list Int64List) TakeLast(n int) Int64List

TakeLast returns a slice of Int64List containing the trailing n elements of the source list. If n is greater than or equal to the size of the list, the whole original list is returned.

The original list is not modified.

func (Int64List) TakeWhile

func (list Int64List) TakeWhile(p func(int64) bool) Int64List

TakeWhile returns a new Int64List containing the leading elements of the source list. Whilst the predicate p returns true, elements are added to the result. Once predicate p returns false, all remaining elements are excluded.

The original list is not modified.

func (Int64List) ToInterfaceSlice

func (list Int64List) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the current list as a slice of arbitrary type.

func (Int64List) ToList

func (list Int64List) ToList() Int64List

ToList returns the elements of the list as a list, which is an identity operation in this case.

func (Int64List) ToSet

func (list Int64List) ToSet() Int64Set

ToSet returns the elements of the list as a set. The returned set is a shallow copy; the list is not altered.

func (Int64List) ToSlice

func (list Int64List) ToSlice() []int64

ToSlice returns the elements of the list as a slice, which is an identity operation in this case, because the simple list is merely a dressed-up slice.

type Int64MkStringer

type Int64MkStringer interface {
	// String implements the Stringer interface to render the collection as a comma-separated string enclosed
	// in square brackets.
	String() string

	// MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.
	MkString(sep string) string

	// MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.
	MkString3(before, between, after string) string

	// StringList gets a collection of strings that depicts all the elements.
	StringList() []string
}

Int64MkStringer defines an interface for stringer methods on int64 collections.

type Int64Queue added in v0.9.0

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

Int64Queue is a ring buffer containing a slice of type int64. It is optimised for FIFO operations.

func BuildInt64QueueFromChan added in v0.9.0

func BuildInt64QueueFromChan(source <-chan int64) *Int64Queue

BuildInt64QueueFromChan constructs a new Int64Queue from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func NewInt64Queue added in v0.9.0

func NewInt64Queue(capacity int, overwrite bool) *Int64Queue

NewInt64Queue returns a new queue of int64. The behaviour when adding to the queue depends on overwrite. If true, the push operation overwrites oldest values up to the space available, when the queue is full. Otherwise, it refuses to overfill the queue.

func NewInt64SortedQueue added in v0.9.0

func NewInt64SortedQueue(capacity int, overwrite bool, less func(i, j int64) bool) *Int64Queue

NewInt64SortedQueue returns a new queue of int64. The behaviour when adding to the queue depends on overwrite. If true, the push operation overwrites oldest values up to the space available, when the queue is full. Otherwise, it refuses to overfill the queue. If the 'less' comparison function is not nil, elements can be easily sorted.

func (*Int64Queue) Add added in v0.9.0

func (queue *Int64Queue) Add(more ...int64)

Add adds items to the queue. This is a synonym for Push.

func (*Int64Queue) Cap added in v0.9.0

func (queue *Int64Queue) Cap() int

Cap gets the capacity of this queue.

func (*Int64Queue) Clear added in v0.9.0

func (queue *Int64Queue) Clear()

Clear the entire queue.

func (*Int64Queue) Clone added in v0.9.0

func (queue *Int64Queue) Clone() *Int64Queue

Clone returns a shallow copy of the queue. It does not clone the underlying elements.

func (*Int64Queue) Contains added in v0.9.0

func (queue *Int64Queue) Contains(v int64) bool

Contains determines whether a given item is already in the queue, returning true if so.

func (*Int64Queue) ContainsAll added in v0.9.0

func (queue *Int64Queue) ContainsAll(i ...int64) bool

ContainsAll determines whether the given items are all in the queue, returning true if so. This is potentially a slow method and should only be used rarely.

func (*Int64Queue) CountBy added in v0.9.0

func (queue *Int64Queue) CountBy(p func(int64) bool) (result int)

CountBy gives the number elements of Int64Queue that return true for the predicate p.

func (*Int64Queue) DoKeepWhere added in v0.9.0

func (queue *Int64Queue) DoKeepWhere(p func(int64) bool) *Int64Queue

DoKeepWhere modifies a Int64Queue by retaining only those elements that match the predicate p. This is very similar to Filter but alters the queue in place.

The queue is modified and the modified queue is returned.

func (*Int64Queue) Equals added in v0.9.0

func (queue *Int64Queue) Equals(other *Int64Queue) bool

Equals determines if two queues are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for sets to be equal. Nil queues are considered to be empty.

func (*Int64Queue) Exists added in v0.9.0

func (queue *Int64Queue) Exists(p func(int64) bool) bool

Exists verifies that one or more elements of Int64Queue return true for the predicate p. The function should not alter the values via side-effects.

func (*Int64Queue) Filter added in v0.9.0

func (queue *Int64Queue) Filter(p func(int64) bool) *Int64Queue

Filter returns a new Int64Queue whose elements return true for predicate p.

The original queue is not modified. See also DoKeepWhere (which does modify the original queue).

func (*Int64Queue) Find added in v0.9.0

func (queue *Int64Queue) Find(p func(int64) bool) (int64, bool)

Find returns the first int64 that returns true for predicate p. False is returned if none match.

func (*Int64Queue) FlatMap added in v0.9.0

func (queue *Int64Queue) FlatMap(f func(int64) []int64) *Int64Queue

FlatMap returns a new Int64Queue by transforming every element with function f that returns zero or more items in a slice. The resulting queue may have a different size to the original queue. The original queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (*Int64Queue) FlatMapToString added in v0.9.0

func (queue *Int64Queue) FlatMapToString(f func(int64) []string) []string

FlatMapToString returns a new []string by transforming every element with function f that returns zero or more items in a slice. The resulting slice may have a different size to the queue. The queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (*Int64Queue) Fold added in v0.9.0

func (queue *Int64Queue) Fold(initial int64, fn func(int64, int64) int64) int64

Fold aggregates all the values in the queue using a supplied function, starting from some initial value.

func (*Int64Queue) Forall added in v0.9.0

func (queue *Int64Queue) Forall(p func(int64) bool) bool

Forall verifies that all elements of Int64Queue return true for the predicate p. The function should not alter the values via side-effects.

func (*Int64Queue) Foreach added in v0.9.0

func (queue *Int64Queue) Foreach(f func(int64))

Foreach iterates over Int64Queue and executes function f against each element. The function can safely alter the values via side-effects.

func (*Int64Queue) Get added in v0.9.0

func (queue *Int64Queue) Get(i int) int64

Get gets the specified element in the queue. Panics if the index is out of range or the queue is nil.

func (*Int64Queue) Head added in v0.9.0

func (queue *Int64Queue) Head() int64

Head gets the first element in the queue. Head is the opposite of Last. Panics if queue is empty or nil.

func (*Int64Queue) HeadOption added in v0.9.0

func (queue *Int64Queue) HeadOption() (int64, bool)

HeadOption returns the oldest item in the queue without removing it. If the queue is nil or empty, it returns the zero value instead.

func (*Int64Queue) IsEmpty added in v0.9.0

func (queue *Int64Queue) IsEmpty() bool

IsEmpty returns true if the queue is empty.

func (*Int64Queue) IsFull added in v0.9.0

func (queue *Int64Queue) IsFull() bool

IsFull returns true if the queue is full.

func (*Int64Queue) IsOverwriting added in v0.9.0

func (queue *Int64Queue) IsOverwriting() bool

IsOverwriting returns true if the queue is overwriting, false if refusing.

func (*Int64Queue) IsSequence added in v0.9.0

func (queue *Int64Queue) IsSequence() bool

IsSequence returns true for ordered lists and queues.

func (*Int64Queue) IsSet added in v0.9.0

func (queue *Int64Queue) IsSet() bool

IsSet returns false for lists or queues.

func (*Int64Queue) Last added in v0.9.0

func (queue *Int64Queue) Last() int64

Last gets the the newest item in the queue (i.e. last element pushed) without removing it. Last is the opposite of Head. Panics if queue is empty or nil.

func (*Int64Queue) LastOption added in v0.9.0

func (queue *Int64Queue) LastOption() (int64, bool)

LastOption returns the newest item in the queue without removing it. If the queue is nil empty, it returns the zero value instead.

func (*Int64Queue) Len added in v0.9.0

func (queue *Int64Queue) Len() int

Len gets the current length of this queue. This is an alias for Size.

func (*Int64Queue) Less added in v0.9.0

func (queue *Int64Queue) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j. The queue must have been created with a non-nil 'less' comparison function and it must not be empty.

func (*Int64Queue) Map added in v0.9.0

func (queue *Int64Queue) Map(f func(int64) int64) *Int64Queue

Map returns a new Int64Queue by transforming every element with function f. The resulting queue is the same size as the original queue. The original queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (*Int64Queue) MapToString added in v0.9.0

func (queue *Int64Queue) MapToString(f func(int64) string) []string

MapToString returns a new []string by transforming every element with function f. The resulting slice is the same size as the queue. The queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Int64Queue) MarshalJSON added in v0.9.0

func (queue Int64Queue) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this queue type.

func (*Int64Queue) Max added in v0.9.0

func (queue *Int64Queue) Max() (result int64)

Max returns the first element containing the maximum value, when compared to other elements. Panics if the collection is empty.

func (*Int64Queue) MaxBy added in v0.9.0

func (queue *Int64Queue) MaxBy(less func(int64, int64) bool) int64

MaxBy returns an element of Int64Queue containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (*Int64Queue) Min added in v0.9.0

func (queue *Int64Queue) Min() int64

Min returns the first element containing the minimum value, when compared to other elements. Panics if the collection is empty.

func (*Int64Queue) MinBy added in v0.9.0

func (queue *Int64Queue) MinBy(less func(int64, int64) bool) int64

MinBy returns an element of Int64Queue containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (*Int64Queue) MkString added in v0.9.0

func (queue *Int64Queue) MkString(sep string) string

MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.

func (*Int64Queue) MkString3 added in v0.9.0

func (queue *Int64Queue) MkString3(before, between, after string) string

MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.

func (*Int64Queue) NonEmpty added in v0.9.0

func (queue *Int64Queue) NonEmpty() bool

NonEmpty returns true if the queue is not empty.

func (*Int64Queue) Offer added in v0.9.0

func (queue *Int64Queue) Offer(items ...int64) []int64

Offer appends as many items to the end of the queue as it can. If the queue is already full, what happens depends on whether the queue is configured to overwrite. If it is, the oldest items will be overwritten. Otherwise, it will be filled to capacity and any unwritten items are returned.

If the capacity is too small for the number of items, the excess items are returned. The queue capacity is never altered.

func (*Int64Queue) Partition added in v0.9.0

func (queue *Int64Queue) Partition(p func(int64) bool) (*Int64Queue, *Int64Queue)

Partition returns two new Int64Queues whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't. The relative order of the elements in the results is the same as in the original queue.

The original queue is not modified

func (*Int64Queue) Pop added in v0.9.0

func (queue *Int64Queue) Pop(n int) []int64

Pop removes and returns the oldest items from the queue. If the queue is empty, it returns a nil slice. If n is larger than the current queue length, it returns all the available elements, so in this case the returned slice will be shorter than n.

func (*Int64Queue) Pop1 added in v0.9.0

func (queue *Int64Queue) Pop1() (int64, bool)

Pop1 removes and returns the oldest item from the queue. If the queue is empty, it returns the zero value instead. The boolean is true only if the element was available.

func (*Int64Queue) Push added in v0.9.0

func (queue *Int64Queue) Push(items ...int64) *Int64Queue

Push appends items to the end of the queue. If the queue does not have enough space, more will be allocated: how this happens depends on the overwriting mode.

When overwriting, the oldest items are overwritten with the new data; it expands the queue only if there is still not enough space.

Otherwise, the queue might be reallocated if necessary, ensuring that all the data is pushed without any older items being affected.

The modified queue is returned.

func (*Int64Queue) Reallocate added in v0.9.0

func (queue *Int64Queue) Reallocate(capacity int, overwrite bool) *Int64Queue

Reallocate adjusts the allocated capacity of the queue and allows the overwriting behaviour to be changed.

If the new queue capacity is different to the current capacity, the queue is re-allocated to the new capacity. If this is less than the current number of elements, the oldest items in the queue are discarded so that the remaining data can fit in the new space available.

If the new queue capacity is the same as the current capacity, the queue is not altered except for adopting the new overwrite flag's value. Therefore this is the means to change the overwriting behaviour.

Reallocate adjusts the storage space but does not clone the underlying elements.

The queue must not be nil.

func (*Int64Queue) Send added in v0.9.0

func (queue *Int64Queue) Send() <-chan int64

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed. The channel will be closed when all the elements have been sent.

func (*Int64Queue) Size added in v0.9.0

func (queue *Int64Queue) Size() int

Size gets the number of elements currently in this queue. This is an alias for Len.

func (*Int64Queue) Sort added in v0.9.0

func (queue *Int64Queue) Sort()

Sort sorts the queue using the 'less' comparison function, which must not be nil. This function will panic if the collection was created with a nil 'less' function (see NewInt64SortedQueue).

func (*Int64Queue) Space added in v0.9.0

func (queue *Int64Queue) Space() int

Space returns the space available in the queue.

func (*Int64Queue) StableSort added in v0.9.0

func (queue *Int64Queue) StableSort()

StableSort sorts the queue using the 'less' comparison function, which must not be nil. The result is stable so that repeated calls will not arbitrarily swap equal items. This function will panic if the collection was created with a nil 'less' function (see NewInt64SortedQueue).

func (*Int64Queue) String added in v0.9.0

func (queue *Int64Queue) String() string

String implements the Stringer interface to render the queue as a comma-separated string enclosed in square brackets.

func (*Int64Queue) StringList added in v0.9.0

func (queue *Int64Queue) StringList() []string

StringList gets a list of strings that depicts all the elements.

func (*Int64Queue) Sum added in v0.9.0

func (queue *Int64Queue) Sum() int64

Sum returns the sum of all the elements in the queue.

func (*Int64Queue) Swap added in v0.9.0

func (queue *Int64Queue) Swap(i, j int)

Swap swaps the elements with indexes i and j. The queue must not be empty.

func (*Int64Queue) ToInterfaceSlice added in v0.9.0

func (queue *Int64Queue) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the queue as a slice of arbitrary type. The queue is not altered.

func (*Int64Queue) ToSlice added in v0.9.0

func (queue *Int64Queue) ToSlice() []int64

ToSlice returns the elements of the queue as a slice. The queue is not altered.

func (*Int64Queue) UnmarshalJSON added in v0.9.0

func (queue *Int64Queue) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this queue type.

type Int64Sequence added in v0.9.0

type Int64Sequence interface {
	Int64Collection

	// Head gets the first element in the sequence. Head plus Tail include the whole sequence. Head is the opposite of Last.
	Head() int64

	// HeadOption gets the first element in the sequence, if possible.
	HeadOption() (int64, bool)

	// Last gets the last element in the sequence. Init plus Last include the whole sequence. Last is the opposite of Head.
	Last() int64

	// LastOption gets the last element in the sequence, if possible.
	LastOption() (int64, bool)
}

Int64Sequence defines an interface for sequence methods on int64.

type Int64Set

type Int64Set map[int64]struct{}

Int64Set is the primary type that represents a set

func BuildInt64SetFromChan

func BuildInt64SetFromChan(source <-chan int64) Int64Set

BuildInt64SetFromChan constructs a new Int64Set from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func ConvertInt64Set

func ConvertInt64Set(values ...interface{}) (Int64Set, bool)

ConvertInt64Set constructs a new set containing the supplied values, if any. The returned boolean will be false if any of the values could not be converted correctly. The returned set will contain all the values that were correctly converted.

func NewInt64Set

func NewInt64Set(values ...int64) Int64Set

NewInt64Set creates and returns a reference to an empty set.

func (Int64Set) Add

func (set Int64Set) Add(more ...int64) Int64Set

Add adds items to the current set, returning the modified set.

func (Int64Set) Append

func (set Int64Set) Append(more ...int64) Int64Set

Append inserts more items into a clone of the set. It returns the augmented set. The original set is unmodified.

func (Int64Set) Cardinality

func (set Int64Set) Cardinality() int

Cardinality returns how many items are currently in the set. This is a synonym for Size.

func (*Int64Set) Clear

func (set *Int64Set) Clear()

Clear the entire set. Aterwards, it will be an empty set.

func (Int64Set) Clone

func (set Int64Set) Clone() Int64Set

Clone returns a shallow copy of the set. It does not clone the underlying elements.

func (Int64Set) Contains

func (set Int64Set) Contains(i int64) bool

Contains determines whether a given item is already in the set, returning true if so.

func (Int64Set) ContainsAll

func (set Int64Set) ContainsAll(i ...int64) bool

ContainsAll determines whether a given item is already in the set, returning true if so.

func (Int64Set) CountBy

func (set Int64Set) CountBy(p func(int64) bool) (result int)

CountBy gives the number elements of Int64Set that return true for the predicate p.

func (Int64Set) Difference

func (set Int64Set) Difference(other Int64Set) Int64Set

Difference returns a new set with items in the current set but not in the other set

func (Int64Set) Equals

func (set Int64Set) Equals(other Int64Set) bool

Equals determines whether two sets are equal to each other, returning true if so. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for sets to be equal.

func (Int64Set) Exists

func (set Int64Set) Exists(p func(int64) bool) bool

Exists applies a predicate p to every element in the set. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (Int64Set) Filter

func (set Int64Set) Filter(p func(int64) bool) Int64Set

Filter returns a new Int64Set whose elements return true for the predicate p.

The original set is not modified

func (Int64Set) Find

func (set Int64Set) Find(p func(int64) bool) (int64, bool)

Find returns the first int64 that returns true for the predicate p. If there are many matches one is arbtrarily chosen. False is returned if none match.

func (Int64Set) FlatMap

func (set Int64Set) FlatMap(f func(int64) []int64) Int64Set

FlatMap returns a new Int64Set by transforming every element with a function f that returns zero or more items in a slice. The resulting set may have a different size to the original set. The original set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Int64Set) FlatMapToString

func (set Int64Set) FlatMapToString(f func(int64) []string) []string

FlatMapToString returns a new []string by transforming every element with function f that returns zero or more items in a slice. The resulting slice may have a different size to the set. The set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Int64Set) Fold added in v0.9.0

func (set Int64Set) Fold(initial int64, fn func(int64, int64) int64) int64

Fold aggregates all the values in the set using a supplied function, starting from some initial value.

func (Int64Set) Forall

func (set Int64Set) Forall(p func(int64) bool) bool

Forall applies a predicate function p to every element in the set. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (Int64Set) Foreach

func (set Int64Set) Foreach(f func(int64))

Foreach iterates over the set and executes the function f against each element.

func (Int64Set) Intersect

func (set Int64Set) Intersect(other Int64Set) Int64Set

Intersect returns a new set with items that exist only in both sets.

func (Int64Set) IsEmpty

func (set Int64Set) IsEmpty() bool

IsEmpty returns true if the set is empty.

func (Int64Set) IsSequence

func (set Int64Set) IsSequence() bool

IsSequence returns true for lists and queues.

func (Int64Set) IsSet

func (set Int64Set) IsSet() bool

IsSet returns false for lists or queues.

func (Int64Set) IsSubset

func (set Int64Set) IsSubset(other Int64Set) bool

IsSubset determines whether every item in the other set is in this set, returning true if so.

func (Int64Set) IsSuperset

func (set Int64Set) IsSuperset(other Int64Set) bool

IsSuperset determines whether every item of this set is in the other set, returning true if so.

func (Int64Set) Map

func (set Int64Set) Map(f func(int64) int64) Int64Set

Map returns a new Int64Set by transforming every element with a function f. The original set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Int64Set) MapToString

func (set Int64Set) MapToString(f func(int64) string) []string

MapToString returns a new []string by transforming every element with function f. The resulting slice is the same size as the set. The set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Int64Set) MarshalJSON

func (set Int64Set) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this set type.

func (Int64Set) Max

func (set Int64Set) Max() int64

Max returns the first element containing the maximum value, when compared to other elements. Panics if the collection is empty.

func (Int64Set) MaxBy

func (set Int64Set) MaxBy(less func(int64, int64) bool) int64

MaxBy returns an element of Int64Set containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (Int64Set) Min

func (set Int64Set) Min() int64

Min returns the first element containing the minimum value, when compared to other elements. Panics if the collection is empty.

func (Int64Set) MinBy

func (set Int64Set) MinBy(less func(int64, int64) bool) int64

MinBy returns an element of Int64Set containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (Int64Set) MkString

func (set Int64Set) MkString(sep string) string

MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.

func (Int64Set) MkString3

func (set Int64Set) MkString3(before, between, after string) string

MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.

func (Int64Set) NonEmpty

func (set Int64Set) NonEmpty() bool

NonEmpty returns true if the set is not empty.

func (Int64Set) Partition

func (set Int64Set) Partition(p func(int64) bool) (Int64Set, Int64Set)

Partition returns two new Int64Sets whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't.

The original set is not modified

func (Int64Set) Remove

func (set Int64Set) Remove(i int64)

Remove a single item from the set.

func (Int64Set) Send

func (set Int64Set) Send() <-chan int64

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed

func (Int64Set) Size

func (set Int64Set) Size() int

Size returns how many items are currently in the set. This is a synonym for Cardinality.

func (Int64Set) String

func (set Int64Set) String() string

String implements the Stringer interface to render the set as a comma-separated string enclosed in square brackets.

func (Int64Set) StringList

func (set Int64Set) StringList() []string

StringList gets a list of strings that depicts all the elements.

func (Int64Set) StringMap

func (set Int64Set) StringMap() map[string]bool

StringMap renders the set as a map of strings. The value of each item in the set becomes stringified as a key in the resulting map.

func (Int64Set) Sum

func (set Int64Set) Sum() int64

Sum returns the sum of all the elements in the set.

func (Int64Set) SymmetricDifference

func (set Int64Set) SymmetricDifference(other Int64Set) Int64Set

SymmetricDifference returns a new set with items in the current set or the other set but not in both.

func (Int64Set) ToInterfaceSlice

func (set Int64Set) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the current set as a slice of arbitrary type.

func (Int64Set) ToList

func (set Int64Set) ToList() Int64List

ToList returns the elements of the set as a list. The returned list is a shallow copy; the set is not altered.

func (Int64Set) ToSet

func (set Int64Set) ToSet() Int64Set

ToSet returns the set; this is an identity operation in this case.

func (Int64Set) ToSlice

func (set Int64Set) ToSlice() []int64

ToSlice returns the elements of the current set as a slice.

func (Int64Set) Union

func (set Int64Set) Union(other Int64Set) Int64Set

Union returns a new set with all items in both sets.

func (Int64Set) UnmarshalJSON

func (set Int64Set) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this set type.

type Int64Sizer

type Int64Sizer interface {
	// IsEmpty tests whether Int64Collection is empty.
	IsEmpty() bool

	// NonEmpty tests whether Int64Collection is empty.
	NonEmpty() bool

	// Size returns the number of items in the collection - an alias of Len().
	Size() int
}

Int64Sizer defines an interface for sizing methods on int64 collections.

type Int64StringMap added in v0.4.0

type Int64StringMap map[int64]string

Int64StringMap is the primary type that represents a map

func NewInt64StringMap added in v0.4.0

func NewInt64StringMap(kv ...Int64StringTuple) Int64StringMap

NewInt64StringMap creates and returns a reference to a map, optionally containing some items.

func NewInt64StringMap1 added in v0.4.0

func NewInt64StringMap1(k int64, v string) Int64StringMap

NewInt64StringMap1 creates and returns a reference to a map containing one item.

func (*Int64StringMap) Clear added in v0.4.0

func (mm *Int64StringMap) Clear()

Clear clears the entire map.

func (Int64StringMap) Clone added in v0.4.0

func (mm Int64StringMap) Clone() Int64StringMap

Clone returns a shallow copy of the map. It does not clone the underlying elements.

func (Int64StringMap) ContainsAllKeys added in v0.4.0

func (mm Int64StringMap) ContainsAllKeys(kk ...int64) bool

ContainsAllKeys determines if the given items are all in the map.

func (Int64StringMap) ContainsKey added in v0.4.0

func (mm Int64StringMap) ContainsKey(k int64) bool

ContainsKey determines if a given item is already in the map.

func (Int64StringMap) DropWhere added in v0.4.0

func (mm Int64StringMap) DropWhere(fn func(int64, string) bool) Int64StringTuples

DropWhere applies a predicate function to every element in the map. If the function returns true, the element is dropped from the map. This is similar to Filter except that the map is modified.

func (Int64StringMap) Equals added in v0.4.0

func (mm Int64StringMap) Equals(other Int64StringMap) bool

Equals determines if two maps are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for maps to be equal.

func (Int64StringMap) Exists added in v0.4.0

func (mm Int64StringMap) Exists(p func(int64, string) bool) bool

Exists applies the predicate p to every element in the map. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (Int64StringMap) Filter added in v0.4.0

func (mm Int64StringMap) Filter(p func(int64, string) bool) Int64StringMap

Filter applies the predicate p to every element in the map and returns a copied map containing only the elements for which the predicate returned true. The original map is not modified.

func (Int64StringMap) Find added in v0.4.0

func (mm Int64StringMap) Find(p func(int64, string) bool) (Int64StringTuple, bool)

Find returns the first string that returns true for the predicate p. False is returned if none match. The original map is not modified.

func (Int64StringMap) FlatMap added in v0.4.0

FlatMap returns a new StringMap by transforming every element with the function f that returns zero or more items in a slice. The resulting map may have a different size to the original map. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Int64StringMap) Forall added in v0.4.0

func (mm Int64StringMap) Forall(p func(int64, string) bool) bool

Forall applies the predicate p to every element in the map. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (Int64StringMap) Foreach added in v0.4.0

func (mm Int64StringMap) Foreach(f func(int64, string))

Foreach applies the function f to every element in the map. The function can safely alter the values via side-effects.

func (Int64StringMap) Get added in v0.4.0

func (mm Int64StringMap) Get(k int64) (string, bool)

Get returns one of the items in the map, if present.

func (Int64StringMap) IsEmpty added in v0.4.0

func (mm Int64StringMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (Int64StringMap) Keys added in v0.4.0

func (mm Int64StringMap) Keys() Int64List

Keys returns the keys of the current map as a slice.

func (Int64StringMap) Map added in v0.4.0

func (mm Int64StringMap) Map(f func(int64, string) (int64, string)) Int64StringMap

Map returns a new StringMap by transforming every element with the function f. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Int64StringMap) MkString added in v0.4.0

func (mm Int64StringMap) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (Int64StringMap) MkString4 added in v0.7.0

func (mm Int64StringMap) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (Int64StringMap) NonEmpty added in v0.4.0

func (mm Int64StringMap) NonEmpty() bool

NonEmpty returns true if the map is not empty.

func (Int64StringMap) OrderedSlice added in v0.6.0

func (mm Int64StringMap) OrderedSlice(keys Int64List) Int64StringTuples

OrderedSlice returns the key/value pairs as a slice in the order specified by keys.

func (Int64StringMap) Partition added in v0.4.0

func (mm Int64StringMap) Partition(p func(int64, string) bool) (matching Int64StringMap, others Int64StringMap)

Partition applies the predicate p to every element in the map. It divides the map into two copied maps, the first containing all the elements for which the predicate returned true, and the second containing all the others. The original map is not modified.

func (Int64StringMap) Pop added in v0.4.0

func (mm Int64StringMap) Pop(k int64) (string, bool)

Pop removes a single item from the map, returning the value present prior to removal.

func (Int64StringMap) Put added in v0.4.0

func (mm Int64StringMap) Put(k int64, v string) bool

Put adds an item to the current map, replacing any prior value.

func (Int64StringMap) Remove added in v0.4.0

func (mm Int64StringMap) Remove(k int64)

Remove a single item from the map.

func (Int64StringMap) Size added in v0.4.0

func (mm Int64StringMap) Size() int

Size returns how many items are currently in the map. This is a synonym for Len.

func (Int64StringMap) String added in v0.4.0

func (mm Int64StringMap) String() string

String implements the Stringer interface to render the set as a comma-separated string enclosed in square brackets.

func (Int64StringMap) ToSlice added in v0.4.0

func (mm Int64StringMap) ToSlice() Int64StringTuples

ToSlice returns the key/value pairs as a slice.

func (Int64StringMap) Values added in v0.4.0

func (mm Int64StringMap) Values() StringList

Values returns the values of the current map as a slice.

type Int64StringTuple added in v0.4.0

type Int64StringTuple struct {
	Key int64
	Val string
}

Int64StringTuple represents a key/value pair.

func (Int64StringTuple) MarshalJSON added in v0.6.0

func (t Int64StringTuple) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding.Marshaler interface.

func (Int64StringTuple) UnmarshalJSON added in v0.6.0

func (t Int64StringTuple) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this tuple type.

type Int64StringTuples added in v0.4.0

type Int64StringTuples []Int64StringTuple

Int64StringTuples can be used as a builder for unmodifiable maps.

func Int64StringZip added in v0.4.0

func Int64StringZip(keys ...int64) Int64StringTuples

Int64StringZip is used with the Values method to zip (i.e. interleave) a slice of keys with a slice of values. These can then be passed in to the NewInt64StringMap constructor function.

func (Int64StringTuples) Append1 added in v0.4.0

Append1 adds one item.

func (Int64StringTuples) Append2 added in v0.4.0

func (ts Int64StringTuples) Append2(k1 int64, v1 string, k2 int64, v2 string) Int64StringTuples

Append2 adds two items.

func (Int64StringTuples) Append3 added in v0.4.0

func (ts Int64StringTuples) Append3(k1 int64, v1 string, k2 int64, v2 string, k3 int64, v3 string) Int64StringTuples

Append3 adds three items.

func (Int64StringTuples) MkString added in v0.6.0

func (ts Int64StringTuples) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (Int64StringTuples) MkString4 added in v0.7.0

func (ts Int64StringTuples) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (Int64StringTuples) String added in v0.6.0

func (ts Int64StringTuples) String() string

func (Int64StringTuples) ToMap added in v0.6.0

func (ts Int64StringTuples) ToMap() Int64StringMap

ToMap converts the tuples to a map.

func (Int64StringTuples) Values added in v0.4.0

func (ts Int64StringTuples) Values(values ...string) Int64StringTuples

Values sets the values in a tuple slice. Use this with Int64StringZip.

type IntCollection

type IntCollection interface {
	IntSizer
	IntMkStringer

	// IsSequence returns true for lists and queues.
	IsSequence() bool

	// IsSet returns false for lists and queues.
	IsSet() bool

	// ToSlice returns a shallow copy as a plain slice.
	ToSlice() []int

	// ToInterfaceSlice returns a shallow copy as a slice of arbitrary type.
	ToInterfaceSlice() []interface{}

	// Exists verifies that one or more elements of IntCollection return true for the predicate p.
	Exists(p func(int) bool) bool

	// Forall verifies that all elements of IntCollection return true for the predicate p.
	Forall(p func(int) bool) bool

	// Foreach iterates over IntCollection and executes the function f against each element.
	Foreach(f func(int))

	// Find returns the first int that returns true for the predicate p.
	// False is returned if none match.
	Find(p func(int) bool) (int, bool)

	// Send returns a channel that will send all the elements in order. Can be used with the plumbing code, for example.
	// A goroutine is created to send the elements; this only terminates when all the elements have been consumed
	Send() <-chan int

	// CountBy gives the number elements of IntCollection that return true for the predicate p.
	CountBy(p func(int) bool) int

	// Contains determines whether a given item is already in the collection, returning true if so.
	Contains(v int) bool

	// ContainsAll determines whether the given items are all in the collection, returning true if so.
	ContainsAll(v ...int) bool

	// Min returns the minimum value of all the items in the collection. Panics if there are no elements.
	Min() int

	// Max returns the minimum value of all the items in the collection. Panics if there are no elements.
	Max() int

	// MinBy returns an element of IntCollection containing the minimum value, when compared to other elements
	// using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such
	// element is returned. Panics if there are no elements.
	MinBy(less func(int, int) bool) int

	// MaxBy returns an element of IntCollection containing the maximum value, when compared to other elements
	// using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such
	// element is returned. Panics if there are no elements.
	MaxBy(less func(int, int) bool) int

	// Fold aggregates all the values in the collection using a supplied function, starting from some initial value.
	Fold(initial int, fn func(int, int) int) int

	// Sum returns the sum of all the elements in the collection.
	Sum() int
}

IntCollection defines an interface for common collection methods on int.

type IntIntMap

type IntIntMap map[int]int

IntIntMap is the primary type that represents a map

func NewIntIntMap

func NewIntIntMap(kv ...IntIntTuple) IntIntMap

NewIntIntMap creates and returns a reference to a map, optionally containing some items.

func NewIntIntMap1

func NewIntIntMap1(k int, v int) IntIntMap

NewIntIntMap1 creates and returns a reference to a map containing one item.

func (*IntIntMap) Clear

func (mm *IntIntMap) Clear()

Clear clears the entire map.

func (IntIntMap) Clone

func (mm IntIntMap) Clone() IntIntMap

Clone returns a shallow copy of the map. It does not clone the underlying elements.

func (IntIntMap) ContainsAllKeys

func (mm IntIntMap) ContainsAllKeys(kk ...int) bool

ContainsAllKeys determines if the given items are all in the map.

func (IntIntMap) ContainsKey

func (mm IntIntMap) ContainsKey(k int) bool

ContainsKey determines if a given item is already in the map.

func (IntIntMap) DropWhere

func (mm IntIntMap) DropWhere(fn func(int, int) bool) IntIntTuples

DropWhere applies a predicate function to every element in the map. If the function returns true, the element is dropped from the map. This is similar to Filter except that the map is modified.

func (IntIntMap) Equals

func (mm IntIntMap) Equals(other IntIntMap) bool

Equals determines if two maps are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for maps to be equal.

func (IntIntMap) Exists

func (mm IntIntMap) Exists(p func(int, int) bool) bool

Exists applies the predicate p to every element in the map. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (IntIntMap) Filter

func (mm IntIntMap) Filter(p func(int, int) bool) IntIntMap

Filter applies the predicate p to every element in the map and returns a copied map containing only the elements for which the predicate returned true. The original map is not modified.

func (IntIntMap) Find

func (mm IntIntMap) Find(p func(int, int) bool) (IntIntTuple, bool)

Find returns the first int that returns true for the predicate p. False is returned if none match. The original map is not modified.

func (IntIntMap) FlatMap

func (mm IntIntMap) FlatMap(f func(int, int) []IntIntTuple) IntIntMap

FlatMap returns a new IntMap by transforming every element with the function f that returns zero or more items in a slice. The resulting map may have a different size to the original map. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (IntIntMap) Forall

func (mm IntIntMap) Forall(p func(int, int) bool) bool

Forall applies the predicate p to every element in the map. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (IntIntMap) Foreach

func (mm IntIntMap) Foreach(f func(int, int))

Foreach applies the function f to every element in the map. The function can safely alter the values via side-effects.

func (IntIntMap) Get

func (mm IntIntMap) Get(k int) (int, bool)

Get returns one of the items in the map, if present.

func (IntIntMap) IsEmpty

func (mm IntIntMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (IntIntMap) Keys

func (mm IntIntMap) Keys() IntList

Keys returns the keys of the current map as a slice.

func (IntIntMap) Map

func (mm IntIntMap) Map(f func(int, int) (int, int)) IntIntMap

Map returns a new IntMap by transforming every element with the function f. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (IntIntMap) MkString

func (mm IntIntMap) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (IntIntMap) MkString4 added in v0.7.0

func (mm IntIntMap) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (IntIntMap) NonEmpty

func (mm IntIntMap) NonEmpty() bool

NonEmpty returns true if the map is not empty.

func (IntIntMap) OrderedSlice added in v0.6.0

func (mm IntIntMap) OrderedSlice(keys IntList) IntIntTuples

OrderedSlice returns the key/value pairs as a slice in the order specified by keys.

func (IntIntMap) Partition

func (mm IntIntMap) Partition(p func(int, int) bool) (matching IntIntMap, others IntIntMap)

Partition applies the predicate p to every element in the map. It divides the map into two copied maps, the first containing all the elements for which the predicate returned true, and the second containing all the others. The original map is not modified.

func (IntIntMap) Pop

func (mm IntIntMap) Pop(k int) (int, bool)

Pop removes a single item from the map, returning the value present prior to removal.

func (IntIntMap) Put

func (mm IntIntMap) Put(k int, v int) bool

Put adds an item to the current map, replacing any prior value.

func (IntIntMap) Remove

func (mm IntIntMap) Remove(k int)

Remove a single item from the map.

func (IntIntMap) Size

func (mm IntIntMap) Size() int

Size returns how many items are currently in the map. This is a synonym for Len.

func (IntIntMap) String

func (mm IntIntMap) String() string

String implements the Stringer interface to render the set as a comma-separated string enclosed in square brackets.

func (IntIntMap) ToSlice

func (mm IntIntMap) ToSlice() IntIntTuples

ToSlice returns the key/value pairs as a slice.

func (IntIntMap) Values

func (mm IntIntMap) Values() IntList

Values returns the values of the current map as a slice.

type IntIntTuple

type IntIntTuple struct {
	Key int
	Val int
}

IntIntTuple represents a key/value pair.

func (IntIntTuple) MarshalJSON added in v0.6.0

func (t IntIntTuple) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding.Marshaler interface.

func (IntIntTuple) UnmarshalJSON added in v0.6.0

func (t IntIntTuple) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this tuple type.

type IntIntTuples

type IntIntTuples []IntIntTuple

IntIntTuples can be used as a builder for unmodifiable maps.

func IntIntZip

func IntIntZip(keys ...int) IntIntTuples

IntIntZip is used with the Values method to zip (i.e. interleave) a slice of keys with a slice of values. These can then be passed in to the NewIntIntMap constructor function.

func (IntIntTuples) Append1

func (ts IntIntTuples) Append1(k int, v int) IntIntTuples

Append1 adds one item.

func (IntIntTuples) Append2

func (ts IntIntTuples) Append2(k1 int, v1 int, k2 int, v2 int) IntIntTuples

Append2 adds two items.

func (IntIntTuples) Append3

func (ts IntIntTuples) Append3(k1 int, v1 int, k2 int, v2 int, k3 int, v3 int) IntIntTuples

Append3 adds three items.

func (IntIntTuples) MkString added in v0.6.0

func (ts IntIntTuples) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (IntIntTuples) MkString4 added in v0.7.0

func (ts IntIntTuples) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (IntIntTuples) String added in v0.6.0

func (ts IntIntTuples) String() string

func (IntIntTuples) ToMap added in v0.6.0

func (ts IntIntTuples) ToMap() IntIntMap

ToMap converts the tuples to a map.

func (IntIntTuples) Values

func (ts IntIntTuples) Values(values ...int) IntIntTuples

Values sets the values in a tuple slice. Use this with IntIntZip.

type IntList

type IntList []int

IntList is a slice of type int. Use it where you would use []int. To add items to the list, simply use the normal built-in append function.

List values follow a similar pattern to Scala Lists and LinearSeqs in particular. For comparison with Scala, see e.g. http://www.scala-lang.org/api/2.11.7/#scala.collection.LinearSeq

func BuildIntListFromChan

func BuildIntListFromChan(source <-chan int) IntList

BuildIntListFromChan constructs a new IntList from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func ConvertIntList

func ConvertIntList(values ...interface{}) (IntList, bool)

ConvertIntList constructs a new list containing the supplied values, if any. The returned boolean will be false if any of the values could not be converted correctly. The returned list will contain all the values that were correctly converted. Conversions are provided from all built-in numeric types.

func MakeIntList

func MakeIntList(length, capacity int) IntList

MakeIntList makes an empty list with both length and capacity initialised.

func NewIntList

func NewIntList(values ...int) IntList

NewIntList constructs a new list containing the supplied values, if any.

func (IntList) Clone

func (list IntList) Clone() IntList

Clone returns a shallow copy of the list. It does not clone the underlying elements.

func (IntList) Contains

func (list IntList) Contains(v int) bool

Contains determines whether a given item is already in the list, returning true if so.

func (IntList) ContainsAll

func (list IntList) ContainsAll(i ...int) bool

ContainsAll determines whether the given items are all in the list, returning true if so. This is potentially a slow method and should only be used rarely.

func (IntList) CountBy

func (list IntList) CountBy(p func(int) bool) (result int)

CountBy gives the number elements of IntList that return true for the predicate p.

func (IntList) DistinctBy

func (list IntList) DistinctBy(equal func(int, int) bool) IntList

DistinctBy returns a new IntList whose elements are unique, where equality is defined by the equal function.

func (IntList) DoReverse

func (list IntList) DoReverse() IntList

DoReverse alters a IntList with all elements in the reverse order. Unlike Reverse, it does not allocate new memory.

The list is modified and the modified list is returned.

func (IntList) DoShuffle

func (list IntList) DoShuffle() IntList

DoShuffle returns a shuffled IntList, using a version of the Fisher-Yates shuffle.

The list is modified and the modified list is returned.

func (IntList) Drop

func (list IntList) Drop(n int) IntList

Drop returns a slice of IntList without the leading n elements of the source list. If n is greater than or equal to the size of the list, an empty list is returned.

The original list is not modified.

func (IntList) DropLast

func (list IntList) DropLast(n int) IntList

DropLast returns a slice of IntList without the trailing n elements of the source list. If n is greater than or equal to the size of the list, an empty list is returned.

The original list is not modified.

func (IntList) DropWhile

func (list IntList) DropWhile(p func(int) bool) IntList

DropWhile returns a new IntList containing the trailing elements of the source list. Whilst the predicate p returns true, elements are excluded from the result. Once predicate p returns false, all remaining elements are added.

The original list is not modified.

func (IntList) Equals

func (list IntList) Equals(other IntList) bool

Equals determines if two lists are equal to each other. If they both are the same size and have the same items in the same order, they are considered equal. Order of items is not relevent for sets to be equal.

func (IntList) Exists

func (list IntList) Exists(p func(int) bool) bool

Exists verifies that one or more elements of IntList return true for the predicate p.

func (IntList) Filter

func (list IntList) Filter(p func(int) bool) IntList

Filter returns a new IntList whose elements return true for predicate p.

The original list is not modified.

func (IntList) Find

func (list IntList) Find(p func(int) bool) (int, bool)

Find returns the first int that returns true for predicate p. False is returned if none match.

func (IntList) FlatMap

func (list IntList) FlatMap(f func(int) []int) IntList

FlatMap returns a new IntList by transforming every element with function f that returns zero or more items in a slice. The resulting list may have a different size to the original list. The original list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (IntList) FlatMapToString added in v0.3.0

func (list IntList) FlatMapToString(f func(int) []string) []string

FlatMapToString returns a new []string by transforming every element with function f that returns zero or more items in a slice. The resulting slice may have a different size to the list. The list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (IntList) Fold added in v0.9.0

func (list IntList) Fold(initial int, fn func(int, int) int) int

Fold aggregates all the values in the list using a supplied function, starting from some initial value.

func (IntList) Forall

func (list IntList) Forall(p func(int) bool) bool

Forall verifies that all elements of IntList return true for the predicate p.

func (IntList) Foreach

func (list IntList) Foreach(f func(int))

Foreach iterates over IntList and executes function f against each element.

func (IntList) Get

func (list IntList) Get(i int) int

Get gets the specified element in the list. Panics if the index is out of range or the list is nil. The simple list is a dressed-up slice and normal slice operations will also work.

func (IntList) GobDecode

func (list IntList) GobDecode(b []byte) error

GobDecode implements 'gob' decoding for this list type. You must register int with the 'gob' package before this method is used.

func (IntList) GobEncode

func (list IntList) GobEncode() ([]byte, error)

GobEncode implements 'gob' encoding for this list type. You must register int with the 'gob' package before this method is used.

func (IntList) Head

func (list IntList) Head() int

Head gets the first element in the list. Head plus Tail include the whole list. Head is the opposite of Last. Panics if list is empty or nil.

func (IntList) HeadOption

func (list IntList) HeadOption() (int, bool)

HeadOption gets the first element in the list, if possible. Otherwise returns the zero value.

func (IntList) IndexWhere

func (list IntList) IndexWhere(p func(int) bool) int

IndexWhere finds the index of the first element satisfying predicate p. If none exists, -1 is returned.

func (IntList) IndexWhere2

func (list IntList) IndexWhere2(p func(int) bool, from int) int

IndexWhere2 finds the index of the first element satisfying predicate p at or after some start index. If none exists, -1 is returned.

func (IntList) Init

func (list IntList) Init() IntList

Init gets everything except the last. Init plus Last include the whole list. Init is the opposite of Tail. Panics if list is empty or nil.

func (IntList) IsEmpty

func (list IntList) IsEmpty() bool

IsEmpty tests whether IntList is empty.

func (IntList) IsSequence

func (list IntList) IsSequence() bool

IsSequence returns true for lists and queues.

func (IntList) IsSet

func (list IntList) IsSet() bool

IsSet returns false for lists or queues.

func (IntList) Last

func (list IntList) Last() int

Last gets the last element in the list. Init plus Last include the whole list. Last is the opposite of Head. Panics if list is empty or nil.

func (IntList) LastIndexWhere

func (list IntList) LastIndexWhere(p func(int) bool) int

LastIndexWhere finds the index of the last element satisfying predicate p. If none exists, -1 is returned.

func (IntList) LastIndexWhere2

func (list IntList) LastIndexWhere2(p func(int) bool, before int) int

LastIndexWhere2 finds the index of the last element satisfying predicate p at or before some start index. If none exists, -1 is returned.

func (IntList) LastOption

func (list IntList) LastOption() (int, bool)

LastOption gets the last element in the list, if possible. Otherwise returns the zero value.

func (IntList) Len

func (list IntList) Len() int

Len returns the number of items in the list - an alias of Size(). This is one of the three methods in the standard sort.Interface.

func (IntList) Map

func (list IntList) Map(f func(int) int) IntList

Map returns a new IntList by transforming every element with function f. The resulting list is the same size as the original list. The original list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (IntList) MapToString added in v0.3.0

func (list IntList) MapToString(f func(int) string) []string

MapToString returns a new []string by transforming every element with function f. The resulting slice is the same size as the list. The list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (IntList) Max

func (list IntList) Max() (result int)

Max returns the first element containing the maximum value, when compared to other elements. Panics if the collection is empty.

func (IntList) MaxBy

func (list IntList) MaxBy(less func(int, int) bool) int

MaxBy returns an element of IntList containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (IntList) Min

func (list IntList) Min() int

Min returns the first element containing the minimum value, when compared to other elements. Panics if the collection is empty.

func (IntList) MinBy

func (list IntList) MinBy(less func(int, int) bool) int

MinBy returns an element of IntList containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (IntList) MkString

func (list IntList) MkString(sep string) string

MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.

func (IntList) MkString3

func (list IntList) MkString3(before, between, after string) string

MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.

func (IntList) NonEmpty

func (list IntList) NonEmpty() bool

NonEmpty tests whether IntList is empty.

func (IntList) Partition

func (list IntList) Partition(p func(int) bool) (IntList, IntList)

Partition returns two new IntLists whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't. The relative order of the elements in the results is the same as in the original list.

The original list is not modified.

func (IntList) Reverse

func (list IntList) Reverse() IntList

Reverse returns a copy of IntList with all elements in the reverse order.

The original list is not modified.

func (IntList) Send

func (list IntList) Send() <-chan int

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed. The channel will be closed when all the elements have been sent.

func (IntList) Shuffle

func (list IntList) Shuffle() IntList

Shuffle returns a shuffled copy of IntList, using a version of the Fisher-Yates shuffle.

The original list is not modified.

func (IntList) Size

func (list IntList) Size() int

Size returns the number of items in the list - an alias of Len().

func (IntList) SortBy

func (list IntList) SortBy(less func(i, j int) bool) IntList

SortBy alters the list so that the elements are sorted by a specified ordering. Sorting happens in-place; the modified list is returned.

func (IntList) Sorted

func (list IntList) Sorted() IntList

Sorted alters the list so that the elements are sorted by their natural ordering. Sorting happens in-place; the modified list is returned.

func (IntList) StableSortBy

func (list IntList) StableSortBy(less func(i, j int) bool) IntList

StableSortBy alters the list so that the elements are sorted by a specified ordering. Sorting happens in-place; the modified list is returned. The algorithm keeps the original order of equal elements.

func (IntList) StableSorted

func (list IntList) StableSorted() IntList

StableSorted alters the list so that the elements are sorted by their natural ordering. Sorting happens in-place; the modified list is returned.

func (IntList) String

func (list IntList) String() string

String implements the Stringer interface to render the list as a comma-separated string enclosed in square brackets.

func (IntList) StringList

func (list IntList) StringList() []string

StringList gets a list of strings that depicts all the elements.

func (IntList) Sum

func (list IntList) Sum() int

Sum returns the sum of all the elements in the list.

func (IntList) Swap

func (list IntList) Swap(i, j int)

Swap exchanges two elements, which is necessary during sorting etc. This is one of the three methods in the standard sort.Interface.

func (IntList) Tail

func (list IntList) Tail() IntList

Tail gets everything except the head. Head plus Tail include the whole list. Tail is the opposite of Init. Panics if list is empty or nil.

func (IntList) Take

func (list IntList) Take(n int) IntList

Take returns a slice of IntList containing the leading n elements of the source list. If n is greater than or equal to the size of the list, the whole original list is returned.

func (IntList) TakeLast

func (list IntList) TakeLast(n int) IntList

TakeLast returns a slice of IntList containing the trailing n elements of the source list. If n is greater than or equal to the size of the list, the whole original list is returned.

The original list is not modified.

func (IntList) TakeWhile

func (list IntList) TakeWhile(p func(int) bool) IntList

TakeWhile returns a new IntList containing the leading elements of the source list. Whilst the predicate p returns true, elements are added to the result. Once predicate p returns false, all remaining elements are excluded.

The original list is not modified.

func (IntList) ToInterfaceSlice

func (list IntList) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the current list as a slice of arbitrary type.

func (IntList) ToList

func (list IntList) ToList() IntList

ToList returns the elements of the list as a list, which is an identity operation in this case.

func (IntList) ToSet

func (list IntList) ToSet() IntSet

ToSet returns the elements of the list as a set. The returned set is a shallow copy; the list is not altered.

func (IntList) ToSlice

func (list IntList) ToSlice() []int

ToSlice returns the elements of the list as a slice, which is an identity operation in this case, because the simple list is merely a dressed-up slice.

type IntMkStringer

type IntMkStringer interface {
	// String implements the Stringer interface to render the collection as a comma-separated string enclosed
	// in square brackets.
	String() string

	// MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.
	MkString(sep string) string

	// MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.
	MkString3(before, between, after string) string

	// StringList gets a collection of strings that depicts all the elements.
	StringList() []string
}

IntMkStringer defines an interface for stringer methods on int collections.

type IntQueue added in v0.9.0

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

IntQueue is a ring buffer containing a slice of type int. It is optimised for FIFO operations.

func BuildIntQueueFromChan added in v0.9.0

func BuildIntQueueFromChan(source <-chan int) *IntQueue

BuildIntQueueFromChan constructs a new IntQueue from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func NewIntQueue added in v0.9.0

func NewIntQueue(capacity int, overwrite bool) *IntQueue

NewIntQueue returns a new queue of int. The behaviour when adding to the queue depends on overwrite. If true, the push operation overwrites oldest values up to the space available, when the queue is full. Otherwise, it refuses to overfill the queue.

func NewIntSortedQueue added in v0.9.0

func NewIntSortedQueue(capacity int, overwrite bool, less func(i, j int) bool) *IntQueue

NewIntSortedQueue returns a new queue of int. The behaviour when adding to the queue depends on overwrite. If true, the push operation overwrites oldest values up to the space available, when the queue is full. Otherwise, it refuses to overfill the queue. If the 'less' comparison function is not nil, elements can be easily sorted.

func (*IntQueue) Add added in v0.9.0

func (queue *IntQueue) Add(more ...int)

Add adds items to the queue. This is a synonym for Push.

func (*IntQueue) Cap added in v0.9.0

func (queue *IntQueue) Cap() int

Cap gets the capacity of this queue.

func (*IntQueue) Clear added in v0.9.0

func (queue *IntQueue) Clear()

Clear the entire queue.

func (*IntQueue) Clone added in v0.9.0

func (queue *IntQueue) Clone() *IntQueue

Clone returns a shallow copy of the queue. It does not clone the underlying elements.

func (*IntQueue) Contains added in v0.9.0

func (queue *IntQueue) Contains(v int) bool

Contains determines whether a given item is already in the queue, returning true if so.

func (*IntQueue) ContainsAll added in v0.9.0

func (queue *IntQueue) ContainsAll(i ...int) bool

ContainsAll determines whether the given items are all in the queue, returning true if so. This is potentially a slow method and should only be used rarely.

func (*IntQueue) CountBy added in v0.9.0

func (queue *IntQueue) CountBy(p func(int) bool) (result int)

CountBy gives the number elements of IntQueue that return true for the predicate p.

func (*IntQueue) DoKeepWhere added in v0.9.0

func (queue *IntQueue) DoKeepWhere(p func(int) bool) *IntQueue

DoKeepWhere modifies a IntQueue by retaining only those elements that match the predicate p. This is very similar to Filter but alters the queue in place.

The queue is modified and the modified queue is returned.

func (*IntQueue) Equals added in v0.9.0

func (queue *IntQueue) Equals(other *IntQueue) bool

Equals determines if two queues are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for sets to be equal. Nil queues are considered to be empty.

func (*IntQueue) Exists added in v0.9.0

func (queue *IntQueue) Exists(p func(int) bool) bool

Exists verifies that one or more elements of IntQueue return true for the predicate p. The function should not alter the values via side-effects.

func (*IntQueue) Filter added in v0.9.0

func (queue *IntQueue) Filter(p func(int) bool) *IntQueue

Filter returns a new IntQueue whose elements return true for predicate p.

The original queue is not modified. See also DoKeepWhere (which does modify the original queue).

func (*IntQueue) Find added in v0.9.0

func (queue *IntQueue) Find(p func(int) bool) (int, bool)

Find returns the first int that returns true for predicate p. False is returned if none match.

func (*IntQueue) FlatMap added in v0.9.0

func (queue *IntQueue) FlatMap(f func(int) []int) *IntQueue

FlatMap returns a new IntQueue by transforming every element with function f that returns zero or more items in a slice. The resulting queue may have a different size to the original queue. The original queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (*IntQueue) FlatMapToString added in v0.9.0

func (queue *IntQueue) FlatMapToString(f func(int) []string) []string

FlatMapToString returns a new []string by transforming every element with function f that returns zero or more items in a slice. The resulting slice may have a different size to the queue. The queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (*IntQueue) Fold added in v0.9.0

func (queue *IntQueue) Fold(initial int, fn func(int, int) int) int

Fold aggregates all the values in the queue using a supplied function, starting from some initial value.

func (*IntQueue) Forall added in v0.9.0

func (queue *IntQueue) Forall(p func(int) bool) bool

Forall verifies that all elements of IntQueue return true for the predicate p. The function should not alter the values via side-effects.

func (*IntQueue) Foreach added in v0.9.0

func (queue *IntQueue) Foreach(f func(int))

Foreach iterates over IntQueue and executes function f against each element. The function can safely alter the values via side-effects.

func (*IntQueue) Get added in v0.9.0

func (queue *IntQueue) Get(i int) int

Get gets the specified element in the queue. Panics if the index is out of range or the queue is nil.

func (*IntQueue) Head added in v0.9.0

func (queue *IntQueue) Head() int

Head gets the first element in the queue. Head is the opposite of Last. Panics if queue is empty or nil.

func (*IntQueue) HeadOption added in v0.9.0

func (queue *IntQueue) HeadOption() (int, bool)

HeadOption returns the oldest item in the queue without removing it. If the queue is nil or empty, it returns the zero value instead.

func (*IntQueue) IsEmpty added in v0.9.0

func (queue *IntQueue) IsEmpty() bool

IsEmpty returns true if the queue is empty.

func (*IntQueue) IsFull added in v0.9.0

func (queue *IntQueue) IsFull() bool

IsFull returns true if the queue is full.

func (*IntQueue) IsOverwriting added in v0.9.0

func (queue *IntQueue) IsOverwriting() bool

IsOverwriting returns true if the queue is overwriting, false if refusing.

func (*IntQueue) IsSequence added in v0.9.0

func (queue *IntQueue) IsSequence() bool

IsSequence returns true for ordered lists and queues.

func (*IntQueue) IsSet added in v0.9.0

func (queue *IntQueue) IsSet() bool

IsSet returns false for lists or queues.

func (*IntQueue) Last added in v0.9.0

func (queue *IntQueue) Last() int

Last gets the the newest item in the queue (i.e. last element pushed) without removing it. Last is the opposite of Head. Panics if queue is empty or nil.

func (*IntQueue) LastOption added in v0.9.0

func (queue *IntQueue) LastOption() (int, bool)

LastOption returns the newest item in the queue without removing it. If the queue is nil empty, it returns the zero value instead.

func (*IntQueue) Len added in v0.9.0

func (queue *IntQueue) Len() int

Len gets the current length of this queue. This is an alias for Size.

func (*IntQueue) Less added in v0.9.0

func (queue *IntQueue) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j. The queue must have been created with a non-nil 'less' comparison function and it must not be empty.

func (*IntQueue) Map added in v0.9.0

func (queue *IntQueue) Map(f func(int) int) *IntQueue

Map returns a new IntQueue by transforming every element with function f. The resulting queue is the same size as the original queue. The original queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (*IntQueue) MapToString added in v0.9.0

func (queue *IntQueue) MapToString(f func(int) string) []string

MapToString returns a new []string by transforming every element with function f. The resulting slice is the same size as the queue. The queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (IntQueue) MarshalJSON added in v0.9.0

func (queue IntQueue) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this queue type.

func (*IntQueue) Max added in v0.9.0

func (queue *IntQueue) Max() (result int)

Max returns the first element containing the maximum value, when compared to other elements. Panics if the collection is empty.

func (*IntQueue) MaxBy added in v0.9.0

func (queue *IntQueue) MaxBy(less func(int, int) bool) int

MaxBy returns an element of IntQueue containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (*IntQueue) Min added in v0.9.0

func (queue *IntQueue) Min() int

Min returns the first element containing the minimum value, when compared to other elements. Panics if the collection is empty.

func (*IntQueue) MinBy added in v0.9.0

func (queue *IntQueue) MinBy(less func(int, int) bool) int

MinBy returns an element of IntQueue containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (*IntQueue) MkString added in v0.9.0

func (queue *IntQueue) MkString(sep string) string

MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.

func (*IntQueue) MkString3 added in v0.9.0

func (queue *IntQueue) MkString3(before, between, after string) string

MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.

func (*IntQueue) NonEmpty added in v0.9.0

func (queue *IntQueue) NonEmpty() bool

NonEmpty returns true if the queue is not empty.

func (*IntQueue) Offer added in v0.9.0

func (queue *IntQueue) Offer(items ...int) []int

Offer appends as many items to the end of the queue as it can. If the queue is already full, what happens depends on whether the queue is configured to overwrite. If it is, the oldest items will be overwritten. Otherwise, it will be filled to capacity and any unwritten items are returned.

If the capacity is too small for the number of items, the excess items are returned. The queue capacity is never altered.

func (*IntQueue) Partition added in v0.9.0

func (queue *IntQueue) Partition(p func(int) bool) (*IntQueue, *IntQueue)

Partition returns two new IntQueues whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't. The relative order of the elements in the results is the same as in the original queue.

The original queue is not modified

func (*IntQueue) Pop added in v0.9.0

func (queue *IntQueue) Pop(n int) []int

Pop removes and returns the oldest items from the queue. If the queue is empty, it returns a nil slice. If n is larger than the current queue length, it returns all the available elements, so in this case the returned slice will be shorter than n.

func (*IntQueue) Pop1 added in v0.9.0

func (queue *IntQueue) Pop1() (int, bool)

Pop1 removes and returns the oldest item from the queue. If the queue is empty, it returns the zero value instead. The boolean is true only if the element was available.

func (*IntQueue) Push added in v0.9.0

func (queue *IntQueue) Push(items ...int) *IntQueue

Push appends items to the end of the queue. If the queue does not have enough space, more will be allocated: how this happens depends on the overwriting mode.

When overwriting, the oldest items are overwritten with the new data; it expands the queue only if there is still not enough space.

Otherwise, the queue might be reallocated if necessary, ensuring that all the data is pushed without any older items being affected.

The modified queue is returned.

func (*IntQueue) Reallocate added in v0.9.0

func (queue *IntQueue) Reallocate(capacity int, overwrite bool) *IntQueue

Reallocate adjusts the allocated capacity of the queue and allows the overwriting behaviour to be changed.

If the new queue capacity is different to the current capacity, the queue is re-allocated to the new capacity. If this is less than the current number of elements, the oldest items in the queue are discarded so that the remaining data can fit in the new space available.

If the new queue capacity is the same as the current capacity, the queue is not altered except for adopting the new overwrite flag's value. Therefore this is the means to change the overwriting behaviour.

Reallocate adjusts the storage space but does not clone the underlying elements.

The queue must not be nil.

func (*IntQueue) Send added in v0.9.0

func (queue *IntQueue) Send() <-chan int

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed. The channel will be closed when all the elements have been sent.

func (*IntQueue) Size added in v0.9.0

func (queue *IntQueue) Size() int

Size gets the number of elements currently in this queue. This is an alias for Len.

func (*IntQueue) Sort added in v0.9.0

func (queue *IntQueue) Sort()

Sort sorts the queue using the 'less' comparison function, which must not be nil. This function will panic if the collection was created with a nil 'less' function (see NewIntSortedQueue).

func (*IntQueue) Space added in v0.9.0

func (queue *IntQueue) Space() int

Space returns the space available in the queue.

func (*IntQueue) StableSort added in v0.9.0

func (queue *IntQueue) StableSort()

StableSort sorts the queue using the 'less' comparison function, which must not be nil. The result is stable so that repeated calls will not arbitrarily swap equal items. This function will panic if the collection was created with a nil 'less' function (see NewIntSortedQueue).

func (*IntQueue) String added in v0.9.0

func (queue *IntQueue) String() string

String implements the Stringer interface to render the queue as a comma-separated string enclosed in square brackets.

func (*IntQueue) StringList added in v0.9.0

func (queue *IntQueue) StringList() []string

StringList gets a list of strings that depicts all the elements.

func (*IntQueue) Sum added in v0.9.0

func (queue *IntQueue) Sum() int

Sum returns the sum of all the elements in the queue.

func (*IntQueue) Swap added in v0.9.0

func (queue *IntQueue) Swap(i, j int)

Swap swaps the elements with indexes i and j. The queue must not be empty.

func (*IntQueue) ToInterfaceSlice added in v0.9.0

func (queue *IntQueue) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the queue as a slice of arbitrary type. The queue is not altered.

func (*IntQueue) ToSlice added in v0.9.0

func (queue *IntQueue) ToSlice() []int

ToSlice returns the elements of the queue as a slice. The queue is not altered.

func (*IntQueue) UnmarshalJSON added in v0.9.0

func (queue *IntQueue) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this queue type.

type IntSequence added in v0.9.0

type IntSequence interface {
	IntCollection

	// Head gets the first element in the sequence. Head plus Tail include the whole sequence. Head is the opposite of Last.
	Head() int

	// HeadOption gets the first element in the sequence, if possible.
	HeadOption() (int, bool)

	// Last gets the last element in the sequence. Init plus Last include the whole sequence. Last is the opposite of Head.
	Last() int

	// LastOption gets the last element in the sequence, if possible.
	LastOption() (int, bool)
}

IntSequence defines an interface for sequence methods on int.

type IntSet

type IntSet map[int]struct{}

IntSet is the primary type that represents a set

func BuildIntSetFromChan

func BuildIntSetFromChan(source <-chan int) IntSet

BuildIntSetFromChan constructs a new IntSet from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func ConvertIntSet

func ConvertIntSet(values ...interface{}) (IntSet, bool)

ConvertIntSet constructs a new set containing the supplied values, if any. The returned boolean will be false if any of the values could not be converted correctly. The returned set will contain all the values that were correctly converted.

func NewIntSet

func NewIntSet(values ...int) IntSet

NewIntSet creates and returns a reference to an empty set.

func (IntSet) Add

func (set IntSet) Add(more ...int) IntSet

Add adds items to the current set, returning the modified set.

func (IntSet) Append

func (set IntSet) Append(more ...int) IntSet

Append inserts more items into a clone of the set. It returns the augmented set. The original set is unmodified.

func (IntSet) Cardinality

func (set IntSet) Cardinality() int

Cardinality returns how many items are currently in the set. This is a synonym for Size.

func (*IntSet) Clear

func (set *IntSet) Clear()

Clear the entire set. Aterwards, it will be an empty set.

func (IntSet) Clone

func (set IntSet) Clone() IntSet

Clone returns a shallow copy of the set. It does not clone the underlying elements.

func (IntSet) Contains

func (set IntSet) Contains(i int) bool

Contains determines whether a given item is already in the set, returning true if so.

func (IntSet) ContainsAll

func (set IntSet) ContainsAll(i ...int) bool

ContainsAll determines whether a given item is already in the set, returning true if so.

func (IntSet) CountBy

func (set IntSet) CountBy(p func(int) bool) (result int)

CountBy gives the number elements of IntSet that return true for the predicate p.

func (IntSet) Difference

func (set IntSet) Difference(other IntSet) IntSet

Difference returns a new set with items in the current set but not in the other set

func (IntSet) Equals

func (set IntSet) Equals(other IntSet) bool

Equals determines whether two sets are equal to each other, returning true if so. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for sets to be equal.

func (IntSet) Exists

func (set IntSet) Exists(p func(int) bool) bool

Exists applies a predicate p to every element in the set. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (IntSet) Filter

func (set IntSet) Filter(p func(int) bool) IntSet

Filter returns a new IntSet whose elements return true for the predicate p.

The original set is not modified

func (IntSet) Find

func (set IntSet) Find(p func(int) bool) (int, bool)

Find returns the first int that returns true for the predicate p. If there are many matches one is arbtrarily chosen. False is returned if none match.

func (IntSet) FlatMap

func (set IntSet) FlatMap(f func(int) []int) IntSet

FlatMap returns a new IntSet by transforming every element with a function f that returns zero or more items in a slice. The resulting set may have a different size to the original set. The original set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (IntSet) FlatMapToString

func (set IntSet) FlatMapToString(f func(int) []string) []string

FlatMapToString returns a new []string by transforming every element with function f that returns zero or more items in a slice. The resulting slice may have a different size to the set. The set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (IntSet) Fold added in v0.9.0

func (set IntSet) Fold(initial int, fn func(int, int) int) int

Fold aggregates all the values in the set using a supplied function, starting from some initial value.

func (IntSet) Forall

func (set IntSet) Forall(p func(int) bool) bool

Forall applies a predicate function p to every element in the set. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (IntSet) Foreach

func (set IntSet) Foreach(f func(int))

Foreach iterates over the set and executes the function f against each element.

func (IntSet) Intersect

func (set IntSet) Intersect(other IntSet) IntSet

Intersect returns a new set with items that exist only in both sets.

func (IntSet) IsEmpty

func (set IntSet) IsEmpty() bool

IsEmpty returns true if the set is empty.

func (IntSet) IsSequence

func (set IntSet) IsSequence() bool

IsSequence returns true for lists and queues.

func (IntSet) IsSet

func (set IntSet) IsSet() bool

IsSet returns false for lists or queues.

func (IntSet) IsSubset

func (set IntSet) IsSubset(other IntSet) bool

IsSubset determines whether every item in the other set is in this set, returning true if so.

func (IntSet) IsSuperset

func (set IntSet) IsSuperset(other IntSet) bool

IsSuperset determines whether every item of this set is in the other set, returning true if so.

func (IntSet) Map

func (set IntSet) Map(f func(int) int) IntSet

Map returns a new IntSet by transforming every element with a function f. The original set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (IntSet) MapToString

func (set IntSet) MapToString(f func(int) string) []string

MapToString returns a new []string by transforming every element with function f. The resulting slice is the same size as the set. The set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (IntSet) MarshalJSON

func (set IntSet) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this set type.

func (IntSet) Max

func (set IntSet) Max() int

Max returns the first element containing the maximum value, when compared to other elements. Panics if the collection is empty.

func (IntSet) MaxBy

func (set IntSet) MaxBy(less func(int, int) bool) int

MaxBy returns an element of IntSet containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (IntSet) Min

func (set IntSet) Min() int

Min returns the first element containing the minimum value, when compared to other elements. Panics if the collection is empty.

func (IntSet) MinBy

func (set IntSet) MinBy(less func(int, int) bool) int

MinBy returns an element of IntSet containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (IntSet) MkString

func (set IntSet) MkString(sep string) string

MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.

func (IntSet) MkString3

func (set IntSet) MkString3(before, between, after string) string

MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.

func (IntSet) NonEmpty

func (set IntSet) NonEmpty() bool

NonEmpty returns true if the set is not empty.

func (IntSet) Partition

func (set IntSet) Partition(p func(int) bool) (IntSet, IntSet)

Partition returns two new IntSets whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't.

The original set is not modified

func (IntSet) Remove

func (set IntSet) Remove(i int)

Remove a single item from the set.

func (IntSet) Send

func (set IntSet) Send() <-chan int

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed

func (IntSet) Size

func (set IntSet) Size() int

Size returns how many items are currently in the set. This is a synonym for Cardinality.

func (IntSet) String

func (set IntSet) String() string

String implements the Stringer interface to render the set as a comma-separated string enclosed in square brackets.

func (IntSet) StringList

func (set IntSet) StringList() []string

StringList gets a list of strings that depicts all the elements.

func (IntSet) StringMap

func (set IntSet) StringMap() map[string]bool

StringMap renders the set as a map of strings. The value of each item in the set becomes stringified as a key in the resulting map.

func (IntSet) Sum

func (set IntSet) Sum() int

Sum returns the sum of all the elements in the set.

func (IntSet) SymmetricDifference

func (set IntSet) SymmetricDifference(other IntSet) IntSet

SymmetricDifference returns a new set with items in the current set or the other set but not in both.

func (IntSet) ToInterfaceSlice

func (set IntSet) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the current set as a slice of arbitrary type.

func (IntSet) ToList

func (set IntSet) ToList() IntList

ToList returns the elements of the set as a list. The returned list is a shallow copy; the set is not altered.

func (IntSet) ToSet

func (set IntSet) ToSet() IntSet

ToSet returns the set; this is an identity operation in this case.

func (IntSet) ToSlice

func (set IntSet) ToSlice() []int

ToSlice returns the elements of the current set as a slice.

func (IntSet) Union

func (set IntSet) Union(other IntSet) IntSet

Union returns a new set with all items in both sets.

func (IntSet) UnmarshalJSON

func (set IntSet) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this set type.

type IntSizer

type IntSizer interface {
	// IsEmpty tests whether IntCollection is empty.
	IsEmpty() bool

	// NonEmpty tests whether IntCollection is empty.
	NonEmpty() bool

	// Size returns the number of items in the collection - an alias of Len().
	Size() int
}

IntSizer defines an interface for sizing methods on int collections.

type IntStringMap

type IntStringMap map[int]string

IntStringMap is the primary type that represents a map

func NewIntStringMap

func NewIntStringMap(kv ...IntStringTuple) IntStringMap

NewIntStringMap creates and returns a reference to a map, optionally containing some items.

func NewIntStringMap1

func NewIntStringMap1(k int, v string) IntStringMap

NewIntStringMap1 creates and returns a reference to a map containing one item.

func (*IntStringMap) Clear

func (mm *IntStringMap) Clear()

Clear clears the entire map.

func (IntStringMap) Clone

func (mm IntStringMap) Clone() IntStringMap

Clone returns a shallow copy of the map. It does not clone the underlying elements.

func (IntStringMap) ContainsAllKeys

func (mm IntStringMap) ContainsAllKeys(kk ...int) bool

ContainsAllKeys determines if the given items are all in the map.

func (IntStringMap) ContainsKey

func (mm IntStringMap) ContainsKey(k int) bool

ContainsKey determines if a given item is already in the map.

func (IntStringMap) DropWhere

func (mm IntStringMap) DropWhere(fn func(int, string) bool) IntStringTuples

DropWhere applies a predicate function to every element in the map. If the function returns true, the element is dropped from the map. This is similar to Filter except that the map is modified.

func (IntStringMap) Equals

func (mm IntStringMap) Equals(other IntStringMap) bool

Equals determines if two maps are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for maps to be equal.

func (IntStringMap) Exists

func (mm IntStringMap) Exists(p func(int, string) bool) bool

Exists applies the predicate p to every element in the map. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (IntStringMap) Filter

func (mm IntStringMap) Filter(p func(int, string) bool) IntStringMap

Filter applies the predicate p to every element in the map and returns a copied map containing only the elements for which the predicate returned true. The original map is not modified.

func (IntStringMap) Find

func (mm IntStringMap) Find(p func(int, string) bool) (IntStringTuple, bool)

Find returns the first string that returns true for the predicate p. False is returned if none match. The original map is not modified.

func (IntStringMap) FlatMap

func (mm IntStringMap) FlatMap(f func(int, string) []IntStringTuple) IntStringMap

FlatMap returns a new StringMap by transforming every element with the function f that returns zero or more items in a slice. The resulting map may have a different size to the original map. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (IntStringMap) Forall

func (mm IntStringMap) Forall(p func(int, string) bool) bool

Forall applies the predicate p to every element in the map. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (IntStringMap) Foreach

func (mm IntStringMap) Foreach(f func(int, string))

Foreach applies the function f to every element in the map. The function can safely alter the values via side-effects.

func (IntStringMap) Get

func (mm IntStringMap) Get(k int) (string, bool)

Get returns one of the items in the map, if present.

func (IntStringMap) IsEmpty

func (mm IntStringMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (IntStringMap) Keys

func (mm IntStringMap) Keys() IntList

Keys returns the keys of the current map as a slice.

func (IntStringMap) Map

func (mm IntStringMap) Map(f func(int, string) (int, string)) IntStringMap

Map returns a new StringMap by transforming every element with the function f. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (IntStringMap) MkString

func (mm IntStringMap) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (IntStringMap) MkString4 added in v0.7.0

func (mm IntStringMap) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (IntStringMap) NonEmpty

func (mm IntStringMap) NonEmpty() bool

NonEmpty returns true if the map is not empty.

func (IntStringMap) OrderedSlice added in v0.6.0

func (mm IntStringMap) OrderedSlice(keys IntList) IntStringTuples

OrderedSlice returns the key/value pairs as a slice in the order specified by keys.

func (IntStringMap) Partition

func (mm IntStringMap) Partition(p func(int, string) bool) (matching IntStringMap, others IntStringMap)

Partition applies the predicate p to every element in the map. It divides the map into two copied maps, the first containing all the elements for which the predicate returned true, and the second containing all the others. The original map is not modified.

func (IntStringMap) Pop

func (mm IntStringMap) Pop(k int) (string, bool)

Pop removes a single item from the map, returning the value present prior to removal.

func (IntStringMap) Put

func (mm IntStringMap) Put(k int, v string) bool

Put adds an item to the current map, replacing any prior value.

func (IntStringMap) Remove

func (mm IntStringMap) Remove(k int)

Remove a single item from the map.

func (IntStringMap) Size

func (mm IntStringMap) Size() int

Size returns how many items are currently in the map. This is a synonym for Len.

func (IntStringMap) String

func (mm IntStringMap) String() string

String implements the Stringer interface to render the set as a comma-separated string enclosed in square brackets.

func (IntStringMap) ToSlice

func (mm IntStringMap) ToSlice() IntStringTuples

ToSlice returns the key/value pairs as a slice.

func (IntStringMap) Values

func (mm IntStringMap) Values() StringList

Values returns the values of the current map as a slice.

type IntStringTuple

type IntStringTuple struct {
	Key int
	Val string
}

IntStringTuple represents a key/value pair.

func (IntStringTuple) MarshalJSON added in v0.6.0

func (t IntStringTuple) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding.Marshaler interface.

func (IntStringTuple) UnmarshalJSON added in v0.6.0

func (t IntStringTuple) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this tuple type.

type IntStringTuples

type IntStringTuples []IntStringTuple

IntStringTuples can be used as a builder for unmodifiable maps.

func IntStringZip

func IntStringZip(keys ...int) IntStringTuples

IntStringZip is used with the Values method to zip (i.e. interleave) a slice of keys with a slice of values. These can then be passed in to the NewIntStringMap constructor function.

func (IntStringTuples) Append1

func (ts IntStringTuples) Append1(k int, v string) IntStringTuples

Append1 adds one item.

func (IntStringTuples) Append2

func (ts IntStringTuples) Append2(k1 int, v1 string, k2 int, v2 string) IntStringTuples

Append2 adds two items.

func (IntStringTuples) Append3

func (ts IntStringTuples) Append3(k1 int, v1 string, k2 int, v2 string, k3 int, v3 string) IntStringTuples

Append3 adds three items.

func (IntStringTuples) MkString added in v0.6.0

func (ts IntStringTuples) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (IntStringTuples) MkString4 added in v0.7.0

func (ts IntStringTuples) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (IntStringTuples) String added in v0.6.0

func (ts IntStringTuples) String() string

func (IntStringTuples) ToMap added in v0.6.0

func (ts IntStringTuples) ToMap() IntStringMap

ToMap converts the tuples to a map.

func (IntStringTuples) Values

func (ts IntStringTuples) Values(values ...string) IntStringTuples

Values sets the values in a tuple slice. Use this with IntStringZip.

type StringAnyMap added in v0.4.0

type StringAnyMap map[string]interface{}

StringAnyMap is the primary type that represents a map

func NewStringAnyMap added in v0.4.0

func NewStringAnyMap(kv ...StringAnyTuple) StringAnyMap

NewStringAnyMap creates and returns a reference to a map, optionally containing some items.

func NewStringAnyMap1 added in v0.4.0

func NewStringAnyMap1(k string, v interface{}) StringAnyMap

NewStringAnyMap1 creates and returns a reference to a map containing one item.

func (*StringAnyMap) Clear added in v0.4.0

func (mm *StringAnyMap) Clear()

Clear clears the entire map.

func (StringAnyMap) Clone added in v0.4.0

func (mm StringAnyMap) Clone() StringAnyMap

Clone returns a shallow copy of the map. It does not clone the underlying elements.

func (StringAnyMap) ContainsAllKeys added in v0.4.0

func (mm StringAnyMap) ContainsAllKeys(kk ...string) bool

ContainsAllKeys determines if the given items are all in the map.

func (StringAnyMap) ContainsKey added in v0.4.0

func (mm StringAnyMap) ContainsKey(k string) bool

ContainsKey determines if a given item is already in the map.

func (StringAnyMap) DropWhere added in v0.4.0

func (mm StringAnyMap) DropWhere(fn func(string, interface{}) bool) StringAnyTuples

DropWhere applies a predicate function to every element in the map. If the function returns true, the element is dropped from the map. This is similar to Filter except that the map is modified.

func (StringAnyMap) Equals added in v0.6.0

func (mm StringAnyMap) Equals(other StringAnyMap) bool

Equals determines if two maps are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for maps to be equal.

func (StringAnyMap) Exists added in v0.4.0

func (mm StringAnyMap) Exists(p func(string, interface{}) bool) bool

Exists applies the predicate p to every element in the map. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (StringAnyMap) Filter added in v0.4.0

func (mm StringAnyMap) Filter(p func(string, interface{}) bool) StringAnyMap

Filter applies the predicate p to every element in the map and returns a copied map containing only the elements for which the predicate returned true. The original map is not modified.

func (StringAnyMap) Find added in v0.4.0

func (mm StringAnyMap) Find(p func(string, interface{}) bool) (StringAnyTuple, bool)

Find returns the first interface{} that returns true for the predicate p. False is returned if none match. The original map is not modified.

func (StringAnyMap) FlatMap added in v0.4.0

func (mm StringAnyMap) FlatMap(f func(string, interface{}) []StringAnyTuple) StringAnyMap

FlatMap returns a new AnyMap by transforming every element with the function f that returns zero or more items in a slice. The resulting map may have a different size to the original map. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringAnyMap) Forall added in v0.4.0

func (mm StringAnyMap) Forall(p func(string, interface{}) bool) bool

Forall applies the predicate p to every element in the map. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (StringAnyMap) Foreach added in v0.4.0

func (mm StringAnyMap) Foreach(f func(string, interface{}))

Foreach applies the function f to every element in the map. The function can safely alter the values via side-effects.

func (StringAnyMap) Get added in v0.4.0

func (mm StringAnyMap) Get(k string) (interface{}, bool)

Get returns one of the items in the map, if present.

func (StringAnyMap) IsEmpty added in v0.4.0

func (mm StringAnyMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (StringAnyMap) Keys added in v0.4.0

func (mm StringAnyMap) Keys() StringList

Keys returns the keys of the current map as a slice.

func (StringAnyMap) Map added in v0.4.0

func (mm StringAnyMap) Map(f func(string, interface{}) (string, interface{})) StringAnyMap

Map returns a new AnyMap by transforming every element with the function f. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringAnyMap) MkString added in v0.6.0

func (mm StringAnyMap) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (StringAnyMap) MkString4 added in v0.7.0

func (mm StringAnyMap) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (StringAnyMap) NonEmpty added in v0.4.0

func (mm StringAnyMap) NonEmpty() bool

NonEmpty returns true if the map is not empty.

func (StringAnyMap) OrderedSlice added in v0.6.0

func (mm StringAnyMap) OrderedSlice(keys StringList) StringAnyTuples

OrderedSlice returns the key/value pairs as a slice in the order specified by keys.

func (StringAnyMap) Partition added in v0.4.0

func (mm StringAnyMap) Partition(p func(string, interface{}) bool) (matching StringAnyMap, others StringAnyMap)

Partition applies the predicate p to every element in the map. It divides the map into two copied maps, the first containing all the elements for which the predicate returned true, and the second containing all the others. The original map is not modified.

func (StringAnyMap) Pop added in v0.4.0

func (mm StringAnyMap) Pop(k string) (interface{}, bool)

Pop removes a single item from the map, returning the value present prior to removal.

func (StringAnyMap) Put added in v0.4.0

func (mm StringAnyMap) Put(k string, v interface{}) bool

Put adds an item to the current map, replacing any prior value.

func (StringAnyMap) Remove added in v0.4.0

func (mm StringAnyMap) Remove(k string)

Remove a single item from the map.

func (StringAnyMap) Size added in v0.4.0

func (mm StringAnyMap) Size() int

Size returns how many items are currently in the map. This is a synonym for Len.

func (StringAnyMap) String added in v0.6.0

func (mm StringAnyMap) String() string

String implements the Stringer interface to render the set as a comma-separated string enclosed in square brackets.

func (StringAnyMap) ToSlice added in v0.4.0

func (mm StringAnyMap) ToSlice() StringAnyTuples

ToSlice returns the key/value pairs as a slice.

func (StringAnyMap) Values added in v0.4.0

func (mm StringAnyMap) Values() AnyList

Values returns the values of the current map as a slice.

type StringAnyTuple added in v0.4.0

type StringAnyTuple struct {
	Key string
	Val interface{}
}

StringAnyTuple represents a key/value pair.

func (StringAnyTuple) MarshalJSON added in v0.6.0

func (t StringAnyTuple) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding.Marshaler interface.

func (StringAnyTuple) UnmarshalJSON added in v0.6.0

func (t StringAnyTuple) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this tuple type.

type StringAnyTuples added in v0.4.0

type StringAnyTuples []StringAnyTuple

StringAnyTuples can be used as a builder for unmodifiable maps.

func StringAnyZip added in v0.4.0

func StringAnyZip(keys ...string) StringAnyTuples

StringAnyZip is used with the Values method to zip (i.e. interleave) a slice of keys with a slice of values. These can then be passed in to the NewStringAnyMap constructor function.

func (StringAnyTuples) Append1 added in v0.4.0

func (ts StringAnyTuples) Append1(k string, v interface{}) StringAnyTuples

Append1 adds one item.

func (StringAnyTuples) Append2 added in v0.4.0

func (ts StringAnyTuples) Append2(k1 string, v1 interface{}, k2 string, v2 interface{}) StringAnyTuples

Append2 adds two items.

func (StringAnyTuples) Append3 added in v0.4.0

func (ts StringAnyTuples) Append3(k1 string, v1 interface{}, k2 string, v2 interface{}, k3 string, v3 interface{}) StringAnyTuples

Append3 adds three items.

func (StringAnyTuples) MkString added in v0.6.0

func (ts StringAnyTuples) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (StringAnyTuples) MkString4 added in v0.7.0

func (ts StringAnyTuples) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (StringAnyTuples) String added in v0.6.0

func (ts StringAnyTuples) String() string

func (StringAnyTuples) ToMap added in v0.6.0

func (ts StringAnyTuples) ToMap() StringAnyMap

ToMap converts the tuples to a map.

func (StringAnyTuples) Values added in v0.4.0

func (ts StringAnyTuples) Values(values ...interface{}) StringAnyTuples

Values sets the values in a tuple slice. Use this with StringAnyZip.

type StringCollection

type StringCollection interface {
	StringSizer
	StringMkStringer

	// IsSequence returns true for lists and queues.
	IsSequence() bool

	// IsSet returns false for lists and queues.
	IsSet() bool

	// ToSlice returns a shallow copy as a plain slice.
	ToSlice() []string

	// ToInterfaceSlice returns a shallow copy as a slice of arbitrary type.
	ToInterfaceSlice() []interface{}

	// Exists verifies that one or more elements of StringCollection return true for the predicate p.
	Exists(p func(string) bool) bool

	// Forall verifies that all elements of StringCollection return true for the predicate p.
	Forall(p func(string) bool) bool

	// Foreach iterates over StringCollection and executes the function f against each element.
	Foreach(f func(string))

	// Find returns the first string that returns true for the predicate p.
	// False is returned if none match.
	Find(p func(string) bool) (string, bool)

	// Send returns a channel that will send all the elements in order. Can be used with the plumbing code, for example.
	// A goroutine is created to send the elements; this only terminates when all the elements have been consumed
	Send() <-chan string

	// CountBy gives the number elements of StringCollection that return true for the predicate p.
	CountBy(p func(string) bool) int

	// Contains determines whether a given item is already in the collection, returning true if so.
	Contains(v string) bool

	// ContainsAll determines whether the given items are all in the collection, returning true if so.
	ContainsAll(v ...string) bool

	// MinBy returns an element of StringCollection containing the minimum value, when compared to other elements
	// using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such
	// element is returned. Panics if there are no elements.
	MinBy(less func(string, string) bool) string

	// MaxBy returns an element of StringCollection containing the maximum value, when compared to other elements
	// using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such
	// element is returned. Panics if there are no elements.
	MaxBy(less func(string, string) bool) string

	// Fold aggregates all the values in the collection using a supplied function, starting from some initial value.
	Fold(initial string, fn func(string, string) string) string
}

StringCollection defines an interface for common collection methods on string.

type StringIntMap

type StringIntMap map[string]int

StringIntMap is the primary type that represents a map

func NewStringIntMap

func NewStringIntMap(kv ...StringIntTuple) StringIntMap

NewStringIntMap creates and returns a reference to a map, optionally containing some items.

func NewStringIntMap1

func NewStringIntMap1(k string, v int) StringIntMap

NewStringIntMap1 creates and returns a reference to a map containing one item.

func (*StringIntMap) Clear

func (mm *StringIntMap) Clear()

Clear clears the entire map.

func (StringIntMap) Clone

func (mm StringIntMap) Clone() StringIntMap

Clone returns a shallow copy of the map. It does not clone the underlying elements.

func (StringIntMap) ContainsAllKeys

func (mm StringIntMap) ContainsAllKeys(kk ...string) bool

ContainsAllKeys determines if the given items are all in the map.

func (StringIntMap) ContainsKey

func (mm StringIntMap) ContainsKey(k string) bool

ContainsKey determines if a given item is already in the map.

func (StringIntMap) DropWhere

func (mm StringIntMap) DropWhere(fn func(string, int) bool) StringIntTuples

DropWhere applies a predicate function to every element in the map. If the function returns true, the element is dropped from the map. This is similar to Filter except that the map is modified.

func (StringIntMap) Equals

func (mm StringIntMap) Equals(other StringIntMap) bool

Equals determines if two maps are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for maps to be equal.

func (StringIntMap) Exists

func (mm StringIntMap) Exists(p func(string, int) bool) bool

Exists applies the predicate p to every element in the map. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (StringIntMap) Filter

func (mm StringIntMap) Filter(p func(string, int) bool) StringIntMap

Filter applies the predicate p to every element in the map and returns a copied map containing only the elements for which the predicate returned true. The original map is not modified.

func (StringIntMap) Find

func (mm StringIntMap) Find(p func(string, int) bool) (StringIntTuple, bool)

Find returns the first int that returns true for the predicate p. False is returned if none match. The original map is not modified.

func (StringIntMap) FlatMap

func (mm StringIntMap) FlatMap(f func(string, int) []StringIntTuple) StringIntMap

FlatMap returns a new IntMap by transforming every element with the function f that returns zero or more items in a slice. The resulting map may have a different size to the original map. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringIntMap) Forall

func (mm StringIntMap) Forall(p func(string, int) bool) bool

Forall applies the predicate p to every element in the map. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (StringIntMap) Foreach

func (mm StringIntMap) Foreach(f func(string, int))

Foreach applies the function f to every element in the map. The function can safely alter the values via side-effects.

func (StringIntMap) Get

func (mm StringIntMap) Get(k string) (int, bool)

Get returns one of the items in the map, if present.

func (StringIntMap) IsEmpty

func (mm StringIntMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (StringIntMap) Keys

func (mm StringIntMap) Keys() StringList

Keys returns the keys of the current map as a slice.

func (StringIntMap) Map

func (mm StringIntMap) Map(f func(string, int) (string, int)) StringIntMap

Map returns a new IntMap by transforming every element with the function f. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringIntMap) MkString

func (mm StringIntMap) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (StringIntMap) MkString4 added in v0.7.0

func (mm StringIntMap) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (StringIntMap) NonEmpty

func (mm StringIntMap) NonEmpty() bool

NonEmpty returns true if the map is not empty.

func (StringIntMap) OrderedSlice added in v0.6.0

func (mm StringIntMap) OrderedSlice(keys StringList) StringIntTuples

OrderedSlice returns the key/value pairs as a slice in the order specified by keys.

func (StringIntMap) Partition

func (mm StringIntMap) Partition(p func(string, int) bool) (matching StringIntMap, others StringIntMap)

Partition applies the predicate p to every element in the map. It divides the map into two copied maps, the first containing all the elements for which the predicate returned true, and the second containing all the others. The original map is not modified.

func (StringIntMap) Pop

func (mm StringIntMap) Pop(k string) (int, bool)

Pop removes a single item from the map, returning the value present prior to removal.

func (StringIntMap) Put

func (mm StringIntMap) Put(k string, v int) bool

Put adds an item to the current map, replacing any prior value.

func (StringIntMap) Remove

func (mm StringIntMap) Remove(k string)

Remove a single item from the map.

func (StringIntMap) Size

func (mm StringIntMap) Size() int

Size returns how many items are currently in the map. This is a synonym for Len.

func (StringIntMap) String

func (mm StringIntMap) String() string

String implements the Stringer interface to render the set as a comma-separated string enclosed in square brackets.

func (StringIntMap) ToSlice

func (mm StringIntMap) ToSlice() StringIntTuples

ToSlice returns the key/value pairs as a slice.

func (StringIntMap) Values

func (mm StringIntMap) Values() IntList

Values returns the values of the current map as a slice.

type StringIntTuple

type StringIntTuple struct {
	Key string
	Val int
}

StringIntTuple represents a key/value pair.

func (StringIntTuple) MarshalJSON added in v0.6.0

func (t StringIntTuple) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding.Marshaler interface.

func (StringIntTuple) UnmarshalJSON added in v0.6.0

func (t StringIntTuple) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this tuple type.

type StringIntTuples

type StringIntTuples []StringIntTuple

StringIntTuples can be used as a builder for unmodifiable maps.

func StringIntZip

func StringIntZip(keys ...string) StringIntTuples

StringIntZip is used with the Values method to zip (i.e. interleave) a slice of keys with a slice of values. These can then be passed in to the NewStringIntMap constructor function.

func (StringIntTuples) Append1

func (ts StringIntTuples) Append1(k string, v int) StringIntTuples

Append1 adds one item.

func (StringIntTuples) Append2

func (ts StringIntTuples) Append2(k1 string, v1 int, k2 string, v2 int) StringIntTuples

Append2 adds two items.

func (StringIntTuples) Append3

func (ts StringIntTuples) Append3(k1 string, v1 int, k2 string, v2 int, k3 string, v3 int) StringIntTuples

Append3 adds three items.

func (StringIntTuples) MkString added in v0.6.0

func (ts StringIntTuples) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (StringIntTuples) MkString4 added in v0.7.0

func (ts StringIntTuples) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (StringIntTuples) String added in v0.6.0

func (ts StringIntTuples) String() string

func (StringIntTuples) ToMap added in v0.6.0

func (ts StringIntTuples) ToMap() StringIntMap

ToMap converts the tuples to a map.

func (StringIntTuples) Values

func (ts StringIntTuples) Values(values ...int) StringIntTuples

Values sets the values in a tuple slice. Use this with StringIntZip.

type StringList

type StringList []string

StringList is a slice of type string. Use it where you would use []string. To add items to the list, simply use the normal built-in append function.

List values follow a similar pattern to Scala Lists and LinearSeqs in particular. For comparison with Scala, see e.g. http://www.scala-lang.org/api/2.11.7/#scala.collection.LinearSeq

func BuildStringListFromChan

func BuildStringListFromChan(source <-chan string) StringList

BuildStringListFromChan constructs a new StringList from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func ConvertStringList

func ConvertStringList(values ...interface{}) (StringList, bool)

ConvertStringList constructs a new list containing the supplied values, if any. The returned boolean will be false if any of the values could not be converted correctly. The returned list will contain all the values that were correctly converted.

func MakeStringList

func MakeStringList(length, capacity int) StringList

MakeStringList makes an empty list with both length and capacity initialised.

func NewStringList

func NewStringList(values ...string) StringList

NewStringList constructs a new list containing the supplied values, if any.

func (StringList) Clone

func (list StringList) Clone() StringList

Clone returns a shallow copy of the list. It does not clone the underlying elements.

func (StringList) Contains

func (list StringList) Contains(v string) bool

Contains determines whether a given item is already in the list, returning true if so.

func (StringList) ContainsAll

func (list StringList) ContainsAll(i ...string) bool

ContainsAll determines whether the given items are all in the list, returning true if so. This is potentially a slow method and should only be used rarely.

func (StringList) CountBy

func (list StringList) CountBy(p func(string) bool) (result int)

CountBy gives the number elements of StringList that return true for the predicate p.

func (StringList) DistinctBy

func (list StringList) DistinctBy(equal func(string, string) bool) StringList

DistinctBy returns a new StringList whose elements are unique, where equality is defined by the equal function.

func (StringList) DoReverse

func (list StringList) DoReverse() StringList

DoReverse alters a StringList with all elements in the reverse order. Unlike Reverse, it does not allocate new memory.

The list is modified and the modified list is returned.

func (StringList) DoShuffle

func (list StringList) DoShuffle() StringList

DoShuffle returns a shuffled StringList, using a version of the Fisher-Yates shuffle.

The list is modified and the modified list is returned.

func (StringList) Drop

func (list StringList) Drop(n int) StringList

Drop returns a slice of StringList without the leading n elements of the source list. If n is greater than or equal to the size of the list, an empty list is returned.

The original list is not modified.

func (StringList) DropLast

func (list StringList) DropLast(n int) StringList

DropLast returns a slice of StringList without the trailing n elements of the source list. If n is greater than or equal to the size of the list, an empty list is returned.

The original list is not modified.

func (StringList) DropWhile

func (list StringList) DropWhile(p func(string) bool) StringList

DropWhile returns a new StringList containing the trailing elements of the source list. Whilst the predicate p returns true, elements are excluded from the result. Once predicate p returns false, all remaining elements are added.

The original list is not modified.

func (StringList) Equals

func (list StringList) Equals(other StringList) bool

Equals determines if two lists are equal to each other. If they both are the same size and have the same items in the same order, they are considered equal. Order of items is not relevent for sets to be equal.

func (StringList) Exists

func (list StringList) Exists(p func(string) bool) bool

Exists verifies that one or more elements of StringList return true for the predicate p.

func (StringList) Filter

func (list StringList) Filter(p func(string) bool) StringList

Filter returns a new StringList whose elements return true for predicate p.

The original list is not modified.

func (StringList) Find

func (list StringList) Find(p func(string) bool) (string, bool)

Find returns the first string that returns true for predicate p. False is returned if none match.

func (StringList) FlatMap

func (list StringList) FlatMap(f func(string) []string) StringList

FlatMap returns a new StringList by transforming every element with function f that returns zero or more items in a slice. The resulting list may have a different size to the original list. The original list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringList) FlatMapToInt added in v0.3.0

func (list StringList) FlatMapToInt(f func(string) []int) []int

FlatMapToInt returns a new []int by transforming every element with function f that returns zero or more items in a slice. The resulting slice may have a different size to the list. The list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringList) Fold added in v0.9.0

func (list StringList) Fold(initial string, fn func(string, string) string) string

Fold aggregates all the values in the list using a supplied function, starting from some initial value.

func (StringList) Forall

func (list StringList) Forall(p func(string) bool) bool

Forall verifies that all elements of StringList return true for the predicate p.

func (StringList) Foreach

func (list StringList) Foreach(f func(string))

Foreach iterates over StringList and executes function f against each element.

func (StringList) Get

func (list StringList) Get(i int) string

Get gets the specified element in the list. Panics if the index is out of range or the list is nil. The simple list is a dressed-up slice and normal slice operations will also work.

func (StringList) GobDecode

func (list StringList) GobDecode(b []byte) error

GobDecode implements 'gob' decoding for this list type. You must register string with the 'gob' package before this method is used.

func (StringList) GobEncode

func (list StringList) GobEncode() ([]byte, error)

GobEncode implements 'gob' encoding for this list type. You must register string with the 'gob' package before this method is used.

func (StringList) Head

func (list StringList) Head() string

Head gets the first element in the list. Head plus Tail include the whole list. Head is the opposite of Last. Panics if list is empty or nil.

func (StringList) HeadOption

func (list StringList) HeadOption() (string, bool)

HeadOption gets the first element in the list, if possible. Otherwise returns the zero value.

func (StringList) IndexWhere

func (list StringList) IndexWhere(p func(string) bool) int

IndexWhere finds the index of the first element satisfying predicate p. If none exists, -1 is returned.

func (StringList) IndexWhere2

func (list StringList) IndexWhere2(p func(string) bool, from int) int

IndexWhere2 finds the index of the first element satisfying predicate p at or after some start index. If none exists, -1 is returned.

func (StringList) Init

func (list StringList) Init() StringList

Init gets everything except the last. Init plus Last include the whole list. Init is the opposite of Tail. Panics if list is empty or nil.

func (StringList) IsEmpty

func (list StringList) IsEmpty() bool

IsEmpty tests whether StringList is empty.

func (StringList) IsSequence

func (list StringList) IsSequence() bool

IsSequence returns true for lists and queues.

func (StringList) IsSet

func (list StringList) IsSet() bool

IsSet returns false for lists or queues.

func (StringList) Last

func (list StringList) Last() string

Last gets the last element in the list. Init plus Last include the whole list. Last is the opposite of Head. Panics if list is empty or nil.

func (StringList) LastIndexWhere

func (list StringList) LastIndexWhere(p func(string) bool) int

LastIndexWhere finds the index of the last element satisfying predicate p. If none exists, -1 is returned.

func (StringList) LastIndexWhere2

func (list StringList) LastIndexWhere2(p func(string) bool, before int) int

LastIndexWhere2 finds the index of the last element satisfying predicate p at or before some start index. If none exists, -1 is returned.

func (StringList) LastOption

func (list StringList) LastOption() (string, bool)

LastOption gets the last element in the list, if possible. Otherwise returns the zero value.

func (StringList) Len

func (list StringList) Len() int

Len returns the number of items in the list - an alias of Size(). This is one of the three methods in the standard sort.Interface.

func (StringList) Map

func (list StringList) Map(f func(string) string) StringList

Map returns a new StringList by transforming every element with function f. The resulting list is the same size as the original list. The original list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringList) MapToInt added in v0.3.0

func (list StringList) MapToInt(f func(string) int) []int

MapToInt returns a new []int by transforming every element with function f. The resulting slice is the same size as the list. The list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringList) MaxBy

func (list StringList) MaxBy(less func(string, string) bool) string

MaxBy returns an element of StringList containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (StringList) MinBy

func (list StringList) MinBy(less func(string, string) bool) string

MinBy returns an element of StringList containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (StringList) MkString

func (list StringList) MkString(sep string) string

MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.

func (StringList) MkString3

func (list StringList) MkString3(before, between, after string) string

MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.

func (StringList) NonEmpty

func (list StringList) NonEmpty() bool

NonEmpty tests whether StringList is empty.

func (StringList) Partition

func (list StringList) Partition(p func(string) bool) (StringList, StringList)

Partition returns two new StringLists whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't. The relative order of the elements in the results is the same as in the original list.

The original list is not modified.

func (StringList) Reverse

func (list StringList) Reverse() StringList

Reverse returns a copy of StringList with all elements in the reverse order.

The original list is not modified.

func (StringList) Send

func (list StringList) Send() <-chan string

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed. The channel will be closed when all the elements have been sent.

func (StringList) Shuffle

func (list StringList) Shuffle() StringList

Shuffle returns a shuffled copy of StringList, using a version of the Fisher-Yates shuffle.

The original list is not modified.

func (StringList) Size

func (list StringList) Size() int

Size returns the number of items in the list - an alias of Len().

func (StringList) SortBy

func (list StringList) SortBy(less func(i, j string) bool) StringList

SortBy alters the list so that the elements are sorted by a specified ordering. Sorting happens in-place; the modified list is returned.

func (StringList) Sorted added in v0.5.0

func (list StringList) Sorted() StringList

Sorted alters the list so that the elements are sorted by their natural ordering. Sorting happens in-place; the modified list is returned.

func (StringList) StableSortBy

func (list StringList) StableSortBy(less func(i, j string) bool) StringList

StableSortBy alters the list so that the elements are sorted by a specified ordering. Sorting happens in-place; the modified list is returned. The algorithm keeps the original order of equal elements.

func (StringList) String

func (list StringList) String() string

String implements the Stringer interface to render the list as a comma-separated string enclosed in square brackets.

func (StringList) StringList

func (list StringList) StringList() []string

StringList gets a list of strings that depicts all the elements.

func (StringList) Swap

func (list StringList) Swap(i, j int)

Swap exchanges two elements, which is necessary during sorting etc. This is one of the three methods in the standard sort.Interface.

func (StringList) Tail

func (list StringList) Tail() StringList

Tail gets everything except the head. Head plus Tail include the whole list. Tail is the opposite of Init. Panics if list is empty or nil.

func (StringList) Take

func (list StringList) Take(n int) StringList

Take returns a slice of StringList containing the leading n elements of the source list. If n is greater than or equal to the size of the list, the whole original list is returned.

func (StringList) TakeLast

func (list StringList) TakeLast(n int) StringList

TakeLast returns a slice of StringList containing the trailing n elements of the source list. If n is greater than or equal to the size of the list, the whole original list is returned.

The original list is not modified.

func (StringList) TakeWhile

func (list StringList) TakeWhile(p func(string) bool) StringList

TakeWhile returns a new StringList containing the leading elements of the source list. Whilst the predicate p returns true, elements are added to the result. Once predicate p returns false, all remaining elements are excluded.

The original list is not modified.

func (StringList) ToInterfaceSlice

func (list StringList) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the current list as a slice of arbitrary type.

func (StringList) ToList

func (list StringList) ToList() StringList

ToList returns the elements of the list as a list, which is an identity operation in this case.

func (StringList) ToSet

func (list StringList) ToSet() StringSet

ToSet returns the elements of the list as a set. The returned set is a shallow copy; the list is not altered.

func (StringList) ToSlice

func (list StringList) ToSlice() []string

ToSlice returns the elements of the list as a slice, which is an identity operation in this case, because the simple list is merely a dressed-up slice.

type StringMkStringer

type StringMkStringer interface {
	// String implements the Stringer interface to render the collection as a comma-separated string enclosed
	// in square brackets.
	String() string

	// MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.
	MkString(sep string) string

	// MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.
	MkString3(before, between, after string) string

	// StringList gets a collection of strings that depicts all the elements.
	StringList() []string
}

StringMkStringer defines an interface for stringer methods on string collections.

type StringQueue added in v0.9.0

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

StringQueue is a ring buffer containing a slice of type string. It is optimised for FIFO operations.

func BuildStringQueueFromChan added in v0.9.0

func BuildStringQueueFromChan(source <-chan string) *StringQueue

BuildStringQueueFromChan constructs a new StringQueue from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func NewStringQueue added in v0.9.0

func NewStringQueue(capacity int, overwrite bool) *StringQueue

NewStringQueue returns a new queue of string. The behaviour when adding to the queue depends on overwrite. If true, the push operation overwrites oldest values up to the space available, when the queue is full. Otherwise, it refuses to overfill the queue.

func NewStringSortedQueue added in v0.9.0

func NewStringSortedQueue(capacity int, overwrite bool, less func(i, j string) bool) *StringQueue

NewStringSortedQueue returns a new queue of string. The behaviour when adding to the queue depends on overwrite. If true, the push operation overwrites oldest values up to the space available, when the queue is full. Otherwise, it refuses to overfill the queue. If the 'less' comparison function is not nil, elements can be easily sorted.

func (*StringQueue) Add added in v0.9.0

func (queue *StringQueue) Add(more ...string)

Add adds items to the queue. This is a synonym for Push.

func (*StringQueue) Cap added in v0.9.0

func (queue *StringQueue) Cap() int

Cap gets the capacity of this queue.

func (*StringQueue) Clear added in v0.9.0

func (queue *StringQueue) Clear()

Clear the entire queue.

func (*StringQueue) Clone added in v0.9.0

func (queue *StringQueue) Clone() *StringQueue

Clone returns a shallow copy of the queue. It does not clone the underlying elements.

func (*StringQueue) Contains added in v0.9.0

func (queue *StringQueue) Contains(v string) bool

Contains determines whether a given item is already in the queue, returning true if so.

func (*StringQueue) ContainsAll added in v0.9.0

func (queue *StringQueue) ContainsAll(i ...string) bool

ContainsAll determines whether the given items are all in the queue, returning true if so. This is potentially a slow method and should only be used rarely.

func (*StringQueue) CountBy added in v0.9.0

func (queue *StringQueue) CountBy(p func(string) bool) (result int)

CountBy gives the number elements of StringQueue that return true for the predicate p.

func (*StringQueue) DoKeepWhere added in v0.9.0

func (queue *StringQueue) DoKeepWhere(p func(string) bool) *StringQueue

DoKeepWhere modifies a StringQueue by retaining only those elements that match the predicate p. This is very similar to Filter but alters the queue in place.

The queue is modified and the modified queue is returned.

func (*StringQueue) Equals added in v0.9.0

func (queue *StringQueue) Equals(other *StringQueue) bool

Equals determines if two queues are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for sets to be equal. Nil queues are considered to be empty.

func (*StringQueue) Exists added in v0.9.0

func (queue *StringQueue) Exists(p func(string) bool) bool

Exists verifies that one or more elements of StringQueue return true for the predicate p. The function should not alter the values via side-effects.

func (*StringQueue) Filter added in v0.9.0

func (queue *StringQueue) Filter(p func(string) bool) *StringQueue

Filter returns a new StringQueue whose elements return true for predicate p.

The original queue is not modified. See also DoKeepWhere (which does modify the original queue).

func (*StringQueue) Find added in v0.9.0

func (queue *StringQueue) Find(p func(string) bool) (string, bool)

Find returns the first string that returns true for predicate p. False is returned if none match.

func (*StringQueue) FlatMap added in v0.9.0

func (queue *StringQueue) FlatMap(f func(string) []string) *StringQueue

FlatMap returns a new StringQueue by transforming every element with function f that returns zero or more items in a slice. The resulting queue may have a different size to the original queue. The original queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (*StringQueue) FlatMapToInt added in v0.9.0

func (queue *StringQueue) FlatMapToInt(f func(string) []int) []int

FlatMapToInt returns a new []int by transforming every element with function f that returns zero or more items in a slice. The resulting slice may have a different size to the queue. The queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (*StringQueue) Fold added in v0.9.0

func (queue *StringQueue) Fold(initial string, fn func(string, string) string) string

Fold aggregates all the values in the queue using a supplied function, starting from some initial value.

func (*StringQueue) Forall added in v0.9.0

func (queue *StringQueue) Forall(p func(string) bool) bool

Forall verifies that all elements of StringQueue return true for the predicate p. The function should not alter the values via side-effects.

func (*StringQueue) Foreach added in v0.9.0

func (queue *StringQueue) Foreach(f func(string))

Foreach iterates over StringQueue and executes function f against each element. The function can safely alter the values via side-effects.

func (*StringQueue) Get added in v0.9.0

func (queue *StringQueue) Get(i int) string

Get gets the specified element in the queue. Panics if the index is out of range or the queue is nil.

func (*StringQueue) Head added in v0.9.0

func (queue *StringQueue) Head() string

Head gets the first element in the queue. Head is the opposite of Last. Panics if queue is empty or nil.

func (*StringQueue) HeadOption added in v0.9.0

func (queue *StringQueue) HeadOption() (string, bool)

HeadOption returns the oldest item in the queue without removing it. If the queue is nil or empty, it returns the zero value instead.

func (*StringQueue) IsEmpty added in v0.9.0

func (queue *StringQueue) IsEmpty() bool

IsEmpty returns true if the queue is empty.

func (*StringQueue) IsFull added in v0.9.0

func (queue *StringQueue) IsFull() bool

IsFull returns true if the queue is full.

func (*StringQueue) IsOverwriting added in v0.9.0

func (queue *StringQueue) IsOverwriting() bool

IsOverwriting returns true if the queue is overwriting, false if refusing.

func (*StringQueue) IsSequence added in v0.9.0

func (queue *StringQueue) IsSequence() bool

IsSequence returns true for ordered lists and queues.

func (*StringQueue) IsSet added in v0.9.0

func (queue *StringQueue) IsSet() bool

IsSet returns false for lists or queues.

func (*StringQueue) Last added in v0.9.0

func (queue *StringQueue) Last() string

Last gets the the newest item in the queue (i.e. last element pushed) without removing it. Last is the opposite of Head. Panics if queue is empty or nil.

func (*StringQueue) LastOption added in v0.9.0

func (queue *StringQueue) LastOption() (string, bool)

LastOption returns the newest item in the queue without removing it. If the queue is nil empty, it returns the zero value instead.

func (*StringQueue) Len added in v0.9.0

func (queue *StringQueue) Len() int

Len gets the current length of this queue. This is an alias for Size.

func (*StringQueue) Less added in v0.9.0

func (queue *StringQueue) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j. The queue must have been created with a non-nil 'less' comparison function and it must not be empty.

func (*StringQueue) Map added in v0.9.0

func (queue *StringQueue) Map(f func(string) string) *StringQueue

Map returns a new StringQueue by transforming every element with function f. The resulting queue is the same size as the original queue. The original queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (*StringQueue) MapToInt added in v0.9.0

func (queue *StringQueue) MapToInt(f func(string) int) []int

MapToInt returns a new []int by transforming every element with function f. The resulting slice is the same size as the queue. The queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringQueue) MarshalJSON added in v0.9.0

func (queue StringQueue) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this queue type.

func (*StringQueue) MaxBy added in v0.9.0

func (queue *StringQueue) MaxBy(less func(string, string) bool) string

MaxBy returns an element of StringQueue containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (*StringQueue) MinBy added in v0.9.0

func (queue *StringQueue) MinBy(less func(string, string) bool) string

MinBy returns an element of StringQueue containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (*StringQueue) MkString added in v0.9.0

func (queue *StringQueue) MkString(sep string) string

MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.

func (*StringQueue) MkString3 added in v0.9.0

func (queue *StringQueue) MkString3(before, between, after string) string

MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.

func (*StringQueue) NonEmpty added in v0.9.0

func (queue *StringQueue) NonEmpty() bool

NonEmpty returns true if the queue is not empty.

func (*StringQueue) Offer added in v0.9.0

func (queue *StringQueue) Offer(items ...string) []string

Offer appends as many items to the end of the queue as it can. If the queue is already full, what happens depends on whether the queue is configured to overwrite. If it is, the oldest items will be overwritten. Otherwise, it will be filled to capacity and any unwritten items are returned.

If the capacity is too small for the number of items, the excess items are returned. The queue capacity is never altered.

func (*StringQueue) Partition added in v0.9.0

func (queue *StringQueue) Partition(p func(string) bool) (*StringQueue, *StringQueue)

Partition returns two new StringQueues whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't. The relative order of the elements in the results is the same as in the original queue.

The original queue is not modified

func (*StringQueue) Pop added in v0.9.0

func (queue *StringQueue) Pop(n int) []string

Pop removes and returns the oldest items from the queue. If the queue is empty, it returns a nil slice. If n is larger than the current queue length, it returns all the available elements, so in this case the returned slice will be shorter than n.

func (*StringQueue) Pop1 added in v0.9.0

func (queue *StringQueue) Pop1() (string, bool)

Pop1 removes and returns the oldest item from the queue. If the queue is empty, it returns the zero value instead. The boolean is true only if the element was available.

func (*StringQueue) Push added in v0.9.0

func (queue *StringQueue) Push(items ...string) *StringQueue

Push appends items to the end of the queue. If the queue does not have enough space, more will be allocated: how this happens depends on the overwriting mode.

When overwriting, the oldest items are overwritten with the new data; it expands the queue only if there is still not enough space.

Otherwise, the queue might be reallocated if necessary, ensuring that all the data is pushed without any older items being affected.

The modified queue is returned.

func (*StringQueue) Reallocate added in v0.9.0

func (queue *StringQueue) Reallocate(capacity int, overwrite bool) *StringQueue

Reallocate adjusts the allocated capacity of the queue and allows the overwriting behaviour to be changed.

If the new queue capacity is different to the current capacity, the queue is re-allocated to the new capacity. If this is less than the current number of elements, the oldest items in the queue are discarded so that the remaining data can fit in the new space available.

If the new queue capacity is the same as the current capacity, the queue is not altered except for adopting the new overwrite flag's value. Therefore this is the means to change the overwriting behaviour.

Reallocate adjusts the storage space but does not clone the underlying elements.

The queue must not be nil.

func (*StringQueue) Send added in v0.9.0

func (queue *StringQueue) Send() <-chan string

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed. The channel will be closed when all the elements have been sent.

func (*StringQueue) Size added in v0.9.0

func (queue *StringQueue) Size() int

Size gets the number of elements currently in this queue. This is an alias for Len.

func (*StringQueue) Sort added in v0.9.0

func (queue *StringQueue) Sort()

Sort sorts the queue using the 'less' comparison function, which must not be nil. This function will panic if the collection was created with a nil 'less' function (see NewStringSortedQueue).

func (*StringQueue) Space added in v0.9.0

func (queue *StringQueue) Space() int

Space returns the space available in the queue.

func (*StringQueue) StableSort added in v0.9.0

func (queue *StringQueue) StableSort()

StableSort sorts the queue using the 'less' comparison function, which must not be nil. The result is stable so that repeated calls will not arbitrarily swap equal items. This function will panic if the collection was created with a nil 'less' function (see NewStringSortedQueue).

func (*StringQueue) String added in v0.9.0

func (queue *StringQueue) String() string

String implements the Stringer interface to render the queue as a comma-separated string enclosed in square brackets.

func (*StringQueue) StringList added in v0.9.0

func (queue *StringQueue) StringList() []string

StringList gets a list of strings that depicts all the elements.

func (*StringQueue) Swap added in v0.9.0

func (queue *StringQueue) Swap(i, j int)

Swap swaps the elements with indexes i and j. The queue must not be empty.

func (*StringQueue) ToInterfaceSlice added in v0.9.0

func (queue *StringQueue) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the queue as a slice of arbitrary type. The queue is not altered.

func (*StringQueue) ToSlice added in v0.9.0

func (queue *StringQueue) ToSlice() []string

ToSlice returns the elements of the queue as a slice. The queue is not altered.

func (*StringQueue) UnmarshalJSON added in v0.9.0

func (queue *StringQueue) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this queue type.

type StringSequence added in v0.9.0

type StringSequence interface {
	StringCollection

	// Head gets the first element in the sequence. Head plus Tail include the whole sequence. Head is the opposite of Last.
	Head() string

	// HeadOption gets the first element in the sequence, if possible.
	HeadOption() (string, bool)

	// Last gets the last element in the sequence. Init plus Last include the whole sequence. Last is the opposite of Head.
	Last() string

	// LastOption gets the last element in the sequence, if possible.
	LastOption() (string, bool)
}

StringSequence defines an interface for sequence methods on string.

type StringSet

type StringSet map[string]struct{}

StringSet is the primary type that represents a set

func BuildStringSetFromChan

func BuildStringSetFromChan(source <-chan string) StringSet

BuildStringSetFromChan constructs a new StringSet from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func ConvertStringSet

func ConvertStringSet(values ...interface{}) (StringSet, bool)

ConvertStringSet constructs a new set containing the supplied values, if any. The returned boolean will be false if any of the values could not be converted correctly. The returned set will contain all the values that were correctly converted.

func NewStringSet

func NewStringSet(values ...string) StringSet

NewStringSet creates and returns a reference to an empty set.

func (StringSet) Add

func (set StringSet) Add(more ...string) StringSet

Add adds items to the current set, returning the modified set.

func (StringSet) Append

func (set StringSet) Append(more ...string) StringSet

Append inserts more items into a clone of the set. It returns the augmented set. The original set is unmodified.

func (StringSet) Cardinality

func (set StringSet) Cardinality() int

Cardinality returns how many items are currently in the set. This is a synonym for Size.

func (*StringSet) Clear

func (set *StringSet) Clear()

Clear the entire set. Aterwards, it will be an empty set.

func (StringSet) Clone

func (set StringSet) Clone() StringSet

Clone returns a shallow copy of the set. It does not clone the underlying elements.

func (StringSet) Contains

func (set StringSet) Contains(i string) bool

Contains determines whether a given item is already in the set, returning true if so.

func (StringSet) ContainsAll

func (set StringSet) ContainsAll(i ...string) bool

ContainsAll determines whether a given item is already in the set, returning true if so.

func (StringSet) CountBy

func (set StringSet) CountBy(p func(string) bool) (result int)

CountBy gives the number elements of StringSet that return true for the predicate p.

func (StringSet) Difference

func (set StringSet) Difference(other StringSet) StringSet

Difference returns a new set with items in the current set but not in the other set

func (StringSet) Equals

func (set StringSet) Equals(other StringSet) bool

Equals determines whether two sets are equal to each other, returning true if so. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for sets to be equal.

func (StringSet) Exists

func (set StringSet) Exists(p func(string) bool) bool

Exists applies a predicate p to every element in the set. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (StringSet) Filter

func (set StringSet) Filter(p func(string) bool) StringSet

Filter returns a new StringSet whose elements return true for the predicate p.

The original set is not modified

func (StringSet) Find

func (set StringSet) Find(p func(string) bool) (string, bool)

Find returns the first string that returns true for the predicate p. If there are many matches one is arbtrarily chosen. False is returned if none match.

func (StringSet) FlatMap

func (set StringSet) FlatMap(f func(string) []string) StringSet

FlatMap returns a new StringSet by transforming every element with a function f that returns zero or more items in a slice. The resulting set may have a different size to the original set. The original set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringSet) FlatMapToInt

func (set StringSet) FlatMapToInt(f func(string) []int) []int

FlatMapToInt returns a new []int by transforming every element with function f that returns zero or more items in a slice. The resulting slice may have a different size to the set. The set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringSet) Fold added in v0.9.0

func (set StringSet) Fold(initial string, fn func(string, string) string) string

Fold aggregates all the values in the set using a supplied function, starting from some initial value.

func (StringSet) Forall

func (set StringSet) Forall(p func(string) bool) bool

Forall applies a predicate function p to every element in the set. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (StringSet) Foreach

func (set StringSet) Foreach(f func(string))

Foreach iterates over the set and executes the function f against each element.

func (StringSet) Intersect

func (set StringSet) Intersect(other StringSet) StringSet

Intersect returns a new set with items that exist only in both sets.

func (StringSet) IsEmpty

func (set StringSet) IsEmpty() bool

IsEmpty returns true if the set is empty.

func (StringSet) IsSequence

func (set StringSet) IsSequence() bool

IsSequence returns true for lists and queues.

func (StringSet) IsSet

func (set StringSet) IsSet() bool

IsSet returns false for lists or queues.

func (StringSet) IsSubset

func (set StringSet) IsSubset(other StringSet) bool

IsSubset determines whether every item in the other set is in this set, returning true if so.

func (StringSet) IsSuperset

func (set StringSet) IsSuperset(other StringSet) bool

IsSuperset determines whether every item of this set is in the other set, returning true if so.

func (StringSet) Map

func (set StringSet) Map(f func(string) string) StringSet

Map returns a new StringSet by transforming every element with a function f. The original set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringSet) MapToInt

func (set StringSet) MapToInt(f func(string) int) []int

MapToInt returns a new []int by transforming every element with function f. The resulting slice is the same size as the set. The set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringSet) MarshalJSON

func (set StringSet) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this set type.

func (StringSet) MaxBy

func (set StringSet) MaxBy(less func(string, string) bool) string

MaxBy returns an element of StringSet containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (StringSet) MinBy

func (set StringSet) MinBy(less func(string, string) bool) string

MinBy returns an element of StringSet containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (StringSet) MkString

func (set StringSet) MkString(sep string) string

MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.

func (StringSet) MkString3

func (set StringSet) MkString3(before, between, after string) string

MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.

func (StringSet) NonEmpty

func (set StringSet) NonEmpty() bool

NonEmpty returns true if the set is not empty.

func (StringSet) Partition

func (set StringSet) Partition(p func(string) bool) (StringSet, StringSet)

Partition returns two new StringSets whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't.

The original set is not modified

func (StringSet) Remove

func (set StringSet) Remove(i string)

Remove a single item from the set.

func (StringSet) Send

func (set StringSet) Send() <-chan string

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed

func (StringSet) Size

func (set StringSet) Size() int

Size returns how many items are currently in the set. This is a synonym for Cardinality.

func (StringSet) String

func (set StringSet) String() string

String implements the Stringer interface to render the set as a comma-separated string enclosed in square brackets.

func (StringSet) StringList

func (set StringSet) StringList() []string

StringList gets a list of strings that depicts all the elements.

func (StringSet) StringMap

func (set StringSet) StringMap() map[string]bool

StringMap renders the set as a map of strings. The value of each item in the set becomes stringified as a key in the resulting map.

func (StringSet) SymmetricDifference

func (set StringSet) SymmetricDifference(other StringSet) StringSet

SymmetricDifference returns a new set with items in the current set or the other set but not in both.

func (StringSet) ToInterfaceSlice

func (set StringSet) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the current set as a slice of arbitrary type.

func (StringSet) ToList

func (set StringSet) ToList() StringList

ToList returns the elements of the set as a list. The returned list is a shallow copy; the set is not altered.

func (StringSet) ToSet

func (set StringSet) ToSet() StringSet

ToSet returns the set; this is an identity operation in this case.

func (StringSet) ToSlice

func (set StringSet) ToSlice() []string

ToSlice returns the elements of the current set as a slice.

func (StringSet) Union

func (set StringSet) Union(other StringSet) StringSet

Union returns a new set with all items in both sets.

func (StringSet) UnmarshalJSON

func (set StringSet) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this set type.

type StringSizer

type StringSizer interface {
	// IsEmpty tests whether StringCollection is empty.
	IsEmpty() bool

	// NonEmpty tests whether StringCollection is empty.
	NonEmpty() bool

	// Size returns the number of items in the collection - an alias of Len().
	Size() int
}

StringSizer defines an interface for sizing methods on string collections.

type StringStringMap

type StringStringMap map[string]string

StringStringMap is the primary type that represents a map

func NewStringStringMap

func NewStringStringMap(kv ...StringStringTuple) StringStringMap

NewStringStringMap creates and returns a reference to a map, optionally containing some items.

func NewStringStringMap1

func NewStringStringMap1(k string, v string) StringStringMap

NewStringStringMap1 creates and returns a reference to a map containing one item.

func (*StringStringMap) Clear

func (mm *StringStringMap) Clear()

Clear clears the entire map.

func (StringStringMap) Clone

func (mm StringStringMap) Clone() StringStringMap

Clone returns a shallow copy of the map. It does not clone the underlying elements.

func (StringStringMap) ContainsAllKeys

func (mm StringStringMap) ContainsAllKeys(kk ...string) bool

ContainsAllKeys determines if the given items are all in the map.

func (StringStringMap) ContainsKey

func (mm StringStringMap) ContainsKey(k string) bool

ContainsKey determines if a given item is already in the map.

func (StringStringMap) DropWhere

func (mm StringStringMap) DropWhere(fn func(string, string) bool) StringStringTuples

DropWhere applies a predicate function to every element in the map. If the function returns true, the element is dropped from the map. This is similar to Filter except that the map is modified.

func (StringStringMap) Equals

func (mm StringStringMap) Equals(other StringStringMap) bool

Equals determines if two maps are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for maps to be equal.

func (StringStringMap) Exists

func (mm StringStringMap) Exists(p func(string, string) bool) bool

Exists applies the predicate p to every element in the map. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (StringStringMap) Filter

func (mm StringStringMap) Filter(p func(string, string) bool) StringStringMap

Filter applies the predicate p to every element in the map and returns a copied map containing only the elements for which the predicate returned true. The original map is not modified.

func (StringStringMap) Find

func (mm StringStringMap) Find(p func(string, string) bool) (StringStringTuple, bool)

Find returns the first string that returns true for the predicate p. False is returned if none match. The original map is not modified.

func (StringStringMap) FlatMap

FlatMap returns a new StringMap by transforming every element with the function f that returns zero or more items in a slice. The resulting map may have a different size to the original map. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringStringMap) Forall

func (mm StringStringMap) Forall(p func(string, string) bool) bool

Forall applies the predicate p to every element in the map. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (StringStringMap) Foreach

func (mm StringStringMap) Foreach(f func(string, string))

Foreach applies the function f to every element in the map. The function can safely alter the values via side-effects.

func (StringStringMap) Get

func (mm StringStringMap) Get(k string) (string, bool)

Get returns one of the items in the map, if present.

func (StringStringMap) IsEmpty

func (mm StringStringMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (StringStringMap) Keys

func (mm StringStringMap) Keys() StringList

Keys returns the keys of the current map as a slice.

func (StringStringMap) Map

Map returns a new StringMap by transforming every element with the function f. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringStringMap) MkString

func (mm StringStringMap) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (StringStringMap) MkString4 added in v0.7.0

func (mm StringStringMap) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (StringStringMap) NonEmpty

func (mm StringStringMap) NonEmpty() bool

NonEmpty returns true if the map is not empty.

func (StringStringMap) OrderedSlice added in v0.6.0

func (mm StringStringMap) OrderedSlice(keys StringList) StringStringTuples

OrderedSlice returns the key/value pairs as a slice in the order specified by keys.

func (StringStringMap) Partition

func (mm StringStringMap) Partition(p func(string, string) bool) (matching StringStringMap, others StringStringMap)

Partition applies the predicate p to every element in the map. It divides the map into two copied maps, the first containing all the elements for which the predicate returned true, and the second containing all the others. The original map is not modified.

func (StringStringMap) Pop

func (mm StringStringMap) Pop(k string) (string, bool)

Pop removes a single item from the map, returning the value present prior to removal.

func (StringStringMap) Put

func (mm StringStringMap) Put(k string, v string) bool

Put adds an item to the current map, replacing any prior value.

func (StringStringMap) Remove

func (mm StringStringMap) Remove(k string)

Remove a single item from the map.

func (StringStringMap) Size

func (mm StringStringMap) Size() int

Size returns how many items are currently in the map. This is a synonym for Len.

func (StringStringMap) String

func (mm StringStringMap) String() string

String implements the Stringer interface to render the set as a comma-separated string enclosed in square brackets.

func (StringStringMap) ToSlice

func (mm StringStringMap) ToSlice() StringStringTuples

ToSlice returns the key/value pairs as a slice.

func (StringStringMap) Values

func (mm StringStringMap) Values() StringList

Values returns the values of the current map as a slice.

type StringStringTuple

type StringStringTuple struct {
	Key string
	Val string
}

StringStringTuple represents a key/value pair.

func (StringStringTuple) MarshalJSON added in v0.6.0

func (t StringStringTuple) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding.Marshaler interface.

func (StringStringTuple) UnmarshalJSON added in v0.6.0

func (t StringStringTuple) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this tuple type.

type StringStringTuples

type StringStringTuples []StringStringTuple

StringStringTuples can be used as a builder for unmodifiable maps.

func StringStringZip

func StringStringZip(keys ...string) StringStringTuples

StringStringZip is used with the Values method to zip (i.e. interleave) a slice of keys with a slice of values. These can then be passed in to the NewStringStringMap constructor function.

func (StringStringTuples) Append1

Append1 adds one item.

func (StringStringTuples) Append2

func (ts StringStringTuples) Append2(k1 string, v1 string, k2 string, v2 string) StringStringTuples

Append2 adds two items.

func (StringStringTuples) Append3

func (ts StringStringTuples) Append3(k1 string, v1 string, k2 string, v2 string, k3 string, v3 string) StringStringTuples

Append3 adds three items.

func (StringStringTuples) MkString added in v0.6.0

func (ts StringStringTuples) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (StringStringTuples) MkString4 added in v0.7.0

func (ts StringStringTuples) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (StringStringTuples) String added in v0.6.0

func (ts StringStringTuples) String() string

func (StringStringTuples) ToMap added in v0.6.0

ToMap converts the tuples to a map.

func (StringStringTuples) Values

func (ts StringStringTuples) Values(values ...string) StringStringTuples

Values sets the values in a tuple slice. Use this with StringStringZip.

type StringUintMap added in v0.3.0

type StringUintMap map[string]uint

StringUintMap is the primary type that represents a map

func NewStringUintMap added in v0.3.0

func NewStringUintMap(kv ...StringUintTuple) StringUintMap

NewStringUintMap creates and returns a reference to a map, optionally containing some items.

func NewStringUintMap1 added in v0.3.0

func NewStringUintMap1(k string, v uint) StringUintMap

NewStringUintMap1 creates and returns a reference to a map containing one item.

func (*StringUintMap) Clear added in v0.3.0

func (mm *StringUintMap) Clear()

Clear clears the entire map.

func (StringUintMap) Clone added in v0.3.0

func (mm StringUintMap) Clone() StringUintMap

Clone returns a shallow copy of the map. It does not clone the underlying elements.

func (StringUintMap) ContainsAllKeys added in v0.3.0

func (mm StringUintMap) ContainsAllKeys(kk ...string) bool

ContainsAllKeys determines if the given items are all in the map.

func (StringUintMap) ContainsKey added in v0.3.0

func (mm StringUintMap) ContainsKey(k string) bool

ContainsKey determines if a given item is already in the map.

func (StringUintMap) DropWhere added in v0.3.0

func (mm StringUintMap) DropWhere(fn func(string, uint) bool) StringUintTuples

DropWhere applies a predicate function to every element in the map. If the function returns true, the element is dropped from the map. This is similar to Filter except that the map is modified.

func (StringUintMap) Equals added in v0.3.0

func (mm StringUintMap) Equals(other StringUintMap) bool

Equals determines if two maps are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for maps to be equal.

func (StringUintMap) Exists added in v0.3.0

func (mm StringUintMap) Exists(p func(string, uint) bool) bool

Exists applies the predicate p to every element in the map. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (StringUintMap) Filter added in v0.3.0

func (mm StringUintMap) Filter(p func(string, uint) bool) StringUintMap

Filter applies the predicate p to every element in the map and returns a copied map containing only the elements for which the predicate returned true. The original map is not modified.

func (StringUintMap) Find added in v0.3.0

func (mm StringUintMap) Find(p func(string, uint) bool) (StringUintTuple, bool)

Find returns the first uint that returns true for the predicate p. False is returned if none match. The original map is not modified.

func (StringUintMap) FlatMap added in v0.3.0

func (mm StringUintMap) FlatMap(f func(string, uint) []StringUintTuple) StringUintMap

FlatMap returns a new UintMap by transforming every element with the function f that returns zero or more items in a slice. The resulting map may have a different size to the original map. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringUintMap) Forall added in v0.3.0

func (mm StringUintMap) Forall(p func(string, uint) bool) bool

Forall applies the predicate p to every element in the map. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (StringUintMap) Foreach added in v0.3.0

func (mm StringUintMap) Foreach(f func(string, uint))

Foreach applies the function f to every element in the map. The function can safely alter the values via side-effects.

func (StringUintMap) Get added in v0.3.0

func (mm StringUintMap) Get(k string) (uint, bool)

Get returns one of the items in the map, if present.

func (StringUintMap) IsEmpty added in v0.3.0

func (mm StringUintMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (StringUintMap) Keys added in v0.3.0

func (mm StringUintMap) Keys() StringList

Keys returns the keys of the current map as a slice.

func (StringUintMap) Map added in v0.3.0

func (mm StringUintMap) Map(f func(string, uint) (string, uint)) StringUintMap

Map returns a new UintMap by transforming every element with the function f. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (StringUintMap) MkString added in v0.3.0

func (mm StringUintMap) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (StringUintMap) MkString4 added in v0.7.0

func (mm StringUintMap) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (StringUintMap) NonEmpty added in v0.3.0

func (mm StringUintMap) NonEmpty() bool

NonEmpty returns true if the map is not empty.

func (StringUintMap) OrderedSlice added in v0.6.0

func (mm StringUintMap) OrderedSlice(keys StringList) StringUintTuples

OrderedSlice returns the key/value pairs as a slice in the order specified by keys.

func (StringUintMap) Partition added in v0.3.0

func (mm StringUintMap) Partition(p func(string, uint) bool) (matching StringUintMap, others StringUintMap)

Partition applies the predicate p to every element in the map. It divides the map into two copied maps, the first containing all the elements for which the predicate returned true, and the second containing all the others. The original map is not modified.

func (StringUintMap) Pop added in v0.3.0

func (mm StringUintMap) Pop(k string) (uint, bool)

Pop removes a single item from the map, returning the value present prior to removal.

func (StringUintMap) Put added in v0.3.0

func (mm StringUintMap) Put(k string, v uint) bool

Put adds an item to the current map, replacing any prior value.

func (StringUintMap) Remove added in v0.3.0

func (mm StringUintMap) Remove(k string)

Remove a single item from the map.

func (StringUintMap) Size added in v0.3.0

func (mm StringUintMap) Size() int

Size returns how many items are currently in the map. This is a synonym for Len.

func (StringUintMap) String added in v0.3.0

func (mm StringUintMap) String() string

String implements the Stringer interface to render the set as a comma-separated string enclosed in square brackets.

func (StringUintMap) ToSlice added in v0.3.0

func (mm StringUintMap) ToSlice() StringUintTuples

ToSlice returns the key/value pairs as a slice.

func (StringUintMap) Values added in v0.3.0

func (mm StringUintMap) Values() UintList

Values returns the values of the current map as a slice.

type StringUintTuple added in v0.3.0

type StringUintTuple struct {
	Key string
	Val uint
}

StringUintTuple represents a key/value pair.

func (StringUintTuple) MarshalJSON added in v0.6.0

func (t StringUintTuple) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding.Marshaler interface.

func (StringUintTuple) UnmarshalJSON added in v0.6.0

func (t StringUintTuple) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this tuple type.

type StringUintTuples added in v0.3.0

type StringUintTuples []StringUintTuple

StringUintTuples can be used as a builder for unmodifiable maps.

func StringUintZip added in v0.3.0

func StringUintZip(keys ...string) StringUintTuples

StringUintZip is used with the Values method to zip (i.e. interleave) a slice of keys with a slice of values. These can then be passed in to the NewStringUintMap constructor function.

func (StringUintTuples) Append1 added in v0.3.0

func (ts StringUintTuples) Append1(k string, v uint) StringUintTuples

Append1 adds one item.

func (StringUintTuples) Append2 added in v0.3.0

func (ts StringUintTuples) Append2(k1 string, v1 uint, k2 string, v2 uint) StringUintTuples

Append2 adds two items.

func (StringUintTuples) Append3 added in v0.3.0

func (ts StringUintTuples) Append3(k1 string, v1 uint, k2 string, v2 uint, k3 string, v3 uint) StringUintTuples

Append3 adds three items.

func (StringUintTuples) MkString added in v0.6.0

func (ts StringUintTuples) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (StringUintTuples) MkString4 added in v0.7.0

func (ts StringUintTuples) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (StringUintTuples) String added in v0.6.0

func (ts StringUintTuples) String() string

func (StringUintTuples) ToMap added in v0.6.0

func (ts StringUintTuples) ToMap() StringUintMap

ToMap converts the tuples to a map.

func (StringUintTuples) Values added in v0.3.0

func (ts StringUintTuples) Values(values ...uint) StringUintTuples

Values sets the values in a tuple slice. Use this with StringUintZip.

type Uint64Collection added in v0.3.0

type Uint64Collection interface {
	Uint64Sizer
	Uint64MkStringer

	// IsSequence returns true for lists and queues.
	IsSequence() bool

	// IsSet returns false for lists and queues.
	IsSet() bool

	// ToSlice returns a shallow copy as a plain slice.
	ToSlice() []uint64

	// ToInterfaceSlice returns a shallow copy as a slice of arbitrary type.
	ToInterfaceSlice() []interface{}

	// Exists verifies that one or more elements of Uint64Collection return true for the predicate p.
	Exists(p func(uint64) bool) bool

	// Forall verifies that all elements of Uint64Collection return true for the predicate p.
	Forall(p func(uint64) bool) bool

	// Foreach iterates over Uint64Collection and executes the function f against each element.
	Foreach(f func(uint64))

	// Find returns the first uint64 that returns true for the predicate p.
	// False is returned if none match.
	Find(p func(uint64) bool) (uint64, bool)

	// Send returns a channel that will send all the elements in order. Can be used with the plumbing code, for example.
	// A goroutine is created to send the elements; this only terminates when all the elements have been consumed
	Send() <-chan uint64

	// CountBy gives the number elements of Uint64Collection that return true for the predicate p.
	CountBy(p func(uint64) bool) int

	// Contains determines whether a given item is already in the collection, returning true if so.
	Contains(v uint64) bool

	// ContainsAll determines whether the given items are all in the collection, returning true if so.
	ContainsAll(v ...uint64) bool

	// Min returns the minimum value of all the items in the collection. Panics if there are no elements.
	Min() uint64

	// Max returns the minimum value of all the items in the collection. Panics if there are no elements.
	Max() uint64

	// MinBy returns an element of Uint64Collection containing the minimum value, when compared to other elements
	// using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such
	// element is returned. Panics if there are no elements.
	MinBy(less func(uint64, uint64) bool) uint64

	// MaxBy returns an element of Uint64Collection containing the maximum value, when compared to other elements
	// using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such
	// element is returned. Panics if there are no elements.
	MaxBy(less func(uint64, uint64) bool) uint64

	// Fold aggregates all the values in the collection using a supplied function, starting from some initial value.
	Fold(initial uint64, fn func(uint64, uint64) uint64) uint64

	// Sum returns the sum of all the elements in the collection.
	Sum() uint64
}

Uint64Collection defines an interface for common collection methods on uint64.

type Uint64List added in v0.3.0

type Uint64List []uint64

Uint64List is a slice of type uint64. Use it where you would use []uint64. To add items to the list, simply use the normal built-in append function.

List values follow a similar pattern to Scala Lists and LinearSeqs in particular. For comparison with Scala, see e.g. http://www.scala-lang.org/api/2.11.7/#scala.collection.LinearSeq

func BuildUint64ListFromChan added in v0.3.0

func BuildUint64ListFromChan(source <-chan uint64) Uint64List

BuildUint64ListFromChan constructs a new Uint64List from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func ConvertUint64List added in v0.3.0

func ConvertUint64List(values ...interface{}) (Uint64List, bool)

ConvertUint64List constructs a new list containing the supplied values, if any. The returned boolean will be false if any of the values could not be converted correctly. The returned list will contain all the values that were correctly converted. Conversions are provided from all built-in numeric types.

func MakeUint64List added in v0.3.0

func MakeUint64List(length, capacity int) Uint64List

MakeUint64List makes an empty list with both length and capacity initialised.

func NewUint64List added in v0.3.0

func NewUint64List(values ...uint64) Uint64List

NewUint64List constructs a new list containing the supplied values, if any.

func (Uint64List) Clone added in v0.3.0

func (list Uint64List) Clone() Uint64List

Clone returns a shallow copy of the list. It does not clone the underlying elements.

func (Uint64List) Contains added in v0.3.0

func (list Uint64List) Contains(v uint64) bool

Contains determines whether a given item is already in the list, returning true if so.

func (Uint64List) ContainsAll added in v0.3.0

func (list Uint64List) ContainsAll(i ...uint64) bool

ContainsAll determines whether the given items are all in the list, returning true if so. This is potentially a slow method and should only be used rarely.

func (Uint64List) CountBy added in v0.3.0

func (list Uint64List) CountBy(p func(uint64) bool) (result int)

CountBy gives the number elements of Uint64List that return true for the predicate p.

func (Uint64List) DistinctBy added in v0.3.0

func (list Uint64List) DistinctBy(equal func(uint64, uint64) bool) Uint64List

DistinctBy returns a new Uint64List whose elements are unique, where equality is defined by the equal function.

func (Uint64List) DoReverse added in v0.3.0

func (list Uint64List) DoReverse() Uint64List

DoReverse alters a Uint64List with all elements in the reverse order. Unlike Reverse, it does not allocate new memory.

The list is modified and the modified list is returned.

func (Uint64List) DoShuffle added in v0.3.0

func (list Uint64List) DoShuffle() Uint64List

DoShuffle returns a shuffled Uint64List, using a version of the Fisher-Yates shuffle.

The list is modified and the modified list is returned.

func (Uint64List) Drop added in v0.3.0

func (list Uint64List) Drop(n int) Uint64List

Drop returns a slice of Uint64List without the leading n elements of the source list. If n is greater than or equal to the size of the list, an empty list is returned.

The original list is not modified.

func (Uint64List) DropLast added in v0.3.0

func (list Uint64List) DropLast(n int) Uint64List

DropLast returns a slice of Uint64List without the trailing n elements of the source list. If n is greater than or equal to the size of the list, an empty list is returned.

The original list is not modified.

func (Uint64List) DropWhile added in v0.3.0

func (list Uint64List) DropWhile(p func(uint64) bool) Uint64List

DropWhile returns a new Uint64List containing the trailing elements of the source list. Whilst the predicate p returns true, elements are excluded from the result. Once predicate p returns false, all remaining elements are added.

The original list is not modified.

func (Uint64List) Equals added in v0.3.0

func (list Uint64List) Equals(other Uint64List) bool

Equals determines if two lists are equal to each other. If they both are the same size and have the same items in the same order, they are considered equal. Order of items is not relevent for sets to be equal.

func (Uint64List) Exists added in v0.3.0

func (list Uint64List) Exists(p func(uint64) bool) bool

Exists verifies that one or more elements of Uint64List return true for the predicate p.

func (Uint64List) Filter added in v0.3.0

func (list Uint64List) Filter(p func(uint64) bool) Uint64List

Filter returns a new Uint64List whose elements return true for predicate p.

The original list is not modified.

func (Uint64List) Find added in v0.3.0

func (list Uint64List) Find(p func(uint64) bool) (uint64, bool)

Find returns the first uint64 that returns true for predicate p. False is returned if none match.

func (Uint64List) FlatMap added in v0.3.0

func (list Uint64List) FlatMap(f func(uint64) []uint64) Uint64List

FlatMap returns a new Uint64List by transforming every element with function f that returns zero or more items in a slice. The resulting list may have a different size to the original list. The original list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Uint64List) FlatMapToString added in v0.3.0

func (list Uint64List) FlatMapToString(f func(uint64) []string) []string

FlatMapToString returns a new []string by transforming every element with function f that returns zero or more items in a slice. The resulting slice may have a different size to the list. The list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Uint64List) Fold added in v0.9.0

func (list Uint64List) Fold(initial uint64, fn func(uint64, uint64) uint64) uint64

Fold aggregates all the values in the list using a supplied function, starting from some initial value.

func (Uint64List) Forall added in v0.3.0

func (list Uint64List) Forall(p func(uint64) bool) bool

Forall verifies that all elements of Uint64List return true for the predicate p.

func (Uint64List) Foreach added in v0.3.0

func (list Uint64List) Foreach(f func(uint64))

Foreach iterates over Uint64List and executes function f against each element.

func (Uint64List) Get added in v0.3.0

func (list Uint64List) Get(i int) uint64

Get gets the specified element in the list. Panics if the index is out of range or the list is nil. The simple list is a dressed-up slice and normal slice operations will also work.

func (Uint64List) GobDecode added in v0.3.0

func (list Uint64List) GobDecode(b []byte) error

GobDecode implements 'gob' decoding for this list type. You must register uint64 with the 'gob' package before this method is used.

func (Uint64List) GobEncode added in v0.3.0

func (list Uint64List) GobEncode() ([]byte, error)

GobEncode implements 'gob' encoding for this list type. You must register uint64 with the 'gob' package before this method is used.

func (Uint64List) Head added in v0.3.0

func (list Uint64List) Head() uint64

Head gets the first element in the list. Head plus Tail include the whole list. Head is the opposite of Last. Panics if list is empty or nil.

func (Uint64List) HeadOption added in v0.3.0

func (list Uint64List) HeadOption() (uint64, bool)

HeadOption gets the first element in the list, if possible. Otherwise returns the zero value.

func (Uint64List) IndexWhere added in v0.3.0

func (list Uint64List) IndexWhere(p func(uint64) bool) int

IndexWhere finds the index of the first element satisfying predicate p. If none exists, -1 is returned.

func (Uint64List) IndexWhere2 added in v0.3.0

func (list Uint64List) IndexWhere2(p func(uint64) bool, from int) int

IndexWhere2 finds the index of the first element satisfying predicate p at or after some start index. If none exists, -1 is returned.

func (Uint64List) Init added in v0.3.0

func (list Uint64List) Init() Uint64List

Init gets everything except the last. Init plus Last include the whole list. Init is the opposite of Tail. Panics if list is empty or nil.

func (Uint64List) IsEmpty added in v0.3.0

func (list Uint64List) IsEmpty() bool

IsEmpty tests whether Uint64List is empty.

func (Uint64List) IsSequence added in v0.3.0

func (list Uint64List) IsSequence() bool

IsSequence returns true for lists and queues.

func (Uint64List) IsSet added in v0.3.0

func (list Uint64List) IsSet() bool

IsSet returns false for lists or queues.

func (Uint64List) Last added in v0.3.0

func (list Uint64List) Last() uint64

Last gets the last element in the list. Init plus Last include the whole list. Last is the opposite of Head. Panics if list is empty or nil.

func (Uint64List) LastIndexWhere added in v0.3.0

func (list Uint64List) LastIndexWhere(p func(uint64) bool) int

LastIndexWhere finds the index of the last element satisfying predicate p. If none exists, -1 is returned.

func (Uint64List) LastIndexWhere2 added in v0.3.0

func (list Uint64List) LastIndexWhere2(p func(uint64) bool, before int) int

LastIndexWhere2 finds the index of the last element satisfying predicate p at or before some start index. If none exists, -1 is returned.

func (Uint64List) LastOption added in v0.3.0

func (list Uint64List) LastOption() (uint64, bool)

LastOption gets the last element in the list, if possible. Otherwise returns the zero value.

func (Uint64List) Len added in v0.3.0

func (list Uint64List) Len() int

Len returns the number of items in the list - an alias of Size(). This is one of the three methods in the standard sort.Interface.

func (Uint64List) Map added in v0.3.0

func (list Uint64List) Map(f func(uint64) uint64) Uint64List

Map returns a new Uint64List by transforming every element with function f. The resulting list is the same size as the original list. The original list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Uint64List) MapToString added in v0.3.0

func (list Uint64List) MapToString(f func(uint64) string) []string

MapToString returns a new []string by transforming every element with function f. The resulting slice is the same size as the list. The list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Uint64List) Max added in v0.3.0

func (list Uint64List) Max() (result uint64)

Max returns the first element containing the maximum value, when compared to other elements. Panics if the collection is empty.

func (Uint64List) MaxBy added in v0.3.0

func (list Uint64List) MaxBy(less func(uint64, uint64) bool) uint64

MaxBy returns an element of Uint64List containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (Uint64List) Min added in v0.3.0

func (list Uint64List) Min() uint64

Min returns the first element containing the minimum value, when compared to other elements. Panics if the collection is empty.

func (Uint64List) MinBy added in v0.3.0

func (list Uint64List) MinBy(less func(uint64, uint64) bool) uint64

MinBy returns an element of Uint64List containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (Uint64List) MkString added in v0.3.0

func (list Uint64List) MkString(sep string) string

MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.

func (Uint64List) MkString3 added in v0.3.0

func (list Uint64List) MkString3(before, between, after string) string

MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.

func (Uint64List) NonEmpty added in v0.3.0

func (list Uint64List) NonEmpty() bool

NonEmpty tests whether Uint64List is empty.

func (Uint64List) Partition added in v0.3.0

func (list Uint64List) Partition(p func(uint64) bool) (Uint64List, Uint64List)

Partition returns two new Uint64Lists whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't. The relative order of the elements in the results is the same as in the original list.

The original list is not modified.

func (Uint64List) Reverse added in v0.3.0

func (list Uint64List) Reverse() Uint64List

Reverse returns a copy of Uint64List with all elements in the reverse order.

The original list is not modified.

func (Uint64List) Send added in v0.3.0

func (list Uint64List) Send() <-chan uint64

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed. The channel will be closed when all the elements have been sent.

func (Uint64List) Shuffle added in v0.3.0

func (list Uint64List) Shuffle() Uint64List

Shuffle returns a shuffled copy of Uint64List, using a version of the Fisher-Yates shuffle.

The original list is not modified.

func (Uint64List) Size added in v0.3.0

func (list Uint64List) Size() int

Size returns the number of items in the list - an alias of Len().

func (Uint64List) SortBy added in v0.3.0

func (list Uint64List) SortBy(less func(i, j uint64) bool) Uint64List

SortBy alters the list so that the elements are sorted by a specified ordering. Sorting happens in-place; the modified list is returned.

func (Uint64List) Sorted added in v0.3.0

func (list Uint64List) Sorted() Uint64List

Sorted alters the list so that the elements are sorted by their natural ordering. Sorting happens in-place; the modified list is returned.

func (Uint64List) StableSortBy added in v0.3.0

func (list Uint64List) StableSortBy(less func(i, j uint64) bool) Uint64List

StableSortBy alters the list so that the elements are sorted by a specified ordering. Sorting happens in-place; the modified list is returned. The algorithm keeps the original order of equal elements.

func (Uint64List) StableSorted added in v0.3.0

func (list Uint64List) StableSorted() Uint64List

StableSorted alters the list so that the elements are sorted by their natural ordering. Sorting happens in-place; the modified list is returned.

func (Uint64List) String added in v0.3.0

func (list Uint64List) String() string

String implements the Stringer interface to render the list as a comma-separated string enclosed in square brackets.

func (Uint64List) StringList added in v0.3.0

func (list Uint64List) StringList() []string

StringList gets a list of strings that depicts all the elements.

func (Uint64List) Sum added in v0.3.0

func (list Uint64List) Sum() uint64

Sum returns the sum of all the elements in the list.

func (Uint64List) Swap added in v0.3.0

func (list Uint64List) Swap(i, j int)

Swap exchanges two elements, which is necessary during sorting etc. This is one of the three methods in the standard sort.Interface.

func (Uint64List) Tail added in v0.3.0

func (list Uint64List) Tail() Uint64List

Tail gets everything except the head. Head plus Tail include the whole list. Tail is the opposite of Init. Panics if list is empty or nil.

func (Uint64List) Take added in v0.3.0

func (list Uint64List) Take(n int) Uint64List

Take returns a slice of Uint64List containing the leading n elements of the source list. If n is greater than or equal to the size of the list, the whole original list is returned.

func (Uint64List) TakeLast added in v0.3.0

func (list Uint64List) TakeLast(n int) Uint64List

TakeLast returns a slice of Uint64List containing the trailing n elements of the source list. If n is greater than or equal to the size of the list, the whole original list is returned.

The original list is not modified.

func (Uint64List) TakeWhile added in v0.3.0

func (list Uint64List) TakeWhile(p func(uint64) bool) Uint64List

TakeWhile returns a new Uint64List containing the leading elements of the source list. Whilst the predicate p returns true, elements are added to the result. Once predicate p returns false, all remaining elements are excluded.

The original list is not modified.

func (Uint64List) ToInterfaceSlice added in v0.3.0

func (list Uint64List) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the current list as a slice of arbitrary type.

func (Uint64List) ToList added in v0.3.0

func (list Uint64List) ToList() Uint64List

ToList returns the elements of the list as a list, which is an identity operation in this case.

func (Uint64List) ToSet added in v0.3.0

func (list Uint64List) ToSet() Uint64Set

ToSet returns the elements of the list as a set. The returned set is a shallow copy; the list is not altered.

func (Uint64List) ToSlice added in v0.3.0

func (list Uint64List) ToSlice() []uint64

ToSlice returns the elements of the list as a slice, which is an identity operation in this case, because the simple list is merely a dressed-up slice.

type Uint64MkStringer added in v0.3.0

type Uint64MkStringer interface {
	// String implements the Stringer interface to render the collection as a comma-separated string enclosed
	// in square brackets.
	String() string

	// MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.
	MkString(sep string) string

	// MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.
	MkString3(before, between, after string) string

	// StringList gets a collection of strings that depicts all the elements.
	StringList() []string
}

Uint64MkStringer defines an interface for stringer methods on uint64 collections.

type Uint64Queue added in v0.9.0

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

Uint64Queue is a ring buffer containing a slice of type uint64. It is optimised for FIFO operations.

func BuildUint64QueueFromChan added in v0.9.0

func BuildUint64QueueFromChan(source <-chan uint64) *Uint64Queue

BuildUint64QueueFromChan constructs a new Uint64Queue from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func NewUint64Queue added in v0.9.0

func NewUint64Queue(capacity int, overwrite bool) *Uint64Queue

NewUint64Queue returns a new queue of uint64. The behaviour when adding to the queue depends on overwrite. If true, the push operation overwrites oldest values up to the space available, when the queue is full. Otherwise, it refuses to overfill the queue.

func NewUint64SortedQueue added in v0.9.0

func NewUint64SortedQueue(capacity int, overwrite bool, less func(i, j uint64) bool) *Uint64Queue

NewUint64SortedQueue returns a new queue of uint64. The behaviour when adding to the queue depends on overwrite. If true, the push operation overwrites oldest values up to the space available, when the queue is full. Otherwise, it refuses to overfill the queue. If the 'less' comparison function is not nil, elements can be easily sorted.

func (*Uint64Queue) Add added in v0.9.0

func (queue *Uint64Queue) Add(more ...uint64)

Add adds items to the queue. This is a synonym for Push.

func (*Uint64Queue) Cap added in v0.9.0

func (queue *Uint64Queue) Cap() int

Cap gets the capacity of this queue.

func (*Uint64Queue) Clear added in v0.9.0

func (queue *Uint64Queue) Clear()

Clear the entire queue.

func (*Uint64Queue) Clone added in v0.9.0

func (queue *Uint64Queue) Clone() *Uint64Queue

Clone returns a shallow copy of the queue. It does not clone the underlying elements.

func (*Uint64Queue) Contains added in v0.9.0

func (queue *Uint64Queue) Contains(v uint64) bool

Contains determines whether a given item is already in the queue, returning true if so.

func (*Uint64Queue) ContainsAll added in v0.9.0

func (queue *Uint64Queue) ContainsAll(i ...uint64) bool

ContainsAll determines whether the given items are all in the queue, returning true if so. This is potentially a slow method and should only be used rarely.

func (*Uint64Queue) CountBy added in v0.9.0

func (queue *Uint64Queue) CountBy(p func(uint64) bool) (result int)

CountBy gives the number elements of Uint64Queue that return true for the predicate p.

func (*Uint64Queue) DoKeepWhere added in v0.9.0

func (queue *Uint64Queue) DoKeepWhere(p func(uint64) bool) *Uint64Queue

DoKeepWhere modifies a Uint64Queue by retaining only those elements that match the predicate p. This is very similar to Filter but alters the queue in place.

The queue is modified and the modified queue is returned.

func (*Uint64Queue) Equals added in v0.9.0

func (queue *Uint64Queue) Equals(other *Uint64Queue) bool

Equals determines if two queues are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for sets to be equal. Nil queues are considered to be empty.

func (*Uint64Queue) Exists added in v0.9.0

func (queue *Uint64Queue) Exists(p func(uint64) bool) bool

Exists verifies that one or more elements of Uint64Queue return true for the predicate p. The function should not alter the values via side-effects.

func (*Uint64Queue) Filter added in v0.9.0

func (queue *Uint64Queue) Filter(p func(uint64) bool) *Uint64Queue

Filter returns a new Uint64Queue whose elements return true for predicate p.

The original queue is not modified. See also DoKeepWhere (which does modify the original queue).

func (*Uint64Queue) Find added in v0.9.0

func (queue *Uint64Queue) Find(p func(uint64) bool) (uint64, bool)

Find returns the first uint64 that returns true for predicate p. False is returned if none match.

func (*Uint64Queue) FlatMap added in v0.9.0

func (queue *Uint64Queue) FlatMap(f func(uint64) []uint64) *Uint64Queue

FlatMap returns a new Uint64Queue by transforming every element with function f that returns zero or more items in a slice. The resulting queue may have a different size to the original queue. The original queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (*Uint64Queue) FlatMapToString added in v0.9.0

func (queue *Uint64Queue) FlatMapToString(f func(uint64) []string) []string

FlatMapToString returns a new []string by transforming every element with function f that returns zero or more items in a slice. The resulting slice may have a different size to the queue. The queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (*Uint64Queue) Fold added in v0.9.0

func (queue *Uint64Queue) Fold(initial uint64, fn func(uint64, uint64) uint64) uint64

Fold aggregates all the values in the queue using a supplied function, starting from some initial value.

func (*Uint64Queue) Forall added in v0.9.0

func (queue *Uint64Queue) Forall(p func(uint64) bool) bool

Forall verifies that all elements of Uint64Queue return true for the predicate p. The function should not alter the values via side-effects.

func (*Uint64Queue) Foreach added in v0.9.0

func (queue *Uint64Queue) Foreach(f func(uint64))

Foreach iterates over Uint64Queue and executes function f against each element. The function can safely alter the values via side-effects.

func (*Uint64Queue) Get added in v0.9.0

func (queue *Uint64Queue) Get(i int) uint64

Get gets the specified element in the queue. Panics if the index is out of range or the queue is nil.

func (*Uint64Queue) Head added in v0.9.0

func (queue *Uint64Queue) Head() uint64

Head gets the first element in the queue. Head is the opposite of Last. Panics if queue is empty or nil.

func (*Uint64Queue) HeadOption added in v0.9.0

func (queue *Uint64Queue) HeadOption() (uint64, bool)

HeadOption returns the oldest item in the queue without removing it. If the queue is nil or empty, it returns the zero value instead.

func (*Uint64Queue) IsEmpty added in v0.9.0

func (queue *Uint64Queue) IsEmpty() bool

IsEmpty returns true if the queue is empty.

func (*Uint64Queue) IsFull added in v0.9.0

func (queue *Uint64Queue) IsFull() bool

IsFull returns true if the queue is full.

func (*Uint64Queue) IsOverwriting added in v0.9.0

func (queue *Uint64Queue) IsOverwriting() bool

IsOverwriting returns true if the queue is overwriting, false if refusing.

func (*Uint64Queue) IsSequence added in v0.9.0

func (queue *Uint64Queue) IsSequence() bool

IsSequence returns true for ordered lists and queues.

func (*Uint64Queue) IsSet added in v0.9.0

func (queue *Uint64Queue) IsSet() bool

IsSet returns false for lists or queues.

func (*Uint64Queue) Last added in v0.9.0

func (queue *Uint64Queue) Last() uint64

Last gets the the newest item in the queue (i.e. last element pushed) without removing it. Last is the opposite of Head. Panics if queue is empty or nil.

func (*Uint64Queue) LastOption added in v0.9.0

func (queue *Uint64Queue) LastOption() (uint64, bool)

LastOption returns the newest item in the queue without removing it. If the queue is nil empty, it returns the zero value instead.

func (*Uint64Queue) Len added in v0.9.0

func (queue *Uint64Queue) Len() int

Len gets the current length of this queue. This is an alias for Size.

func (*Uint64Queue) Less added in v0.9.0

func (queue *Uint64Queue) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j. The queue must have been created with a non-nil 'less' comparison function and it must not be empty.

func (*Uint64Queue) Map added in v0.9.0

func (queue *Uint64Queue) Map(f func(uint64) uint64) *Uint64Queue

Map returns a new Uint64Queue by transforming every element with function f. The resulting queue is the same size as the original queue. The original queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (*Uint64Queue) MapToString added in v0.9.0

func (queue *Uint64Queue) MapToString(f func(uint64) string) []string

MapToString returns a new []string by transforming every element with function f. The resulting slice is the same size as the queue. The queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Uint64Queue) MarshalJSON added in v0.9.0

func (queue Uint64Queue) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this queue type.

func (*Uint64Queue) Max added in v0.9.0

func (queue *Uint64Queue) Max() (result uint64)

Max returns the first element containing the maximum value, when compared to other elements. Panics if the collection is empty.

func (*Uint64Queue) MaxBy added in v0.9.0

func (queue *Uint64Queue) MaxBy(less func(uint64, uint64) bool) uint64

MaxBy returns an element of Uint64Queue containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (*Uint64Queue) Min added in v0.9.0

func (queue *Uint64Queue) Min() uint64

Min returns the first element containing the minimum value, when compared to other elements. Panics if the collection is empty.

func (*Uint64Queue) MinBy added in v0.9.0

func (queue *Uint64Queue) MinBy(less func(uint64, uint64) bool) uint64

MinBy returns an element of Uint64Queue containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (*Uint64Queue) MkString added in v0.9.0

func (queue *Uint64Queue) MkString(sep string) string

MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.

func (*Uint64Queue) MkString3 added in v0.9.0

func (queue *Uint64Queue) MkString3(before, between, after string) string

MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.

func (*Uint64Queue) NonEmpty added in v0.9.0

func (queue *Uint64Queue) NonEmpty() bool

NonEmpty returns true if the queue is not empty.

func (*Uint64Queue) Offer added in v0.9.0

func (queue *Uint64Queue) Offer(items ...uint64) []uint64

Offer appends as many items to the end of the queue as it can. If the queue is already full, what happens depends on whether the queue is configured to overwrite. If it is, the oldest items will be overwritten. Otherwise, it will be filled to capacity and any unwritten items are returned.

If the capacity is too small for the number of items, the excess items are returned. The queue capacity is never altered.

func (*Uint64Queue) Partition added in v0.9.0

func (queue *Uint64Queue) Partition(p func(uint64) bool) (*Uint64Queue, *Uint64Queue)

Partition returns two new Uint64Queues whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't. The relative order of the elements in the results is the same as in the original queue.

The original queue is not modified

func (*Uint64Queue) Pop added in v0.9.0

func (queue *Uint64Queue) Pop(n int) []uint64

Pop removes and returns the oldest items from the queue. If the queue is empty, it returns a nil slice. If n is larger than the current queue length, it returns all the available elements, so in this case the returned slice will be shorter than n.

func (*Uint64Queue) Pop1 added in v0.9.0

func (queue *Uint64Queue) Pop1() (uint64, bool)

Pop1 removes and returns the oldest item from the queue. If the queue is empty, it returns the zero value instead. The boolean is true only if the element was available.

func (*Uint64Queue) Push added in v0.9.0

func (queue *Uint64Queue) Push(items ...uint64) *Uint64Queue

Push appends items to the end of the queue. If the queue does not have enough space, more will be allocated: how this happens depends on the overwriting mode.

When overwriting, the oldest items are overwritten with the new data; it expands the queue only if there is still not enough space.

Otherwise, the queue might be reallocated if necessary, ensuring that all the data is pushed without any older items being affected.

The modified queue is returned.

func (*Uint64Queue) Reallocate added in v0.9.0

func (queue *Uint64Queue) Reallocate(capacity int, overwrite bool) *Uint64Queue

Reallocate adjusts the allocated capacity of the queue and allows the overwriting behaviour to be changed.

If the new queue capacity is different to the current capacity, the queue is re-allocated to the new capacity. If this is less than the current number of elements, the oldest items in the queue are discarded so that the remaining data can fit in the new space available.

If the new queue capacity is the same as the current capacity, the queue is not altered except for adopting the new overwrite flag's value. Therefore this is the means to change the overwriting behaviour.

Reallocate adjusts the storage space but does not clone the underlying elements.

The queue must not be nil.

func (*Uint64Queue) Send added in v0.9.0

func (queue *Uint64Queue) Send() <-chan uint64

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed. The channel will be closed when all the elements have been sent.

func (*Uint64Queue) Size added in v0.9.0

func (queue *Uint64Queue) Size() int

Size gets the number of elements currently in this queue. This is an alias for Len.

func (*Uint64Queue) Sort added in v0.9.0

func (queue *Uint64Queue) Sort()

Sort sorts the queue using the 'less' comparison function, which must not be nil. This function will panic if the collection was created with a nil 'less' function (see NewUint64SortedQueue).

func (*Uint64Queue) Space added in v0.9.0

func (queue *Uint64Queue) Space() int

Space returns the space available in the queue.

func (*Uint64Queue) StableSort added in v0.9.0

func (queue *Uint64Queue) StableSort()

StableSort sorts the queue using the 'less' comparison function, which must not be nil. The result is stable so that repeated calls will not arbitrarily swap equal items. This function will panic if the collection was created with a nil 'less' function (see NewUint64SortedQueue).

func (*Uint64Queue) String added in v0.9.0

func (queue *Uint64Queue) String() string

String implements the Stringer interface to render the queue as a comma-separated string enclosed in square brackets.

func (*Uint64Queue) StringList added in v0.9.0

func (queue *Uint64Queue) StringList() []string

StringList gets a list of strings that depicts all the elements.

func (*Uint64Queue) Sum added in v0.9.0

func (queue *Uint64Queue) Sum() uint64

Sum returns the sum of all the elements in the queue.

func (*Uint64Queue) Swap added in v0.9.0

func (queue *Uint64Queue) Swap(i, j int)

Swap swaps the elements with indexes i and j. The queue must not be empty.

func (*Uint64Queue) ToInterfaceSlice added in v0.9.0

func (queue *Uint64Queue) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the queue as a slice of arbitrary type. The queue is not altered.

func (*Uint64Queue) ToSlice added in v0.9.0

func (queue *Uint64Queue) ToSlice() []uint64

ToSlice returns the elements of the queue as a slice. The queue is not altered.

func (*Uint64Queue) UnmarshalJSON added in v0.9.0

func (queue *Uint64Queue) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this queue type.

type Uint64Sequence added in v0.9.0

type Uint64Sequence interface {
	Uint64Collection

	// Head gets the first element in the sequence. Head plus Tail include the whole sequence. Head is the opposite of Last.
	Head() uint64

	// HeadOption gets the first element in the sequence, if possible.
	HeadOption() (uint64, bool)

	// Last gets the last element in the sequence. Init plus Last include the whole sequence. Last is the opposite of Head.
	Last() uint64

	// LastOption gets the last element in the sequence, if possible.
	LastOption() (uint64, bool)
}

Uint64Sequence defines an interface for sequence methods on uint64.

type Uint64Set added in v0.3.0

type Uint64Set map[uint64]struct{}

Uint64Set is the primary type that represents a set

func BuildUint64SetFromChan added in v0.3.0

func BuildUint64SetFromChan(source <-chan uint64) Uint64Set

BuildUint64SetFromChan constructs a new Uint64Set from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func ConvertUint64Set added in v0.3.0

func ConvertUint64Set(values ...interface{}) (Uint64Set, bool)

ConvertUint64Set constructs a new set containing the supplied values, if any. The returned boolean will be false if any of the values could not be converted correctly. The returned set will contain all the values that were correctly converted.

func NewUint64Set added in v0.3.0

func NewUint64Set(values ...uint64) Uint64Set

NewUint64Set creates and returns a reference to an empty set.

func (Uint64Set) Add added in v0.3.0

func (set Uint64Set) Add(more ...uint64) Uint64Set

Add adds items to the current set, returning the modified set.

func (Uint64Set) Append added in v0.3.0

func (set Uint64Set) Append(more ...uint64) Uint64Set

Append inserts more items into a clone of the set. It returns the augmented set. The original set is unmodified.

func (Uint64Set) Cardinality added in v0.3.0

func (set Uint64Set) Cardinality() int

Cardinality returns how many items are currently in the set. This is a synonym for Size.

func (*Uint64Set) Clear added in v0.3.0

func (set *Uint64Set) Clear()

Clear the entire set. Aterwards, it will be an empty set.

func (Uint64Set) Clone added in v0.3.0

func (set Uint64Set) Clone() Uint64Set

Clone returns a shallow copy of the set. It does not clone the underlying elements.

func (Uint64Set) Contains added in v0.3.0

func (set Uint64Set) Contains(i uint64) bool

Contains determines whether a given item is already in the set, returning true if so.

func (Uint64Set) ContainsAll added in v0.3.0

func (set Uint64Set) ContainsAll(i ...uint64) bool

ContainsAll determines whether a given item is already in the set, returning true if so.

func (Uint64Set) CountBy added in v0.3.0

func (set Uint64Set) CountBy(p func(uint64) bool) (result int)

CountBy gives the number elements of Uint64Set that return true for the predicate p.

func (Uint64Set) Difference added in v0.3.0

func (set Uint64Set) Difference(other Uint64Set) Uint64Set

Difference returns a new set with items in the current set but not in the other set

func (Uint64Set) Equals added in v0.3.0

func (set Uint64Set) Equals(other Uint64Set) bool

Equals determines whether two sets are equal to each other, returning true if so. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for sets to be equal.

func (Uint64Set) Exists added in v0.3.0

func (set Uint64Set) Exists(p func(uint64) bool) bool

Exists applies a predicate p to every element in the set. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (Uint64Set) Filter added in v0.3.0

func (set Uint64Set) Filter(p func(uint64) bool) Uint64Set

Filter returns a new Uint64Set whose elements return true for the predicate p.

The original set is not modified

func (Uint64Set) Find added in v0.3.0

func (set Uint64Set) Find(p func(uint64) bool) (uint64, bool)

Find returns the first uint64 that returns true for the predicate p. If there are many matches one is arbtrarily chosen. False is returned if none match.

func (Uint64Set) FlatMap added in v0.3.0

func (set Uint64Set) FlatMap(f func(uint64) []uint64) Uint64Set

FlatMap returns a new Uint64Set by transforming every element with a function f that returns zero or more items in a slice. The resulting set may have a different size to the original set. The original set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Uint64Set) FlatMapToString added in v0.3.0

func (set Uint64Set) FlatMapToString(f func(uint64) []string) []string

FlatMapToString returns a new []string by transforming every element with function f that returns zero or more items in a slice. The resulting slice may have a different size to the set. The set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Uint64Set) Fold added in v0.9.0

func (set Uint64Set) Fold(initial uint64, fn func(uint64, uint64) uint64) uint64

Fold aggregates all the values in the set using a supplied function, starting from some initial value.

func (Uint64Set) Forall added in v0.3.0

func (set Uint64Set) Forall(p func(uint64) bool) bool

Forall applies a predicate function p to every element in the set. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (Uint64Set) Foreach added in v0.3.0

func (set Uint64Set) Foreach(f func(uint64))

Foreach iterates over the set and executes the function f against each element.

func (Uint64Set) Intersect added in v0.3.0

func (set Uint64Set) Intersect(other Uint64Set) Uint64Set

Intersect returns a new set with items that exist only in both sets.

func (Uint64Set) IsEmpty added in v0.3.0

func (set Uint64Set) IsEmpty() bool

IsEmpty returns true if the set is empty.

func (Uint64Set) IsSequence added in v0.3.0

func (set Uint64Set) IsSequence() bool

IsSequence returns true for lists and queues.

func (Uint64Set) IsSet added in v0.3.0

func (set Uint64Set) IsSet() bool

IsSet returns false for lists or queues.

func (Uint64Set) IsSubset added in v0.3.0

func (set Uint64Set) IsSubset(other Uint64Set) bool

IsSubset determines whether every item in the other set is in this set, returning true if so.

func (Uint64Set) IsSuperset added in v0.3.0

func (set Uint64Set) IsSuperset(other Uint64Set) bool

IsSuperset determines whether every item of this set is in the other set, returning true if so.

func (Uint64Set) Map added in v0.3.0

func (set Uint64Set) Map(f func(uint64) uint64) Uint64Set

Map returns a new Uint64Set by transforming every element with a function f. The original set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Uint64Set) MapToString added in v0.3.0

func (set Uint64Set) MapToString(f func(uint64) string) []string

MapToString returns a new []string by transforming every element with function f. The resulting slice is the same size as the set. The set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Uint64Set) MarshalJSON added in v0.3.0

func (set Uint64Set) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this set type.

func (Uint64Set) Max added in v0.3.0

func (set Uint64Set) Max() uint64

Max returns the first element containing the maximum value, when compared to other elements. Panics if the collection is empty.

func (Uint64Set) MaxBy added in v0.3.0

func (set Uint64Set) MaxBy(less func(uint64, uint64) bool) uint64

MaxBy returns an element of Uint64Set containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (Uint64Set) Min added in v0.3.0

func (set Uint64Set) Min() uint64

Min returns the first element containing the minimum value, when compared to other elements. Panics if the collection is empty.

func (Uint64Set) MinBy added in v0.3.0

func (set Uint64Set) MinBy(less func(uint64, uint64) bool) uint64

MinBy returns an element of Uint64Set containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (Uint64Set) MkString added in v0.3.0

func (set Uint64Set) MkString(sep string) string

MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.

func (Uint64Set) MkString3 added in v0.3.0

func (set Uint64Set) MkString3(before, between, after string) string

MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.

func (Uint64Set) NonEmpty added in v0.3.0

func (set Uint64Set) NonEmpty() bool

NonEmpty returns true if the set is not empty.

func (Uint64Set) Partition added in v0.3.0

func (set Uint64Set) Partition(p func(uint64) bool) (Uint64Set, Uint64Set)

Partition returns two new Uint64Sets whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't.

The original set is not modified

func (Uint64Set) Remove added in v0.3.0

func (set Uint64Set) Remove(i uint64)

Remove a single item from the set.

func (Uint64Set) Send added in v0.3.0

func (set Uint64Set) Send() <-chan uint64

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed

func (Uint64Set) Size added in v0.3.0

func (set Uint64Set) Size() int

Size returns how many items are currently in the set. This is a synonym for Cardinality.

func (Uint64Set) String added in v0.3.0

func (set Uint64Set) String() string

String implements the Stringer interface to render the set as a comma-separated string enclosed in square brackets.

func (Uint64Set) StringList added in v0.3.0

func (set Uint64Set) StringList() []string

StringList gets a list of strings that depicts all the elements.

func (Uint64Set) StringMap added in v0.3.0

func (set Uint64Set) StringMap() map[string]bool

StringMap renders the set as a map of strings. The value of each item in the set becomes stringified as a key in the resulting map.

func (Uint64Set) Sum added in v0.3.0

func (set Uint64Set) Sum() uint64

Sum returns the sum of all the elements in the set.

func (Uint64Set) SymmetricDifference added in v0.3.0

func (set Uint64Set) SymmetricDifference(other Uint64Set) Uint64Set

SymmetricDifference returns a new set with items in the current set or the other set but not in both.

func (Uint64Set) ToInterfaceSlice added in v0.3.0

func (set Uint64Set) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the current set as a slice of arbitrary type.

func (Uint64Set) ToList added in v0.3.0

func (set Uint64Set) ToList() Uint64List

ToList returns the elements of the set as a list. The returned list is a shallow copy; the set is not altered.

func (Uint64Set) ToSet added in v0.3.0

func (set Uint64Set) ToSet() Uint64Set

ToSet returns the set; this is an identity operation in this case.

func (Uint64Set) ToSlice added in v0.3.0

func (set Uint64Set) ToSlice() []uint64

ToSlice returns the elements of the current set as a slice.

func (Uint64Set) Union added in v0.3.0

func (set Uint64Set) Union(other Uint64Set) Uint64Set

Union returns a new set with all items in both sets.

func (Uint64Set) UnmarshalJSON added in v0.3.0

func (set Uint64Set) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this set type.

type Uint64Sizer added in v0.3.0

type Uint64Sizer interface {
	// IsEmpty tests whether Uint64Collection is empty.
	IsEmpty() bool

	// NonEmpty tests whether Uint64Collection is empty.
	NonEmpty() bool

	// Size returns the number of items in the collection - an alias of Len().
	Size() int
}

Uint64Sizer defines an interface for sizing methods on uint64 collections.

type Uint64StringMap added in v0.4.0

type Uint64StringMap map[uint64]string

Uint64StringMap is the primary type that represents a map

func NewUint64StringMap added in v0.4.0

func NewUint64StringMap(kv ...Uint64StringTuple) Uint64StringMap

NewUint64StringMap creates and returns a reference to a map, optionally containing some items.

func NewUint64StringMap1 added in v0.4.0

func NewUint64StringMap1(k uint64, v string) Uint64StringMap

NewUint64StringMap1 creates and returns a reference to a map containing one item.

func (*Uint64StringMap) Clear added in v0.4.0

func (mm *Uint64StringMap) Clear()

Clear clears the entire map.

func (Uint64StringMap) Clone added in v0.4.0

func (mm Uint64StringMap) Clone() Uint64StringMap

Clone returns a shallow copy of the map. It does not clone the underlying elements.

func (Uint64StringMap) ContainsAllKeys added in v0.4.0

func (mm Uint64StringMap) ContainsAllKeys(kk ...uint64) bool

ContainsAllKeys determines if the given items are all in the map.

func (Uint64StringMap) ContainsKey added in v0.4.0

func (mm Uint64StringMap) ContainsKey(k uint64) bool

ContainsKey determines if a given item is already in the map.

func (Uint64StringMap) DropWhere added in v0.4.0

func (mm Uint64StringMap) DropWhere(fn func(uint64, string) bool) Uint64StringTuples

DropWhere applies a predicate function to every element in the map. If the function returns true, the element is dropped from the map. This is similar to Filter except that the map is modified.

func (Uint64StringMap) Equals added in v0.4.0

func (mm Uint64StringMap) Equals(other Uint64StringMap) bool

Equals determines if two maps are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for maps to be equal.

func (Uint64StringMap) Exists added in v0.4.0

func (mm Uint64StringMap) Exists(p func(uint64, string) bool) bool

Exists applies the predicate p to every element in the map. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (Uint64StringMap) Filter added in v0.4.0

func (mm Uint64StringMap) Filter(p func(uint64, string) bool) Uint64StringMap

Filter applies the predicate p to every element in the map and returns a copied map containing only the elements for which the predicate returned true. The original map is not modified.

func (Uint64StringMap) Find added in v0.4.0

func (mm Uint64StringMap) Find(p func(uint64, string) bool) (Uint64StringTuple, bool)

Find returns the first string that returns true for the predicate p. False is returned if none match. The original map is not modified.

func (Uint64StringMap) FlatMap added in v0.4.0

FlatMap returns a new StringMap by transforming every element with the function f that returns zero or more items in a slice. The resulting map may have a different size to the original map. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Uint64StringMap) Forall added in v0.4.0

func (mm Uint64StringMap) Forall(p func(uint64, string) bool) bool

Forall applies the predicate p to every element in the map. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (Uint64StringMap) Foreach added in v0.4.0

func (mm Uint64StringMap) Foreach(f func(uint64, string))

Foreach applies the function f to every element in the map. The function can safely alter the values via side-effects.

func (Uint64StringMap) Get added in v0.4.0

func (mm Uint64StringMap) Get(k uint64) (string, bool)

Get returns one of the items in the map, if present.

func (Uint64StringMap) IsEmpty added in v0.4.0

func (mm Uint64StringMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (Uint64StringMap) Keys added in v0.4.0

func (mm Uint64StringMap) Keys() Uint64List

Keys returns the keys of the current map as a slice.

func (Uint64StringMap) Map added in v0.4.0

Map returns a new StringMap by transforming every element with the function f. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Uint64StringMap) MkString added in v0.4.0

func (mm Uint64StringMap) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (Uint64StringMap) MkString4 added in v0.7.0

func (mm Uint64StringMap) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (Uint64StringMap) NonEmpty added in v0.4.0

func (mm Uint64StringMap) NonEmpty() bool

NonEmpty returns true if the map is not empty.

func (Uint64StringMap) OrderedSlice added in v0.6.0

func (mm Uint64StringMap) OrderedSlice(keys Uint64List) Uint64StringTuples

OrderedSlice returns the key/value pairs as a slice in the order specified by keys.

func (Uint64StringMap) Partition added in v0.4.0

func (mm Uint64StringMap) Partition(p func(uint64, string) bool) (matching Uint64StringMap, others Uint64StringMap)

Partition applies the predicate p to every element in the map. It divides the map into two copied maps, the first containing all the elements for which the predicate returned true, and the second containing all the others. The original map is not modified.

func (Uint64StringMap) Pop added in v0.4.0

func (mm Uint64StringMap) Pop(k uint64) (string, bool)

Pop removes a single item from the map, returning the value present prior to removal.

func (Uint64StringMap) Put added in v0.4.0

func (mm Uint64StringMap) Put(k uint64, v string) bool

Put adds an item to the current map, replacing any prior value.

func (Uint64StringMap) Remove added in v0.4.0

func (mm Uint64StringMap) Remove(k uint64)

Remove a single item from the map.

func (Uint64StringMap) Size added in v0.4.0

func (mm Uint64StringMap) Size() int

Size returns how many items are currently in the map. This is a synonym for Len.

func (Uint64StringMap) String added in v0.4.0

func (mm Uint64StringMap) String() string

String implements the Stringer interface to render the set as a comma-separated string enclosed in square brackets.

func (Uint64StringMap) ToSlice added in v0.4.0

func (mm Uint64StringMap) ToSlice() Uint64StringTuples

ToSlice returns the key/value pairs as a slice.

func (Uint64StringMap) Values added in v0.4.0

func (mm Uint64StringMap) Values() StringList

Values returns the values of the current map as a slice.

type Uint64StringTuple added in v0.4.0

type Uint64StringTuple struct {
	Key uint64
	Val string
}

Uint64StringTuple represents a key/value pair.

func (Uint64StringTuple) MarshalJSON added in v0.6.0

func (t Uint64StringTuple) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding.Marshaler interface.

func (Uint64StringTuple) UnmarshalJSON added in v0.6.0

func (t Uint64StringTuple) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this tuple type.

type Uint64StringTuples added in v0.4.0

type Uint64StringTuples []Uint64StringTuple

Uint64StringTuples can be used as a builder for unmodifiable maps.

func Uint64StringZip added in v0.4.0

func Uint64StringZip(keys ...uint64) Uint64StringTuples

Uint64StringZip is used with the Values method to zip (i.e. interleave) a slice of keys with a slice of values. These can then be passed in to the NewUint64StringMap constructor function.

func (Uint64StringTuples) Append1 added in v0.4.0

Append1 adds one item.

func (Uint64StringTuples) Append2 added in v0.4.0

func (ts Uint64StringTuples) Append2(k1 uint64, v1 string, k2 uint64, v2 string) Uint64StringTuples

Append2 adds two items.

func (Uint64StringTuples) Append3 added in v0.4.0

func (ts Uint64StringTuples) Append3(k1 uint64, v1 string, k2 uint64, v2 string, k3 uint64, v3 string) Uint64StringTuples

Append3 adds three items.

func (Uint64StringTuples) MkString added in v0.6.0

func (ts Uint64StringTuples) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (Uint64StringTuples) MkString4 added in v0.7.0

func (ts Uint64StringTuples) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (Uint64StringTuples) String added in v0.6.0

func (ts Uint64StringTuples) String() string

func (Uint64StringTuples) ToMap added in v0.6.0

ToMap converts the tuples to a map.

func (Uint64StringTuples) Values added in v0.4.0

func (ts Uint64StringTuples) Values(values ...string) Uint64StringTuples

Values sets the values in a tuple slice. Use this with Uint64StringZip.

type Uint64Uint64Map added in v0.3.0

type Uint64Uint64Map map[uint64]uint64

Uint64Uint64Map is the primary type that represents a map

func NewUint64Uint64Map added in v0.3.0

func NewUint64Uint64Map(kv ...Uint64Uint64Tuple) Uint64Uint64Map

NewUint64Uint64Map creates and returns a reference to a map, optionally containing some items.

func NewUint64Uint64Map1 added in v0.3.0

func NewUint64Uint64Map1(k uint64, v uint64) Uint64Uint64Map

NewUint64Uint64Map1 creates and returns a reference to a map containing one item.

func (*Uint64Uint64Map) Clear added in v0.3.0

func (mm *Uint64Uint64Map) Clear()

Clear clears the entire map.

func (Uint64Uint64Map) Clone added in v0.3.0

func (mm Uint64Uint64Map) Clone() Uint64Uint64Map

Clone returns a shallow copy of the map. It does not clone the underlying elements.

func (Uint64Uint64Map) ContainsAllKeys added in v0.3.0

func (mm Uint64Uint64Map) ContainsAllKeys(kk ...uint64) bool

ContainsAllKeys determines if the given items are all in the map.

func (Uint64Uint64Map) ContainsKey added in v0.3.0

func (mm Uint64Uint64Map) ContainsKey(k uint64) bool

ContainsKey determines if a given item is already in the map.

func (Uint64Uint64Map) DropWhere added in v0.3.0

func (mm Uint64Uint64Map) DropWhere(fn func(uint64, uint64) bool) Uint64Uint64Tuples

DropWhere applies a predicate function to every element in the map. If the function returns true, the element is dropped from the map. This is similar to Filter except that the map is modified.

func (Uint64Uint64Map) Equals added in v0.3.0

func (mm Uint64Uint64Map) Equals(other Uint64Uint64Map) bool

Equals determines if two maps are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for maps to be equal.

func (Uint64Uint64Map) Exists added in v0.3.0

func (mm Uint64Uint64Map) Exists(p func(uint64, uint64) bool) bool

Exists applies the predicate p to every element in the map. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (Uint64Uint64Map) Filter added in v0.3.0

func (mm Uint64Uint64Map) Filter(p func(uint64, uint64) bool) Uint64Uint64Map

Filter applies the predicate p to every element in the map and returns a copied map containing only the elements for which the predicate returned true. The original map is not modified.

func (Uint64Uint64Map) Find added in v0.3.0

func (mm Uint64Uint64Map) Find(p func(uint64, uint64) bool) (Uint64Uint64Tuple, bool)

Find returns the first uint64 that returns true for the predicate p. False is returned if none match. The original map is not modified.

func (Uint64Uint64Map) FlatMap added in v0.3.0

FlatMap returns a new Uint64Map by transforming every element with the function f that returns zero or more items in a slice. The resulting map may have a different size to the original map. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Uint64Uint64Map) Forall added in v0.3.0

func (mm Uint64Uint64Map) Forall(p func(uint64, uint64) bool) bool

Forall applies the predicate p to every element in the map. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (Uint64Uint64Map) Foreach added in v0.3.0

func (mm Uint64Uint64Map) Foreach(f func(uint64, uint64))

Foreach applies the function f to every element in the map. The function can safely alter the values via side-effects.

func (Uint64Uint64Map) Get added in v0.3.0

func (mm Uint64Uint64Map) Get(k uint64) (uint64, bool)

Get returns one of the items in the map, if present.

func (Uint64Uint64Map) IsEmpty added in v0.3.0

func (mm Uint64Uint64Map) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (Uint64Uint64Map) Keys added in v0.3.0

func (mm Uint64Uint64Map) Keys() Uint64List

Keys returns the keys of the current map as a slice.

func (Uint64Uint64Map) Map added in v0.3.0

Map returns a new Uint64Map by transforming every element with the function f. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (Uint64Uint64Map) MkString added in v0.3.0

func (mm Uint64Uint64Map) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (Uint64Uint64Map) MkString4 added in v0.7.0

func (mm Uint64Uint64Map) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (Uint64Uint64Map) NonEmpty added in v0.3.0

func (mm Uint64Uint64Map) NonEmpty() bool

NonEmpty returns true if the map is not empty.

func (Uint64Uint64Map) OrderedSlice added in v0.6.0

func (mm Uint64Uint64Map) OrderedSlice(keys Uint64List) Uint64Uint64Tuples

OrderedSlice returns the key/value pairs as a slice in the order specified by keys.

func (Uint64Uint64Map) Partition added in v0.3.0

func (mm Uint64Uint64Map) Partition(p func(uint64, uint64) bool) (matching Uint64Uint64Map, others Uint64Uint64Map)

Partition applies the predicate p to every element in the map. It divides the map into two copied maps, the first containing all the elements for which the predicate returned true, and the second containing all the others. The original map is not modified.

func (Uint64Uint64Map) Pop added in v0.3.0

func (mm Uint64Uint64Map) Pop(k uint64) (uint64, bool)

Pop removes a single item from the map, returning the value present prior to removal.

func (Uint64Uint64Map) Put added in v0.3.0

func (mm Uint64Uint64Map) Put(k uint64, v uint64) bool

Put adds an item to the current map, replacing any prior value.

func (Uint64Uint64Map) Remove added in v0.3.0

func (mm Uint64Uint64Map) Remove(k uint64)

Remove a single item from the map.

func (Uint64Uint64Map) Size added in v0.3.0

func (mm Uint64Uint64Map) Size() int

Size returns how many items are currently in the map. This is a synonym for Len.

func (Uint64Uint64Map) String added in v0.3.0

func (mm Uint64Uint64Map) String() string

String implements the Stringer interface to render the set as a comma-separated string enclosed in square brackets.

func (Uint64Uint64Map) ToSlice added in v0.3.0

func (mm Uint64Uint64Map) ToSlice() Uint64Uint64Tuples

ToSlice returns the key/value pairs as a slice.

func (Uint64Uint64Map) Values added in v0.3.0

func (mm Uint64Uint64Map) Values() Uint64List

Values returns the values of the current map as a slice.

type Uint64Uint64Tuple added in v0.3.0

type Uint64Uint64Tuple struct {
	Key uint64
	Val uint64
}

Uint64Uint64Tuple represents a key/value pair.

func (Uint64Uint64Tuple) MarshalJSON added in v0.6.0

func (t Uint64Uint64Tuple) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding.Marshaler interface.

func (Uint64Uint64Tuple) UnmarshalJSON added in v0.6.0

func (t Uint64Uint64Tuple) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this tuple type.

type Uint64Uint64Tuples added in v0.3.0

type Uint64Uint64Tuples []Uint64Uint64Tuple

Uint64Uint64Tuples can be used as a builder for unmodifiable maps.

func Uint64Uint64Zip added in v0.3.0

func Uint64Uint64Zip(keys ...uint64) Uint64Uint64Tuples

Uint64Uint64Zip is used with the Values method to zip (i.e. interleave) a slice of keys with a slice of values. These can then be passed in to the NewUint64Uint64Map constructor function.

func (Uint64Uint64Tuples) Append1 added in v0.3.0

Append1 adds one item.

func (Uint64Uint64Tuples) Append2 added in v0.3.0

func (ts Uint64Uint64Tuples) Append2(k1 uint64, v1 uint64, k2 uint64, v2 uint64) Uint64Uint64Tuples

Append2 adds two items.

func (Uint64Uint64Tuples) Append3 added in v0.3.0

func (ts Uint64Uint64Tuples) Append3(k1 uint64, v1 uint64, k2 uint64, v2 uint64, k3 uint64, v3 uint64) Uint64Uint64Tuples

Append3 adds three items.

func (Uint64Uint64Tuples) MkString added in v0.6.0

func (ts Uint64Uint64Tuples) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (Uint64Uint64Tuples) MkString4 added in v0.7.0

func (ts Uint64Uint64Tuples) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (Uint64Uint64Tuples) String added in v0.6.0

func (ts Uint64Uint64Tuples) String() string

func (Uint64Uint64Tuples) ToMap added in v0.6.0

ToMap converts the tuples to a map.

func (Uint64Uint64Tuples) Values added in v0.3.0

func (ts Uint64Uint64Tuples) Values(values ...uint64) Uint64Uint64Tuples

Values sets the values in a tuple slice. Use this with Uint64Uint64Zip.

type UintCollection added in v0.3.0

type UintCollection interface {
	UintSizer
	UintMkStringer

	// IsSequence returns true for lists and queues.
	IsSequence() bool

	// IsSet returns false for lists and queues.
	IsSet() bool

	// ToSlice returns a shallow copy as a plain slice.
	ToSlice() []uint

	// ToInterfaceSlice returns a shallow copy as a slice of arbitrary type.
	ToInterfaceSlice() []interface{}

	// Exists verifies that one or more elements of UintCollection return true for the predicate p.
	Exists(p func(uint) bool) bool

	// Forall verifies that all elements of UintCollection return true for the predicate p.
	Forall(p func(uint) bool) bool

	// Foreach iterates over UintCollection and executes the function f against each element.
	Foreach(f func(uint))

	// Find returns the first uint that returns true for the predicate p.
	// False is returned if none match.
	Find(p func(uint) bool) (uint, bool)

	// Send returns a channel that will send all the elements in order. Can be used with the plumbing code, for example.
	// A goroutine is created to send the elements; this only terminates when all the elements have been consumed
	Send() <-chan uint

	// CountBy gives the number elements of UintCollection that return true for the predicate p.
	CountBy(p func(uint) bool) int

	// Contains determines whether a given item is already in the collection, returning true if so.
	Contains(v uint) bool

	// ContainsAll determines whether the given items are all in the collection, returning true if so.
	ContainsAll(v ...uint) bool

	// Min returns the minimum value of all the items in the collection. Panics if there are no elements.
	Min() uint

	// Max returns the minimum value of all the items in the collection. Panics if there are no elements.
	Max() uint

	// MinBy returns an element of UintCollection containing the minimum value, when compared to other elements
	// using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such
	// element is returned. Panics if there are no elements.
	MinBy(less func(uint, uint) bool) uint

	// MaxBy returns an element of UintCollection containing the maximum value, when compared to other elements
	// using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such
	// element is returned. Panics if there are no elements.
	MaxBy(less func(uint, uint) bool) uint

	// Fold aggregates all the values in the collection using a supplied function, starting from some initial value.
	Fold(initial uint, fn func(uint, uint) uint) uint

	// Sum returns the sum of all the elements in the collection.
	Sum() uint
}

UintCollection defines an interface for common collection methods on uint.

type UintList added in v0.3.0

type UintList []uint

UintList is a slice of type uint. Use it where you would use []uint. To add items to the list, simply use the normal built-in append function.

List values follow a similar pattern to Scala Lists and LinearSeqs in particular. For comparison with Scala, see e.g. http://www.scala-lang.org/api/2.11.7/#scala.collection.LinearSeq

func BuildUintListFromChan added in v0.3.0

func BuildUintListFromChan(source <-chan uint) UintList

BuildUintListFromChan constructs a new UintList from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func ConvertUintList added in v0.3.0

func ConvertUintList(values ...interface{}) (UintList, bool)

ConvertUintList constructs a new list containing the supplied values, if any. The returned boolean will be false if any of the values could not be converted correctly. The returned list will contain all the values that were correctly converted. Conversions are provided from all built-in numeric types.

func MakeUintList added in v0.3.0

func MakeUintList(length, capacity int) UintList

MakeUintList makes an empty list with both length and capacity initialised.

func NewUintList added in v0.3.0

func NewUintList(values ...uint) UintList

NewUintList constructs a new list containing the supplied values, if any.

func (UintList) Clone added in v0.3.0

func (list UintList) Clone() UintList

Clone returns a shallow copy of the list. It does not clone the underlying elements.

func (UintList) Contains added in v0.3.0

func (list UintList) Contains(v uint) bool

Contains determines whether a given item is already in the list, returning true if so.

func (UintList) ContainsAll added in v0.3.0

func (list UintList) ContainsAll(i ...uint) bool

ContainsAll determines whether the given items are all in the list, returning true if so. This is potentially a slow method and should only be used rarely.

func (UintList) CountBy added in v0.3.0

func (list UintList) CountBy(p func(uint) bool) (result int)

CountBy gives the number elements of UintList that return true for the predicate p.

func (UintList) DistinctBy added in v0.3.0

func (list UintList) DistinctBy(equal func(uint, uint) bool) UintList

DistinctBy returns a new UintList whose elements are unique, where equality is defined by the equal function.

func (UintList) DoReverse added in v0.3.0

func (list UintList) DoReverse() UintList

DoReverse alters a UintList with all elements in the reverse order. Unlike Reverse, it does not allocate new memory.

The list is modified and the modified list is returned.

func (UintList) DoShuffle added in v0.3.0

func (list UintList) DoShuffle() UintList

DoShuffle returns a shuffled UintList, using a version of the Fisher-Yates shuffle.

The list is modified and the modified list is returned.

func (UintList) Drop added in v0.3.0

func (list UintList) Drop(n int) UintList

Drop returns a slice of UintList without the leading n elements of the source list. If n is greater than or equal to the size of the list, an empty list is returned.

The original list is not modified.

func (UintList) DropLast added in v0.3.0

func (list UintList) DropLast(n int) UintList

DropLast returns a slice of UintList without the trailing n elements of the source list. If n is greater than or equal to the size of the list, an empty list is returned.

The original list is not modified.

func (UintList) DropWhile added in v0.3.0

func (list UintList) DropWhile(p func(uint) bool) UintList

DropWhile returns a new UintList containing the trailing elements of the source list. Whilst the predicate p returns true, elements are excluded from the result. Once predicate p returns false, all remaining elements are added.

The original list is not modified.

func (UintList) Equals added in v0.3.0

func (list UintList) Equals(other UintList) bool

Equals determines if two lists are equal to each other. If they both are the same size and have the same items in the same order, they are considered equal. Order of items is not relevent for sets to be equal.

func (UintList) Exists added in v0.3.0

func (list UintList) Exists(p func(uint) bool) bool

Exists verifies that one or more elements of UintList return true for the predicate p.

func (UintList) Filter added in v0.3.0

func (list UintList) Filter(p func(uint) bool) UintList

Filter returns a new UintList whose elements return true for predicate p.

The original list is not modified.

func (UintList) Find added in v0.3.0

func (list UintList) Find(p func(uint) bool) (uint, bool)

Find returns the first uint that returns true for predicate p. False is returned if none match.

func (UintList) FlatMap added in v0.3.0

func (list UintList) FlatMap(f func(uint) []uint) UintList

FlatMap returns a new UintList by transforming every element with function f that returns zero or more items in a slice. The resulting list may have a different size to the original list. The original list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (UintList) FlatMapToString added in v0.3.0

func (list UintList) FlatMapToString(f func(uint) []string) []string

FlatMapToString returns a new []string by transforming every element with function f that returns zero or more items in a slice. The resulting slice may have a different size to the list. The list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (UintList) Fold added in v0.9.0

func (list UintList) Fold(initial uint, fn func(uint, uint) uint) uint

Fold aggregates all the values in the list using a supplied function, starting from some initial value.

func (UintList) Forall added in v0.3.0

func (list UintList) Forall(p func(uint) bool) bool

Forall verifies that all elements of UintList return true for the predicate p.

func (UintList) Foreach added in v0.3.0

func (list UintList) Foreach(f func(uint))

Foreach iterates over UintList and executes function f against each element.

func (UintList) Get added in v0.3.0

func (list UintList) Get(i int) uint

Get gets the specified element in the list. Panics if the index is out of range or the list is nil. The simple list is a dressed-up slice and normal slice operations will also work.

func (UintList) GobDecode added in v0.3.0

func (list UintList) GobDecode(b []byte) error

GobDecode implements 'gob' decoding for this list type. You must register uint with the 'gob' package before this method is used.

func (UintList) GobEncode added in v0.3.0

func (list UintList) GobEncode() ([]byte, error)

GobEncode implements 'gob' encoding for this list type. You must register uint with the 'gob' package before this method is used.

func (UintList) Head added in v0.3.0

func (list UintList) Head() uint

Head gets the first element in the list. Head plus Tail include the whole list. Head is the opposite of Last. Panics if list is empty or nil.

func (UintList) HeadOption added in v0.3.0

func (list UintList) HeadOption() (uint, bool)

HeadOption gets the first element in the list, if possible. Otherwise returns the zero value.

func (UintList) IndexWhere added in v0.3.0

func (list UintList) IndexWhere(p func(uint) bool) int

IndexWhere finds the index of the first element satisfying predicate p. If none exists, -1 is returned.

func (UintList) IndexWhere2 added in v0.3.0

func (list UintList) IndexWhere2(p func(uint) bool, from int) int

IndexWhere2 finds the index of the first element satisfying predicate p at or after some start index. If none exists, -1 is returned.

func (UintList) Init added in v0.3.0

func (list UintList) Init() UintList

Init gets everything except the last. Init plus Last include the whole list. Init is the opposite of Tail. Panics if list is empty or nil.

func (UintList) IsEmpty added in v0.3.0

func (list UintList) IsEmpty() bool

IsEmpty tests whether UintList is empty.

func (UintList) IsSequence added in v0.3.0

func (list UintList) IsSequence() bool

IsSequence returns true for lists and queues.

func (UintList) IsSet added in v0.3.0

func (list UintList) IsSet() bool

IsSet returns false for lists or queues.

func (UintList) Last added in v0.3.0

func (list UintList) Last() uint

Last gets the last element in the list. Init plus Last include the whole list. Last is the opposite of Head. Panics if list is empty or nil.

func (UintList) LastIndexWhere added in v0.3.0

func (list UintList) LastIndexWhere(p func(uint) bool) int

LastIndexWhere finds the index of the last element satisfying predicate p. If none exists, -1 is returned.

func (UintList) LastIndexWhere2 added in v0.3.0

func (list UintList) LastIndexWhere2(p func(uint) bool, before int) int

LastIndexWhere2 finds the index of the last element satisfying predicate p at or before some start index. If none exists, -1 is returned.

func (UintList) LastOption added in v0.3.0

func (list UintList) LastOption() (uint, bool)

LastOption gets the last element in the list, if possible. Otherwise returns the zero value.

func (UintList) Len added in v0.3.0

func (list UintList) Len() int

Len returns the number of items in the list - an alias of Size(). This is one of the three methods in the standard sort.Interface.

func (UintList) Map added in v0.3.0

func (list UintList) Map(f func(uint) uint) UintList

Map returns a new UintList by transforming every element with function f. The resulting list is the same size as the original list. The original list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (UintList) MapToString added in v0.3.0

func (list UintList) MapToString(f func(uint) string) []string

MapToString returns a new []string by transforming every element with function f. The resulting slice is the same size as the list. The list is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (UintList) Max added in v0.3.0

func (list UintList) Max() (result uint)

Max returns the first element containing the maximum value, when compared to other elements. Panics if the collection is empty.

func (UintList) MaxBy added in v0.3.0

func (list UintList) MaxBy(less func(uint, uint) bool) uint

MaxBy returns an element of UintList containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (UintList) Min added in v0.3.0

func (list UintList) Min() uint

Min returns the first element containing the minimum value, when compared to other elements. Panics if the collection is empty.

func (UintList) MinBy added in v0.3.0

func (list UintList) MinBy(less func(uint, uint) bool) uint

MinBy returns an element of UintList containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (UintList) MkString added in v0.3.0

func (list UintList) MkString(sep string) string

MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.

func (UintList) MkString3 added in v0.3.0

func (list UintList) MkString3(before, between, after string) string

MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.

func (UintList) NonEmpty added in v0.3.0

func (list UintList) NonEmpty() bool

NonEmpty tests whether UintList is empty.

func (UintList) Partition added in v0.3.0

func (list UintList) Partition(p func(uint) bool) (UintList, UintList)

Partition returns two new UintLists whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't. The relative order of the elements in the results is the same as in the original list.

The original list is not modified.

func (UintList) Reverse added in v0.3.0

func (list UintList) Reverse() UintList

Reverse returns a copy of UintList with all elements in the reverse order.

The original list is not modified.

func (UintList) Send added in v0.3.0

func (list UintList) Send() <-chan uint

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed. The channel will be closed when all the elements have been sent.

func (UintList) Shuffle added in v0.3.0

func (list UintList) Shuffle() UintList

Shuffle returns a shuffled copy of UintList, using a version of the Fisher-Yates shuffle.

The original list is not modified.

func (UintList) Size added in v0.3.0

func (list UintList) Size() int

Size returns the number of items in the list - an alias of Len().

func (UintList) SortBy added in v0.3.0

func (list UintList) SortBy(less func(i, j uint) bool) UintList

SortBy alters the list so that the elements are sorted by a specified ordering. Sorting happens in-place; the modified list is returned.

func (UintList) Sorted added in v0.3.0

func (list UintList) Sorted() UintList

Sorted alters the list so that the elements are sorted by their natural ordering. Sorting happens in-place; the modified list is returned.

func (UintList) StableSortBy added in v0.3.0

func (list UintList) StableSortBy(less func(i, j uint) bool) UintList

StableSortBy alters the list so that the elements are sorted by a specified ordering. Sorting happens in-place; the modified list is returned. The algorithm keeps the original order of equal elements.

func (UintList) StableSorted added in v0.3.0

func (list UintList) StableSorted() UintList

StableSorted alters the list so that the elements are sorted by their natural ordering. Sorting happens in-place; the modified list is returned.

func (UintList) String added in v0.3.0

func (list UintList) String() string

String implements the Stringer interface to render the list as a comma-separated string enclosed in square brackets.

func (UintList) StringList added in v0.3.0

func (list UintList) StringList() []string

StringList gets a list of strings that depicts all the elements.

func (UintList) Sum added in v0.3.0

func (list UintList) Sum() uint

Sum returns the sum of all the elements in the list.

func (UintList) Swap added in v0.3.0

func (list UintList) Swap(i, j int)

Swap exchanges two elements, which is necessary during sorting etc. This is one of the three methods in the standard sort.Interface.

func (UintList) Tail added in v0.3.0

func (list UintList) Tail() UintList

Tail gets everything except the head. Head plus Tail include the whole list. Tail is the opposite of Init. Panics if list is empty or nil.

func (UintList) Take added in v0.3.0

func (list UintList) Take(n int) UintList

Take returns a slice of UintList containing the leading n elements of the source list. If n is greater than or equal to the size of the list, the whole original list is returned.

func (UintList) TakeLast added in v0.3.0

func (list UintList) TakeLast(n int) UintList

TakeLast returns a slice of UintList containing the trailing n elements of the source list. If n is greater than or equal to the size of the list, the whole original list is returned.

The original list is not modified.

func (UintList) TakeWhile added in v0.3.0

func (list UintList) TakeWhile(p func(uint) bool) UintList

TakeWhile returns a new UintList containing the leading elements of the source list. Whilst the predicate p returns true, elements are added to the result. Once predicate p returns false, all remaining elements are excluded.

The original list is not modified.

func (UintList) ToInterfaceSlice added in v0.3.0

func (list UintList) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the current list as a slice of arbitrary type.

func (UintList) ToList added in v0.3.0

func (list UintList) ToList() UintList

ToList returns the elements of the list as a list, which is an identity operation in this case.

func (UintList) ToSet added in v0.3.0

func (list UintList) ToSet() UintSet

ToSet returns the elements of the list as a set. The returned set is a shallow copy; the list is not altered.

func (UintList) ToSlice added in v0.3.0

func (list UintList) ToSlice() []uint

ToSlice returns the elements of the list as a slice, which is an identity operation in this case, because the simple list is merely a dressed-up slice.

type UintMkStringer added in v0.3.0

type UintMkStringer interface {
	// String implements the Stringer interface to render the collection as a comma-separated string enclosed
	// in square brackets.
	String() string

	// MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.
	MkString(sep string) string

	// MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.
	MkString3(before, between, after string) string

	// StringList gets a collection of strings that depicts all the elements.
	StringList() []string
}

UintMkStringer defines an interface for stringer methods on uint collections.

type UintQueue added in v0.9.0

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

UintQueue is a ring buffer containing a slice of type uint. It is optimised for FIFO operations.

func BuildUintQueueFromChan added in v0.9.0

func BuildUintQueueFromChan(source <-chan uint) *UintQueue

BuildUintQueueFromChan constructs a new UintQueue from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func NewUintQueue added in v0.9.0

func NewUintQueue(capacity int, overwrite bool) *UintQueue

NewUintQueue returns a new queue of uint. The behaviour when adding to the queue depends on overwrite. If true, the push operation overwrites oldest values up to the space available, when the queue is full. Otherwise, it refuses to overfill the queue.

func NewUintSortedQueue added in v0.9.0

func NewUintSortedQueue(capacity int, overwrite bool, less func(i, j uint) bool) *UintQueue

NewUintSortedQueue returns a new queue of uint. The behaviour when adding to the queue depends on overwrite. If true, the push operation overwrites oldest values up to the space available, when the queue is full. Otherwise, it refuses to overfill the queue. If the 'less' comparison function is not nil, elements can be easily sorted.

func (*UintQueue) Add added in v0.9.0

func (queue *UintQueue) Add(more ...uint)

Add adds items to the queue. This is a synonym for Push.

func (*UintQueue) Cap added in v0.9.0

func (queue *UintQueue) Cap() int

Cap gets the capacity of this queue.

func (*UintQueue) Clear added in v0.9.0

func (queue *UintQueue) Clear()

Clear the entire queue.

func (*UintQueue) Clone added in v0.9.0

func (queue *UintQueue) Clone() *UintQueue

Clone returns a shallow copy of the queue. It does not clone the underlying elements.

func (*UintQueue) Contains added in v0.9.0

func (queue *UintQueue) Contains(v uint) bool

Contains determines whether a given item is already in the queue, returning true if so.

func (*UintQueue) ContainsAll added in v0.9.0

func (queue *UintQueue) ContainsAll(i ...uint) bool

ContainsAll determines whether the given items are all in the queue, returning true if so. This is potentially a slow method and should only be used rarely.

func (*UintQueue) CountBy added in v0.9.0

func (queue *UintQueue) CountBy(p func(uint) bool) (result int)

CountBy gives the number elements of UintQueue that return true for the predicate p.

func (*UintQueue) DoKeepWhere added in v0.9.0

func (queue *UintQueue) DoKeepWhere(p func(uint) bool) *UintQueue

DoKeepWhere modifies a UintQueue by retaining only those elements that match the predicate p. This is very similar to Filter but alters the queue in place.

The queue is modified and the modified queue is returned.

func (*UintQueue) Equals added in v0.9.0

func (queue *UintQueue) Equals(other *UintQueue) bool

Equals determines if two queues are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for sets to be equal. Nil queues are considered to be empty.

func (*UintQueue) Exists added in v0.9.0

func (queue *UintQueue) Exists(p func(uint) bool) bool

Exists verifies that one or more elements of UintQueue return true for the predicate p. The function should not alter the values via side-effects.

func (*UintQueue) Filter added in v0.9.0

func (queue *UintQueue) Filter(p func(uint) bool) *UintQueue

Filter returns a new UintQueue whose elements return true for predicate p.

The original queue is not modified. See also DoKeepWhere (which does modify the original queue).

func (*UintQueue) Find added in v0.9.0

func (queue *UintQueue) Find(p func(uint) bool) (uint, bool)

Find returns the first uint that returns true for predicate p. False is returned if none match.

func (*UintQueue) FlatMap added in v0.9.0

func (queue *UintQueue) FlatMap(f func(uint) []uint) *UintQueue

FlatMap returns a new UintQueue by transforming every element with function f that returns zero or more items in a slice. The resulting queue may have a different size to the original queue. The original queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (*UintQueue) FlatMapToString added in v0.9.0

func (queue *UintQueue) FlatMapToString(f func(uint) []string) []string

FlatMapToString returns a new []string by transforming every element with function f that returns zero or more items in a slice. The resulting slice may have a different size to the queue. The queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (*UintQueue) Fold added in v0.9.0

func (queue *UintQueue) Fold(initial uint, fn func(uint, uint) uint) uint

Fold aggregates all the values in the queue using a supplied function, starting from some initial value.

func (*UintQueue) Forall added in v0.9.0

func (queue *UintQueue) Forall(p func(uint) bool) bool

Forall verifies that all elements of UintQueue return true for the predicate p. The function should not alter the values via side-effects.

func (*UintQueue) Foreach added in v0.9.0

func (queue *UintQueue) Foreach(f func(uint))

Foreach iterates over UintQueue and executes function f against each element. The function can safely alter the values via side-effects.

func (*UintQueue) Get added in v0.9.0

func (queue *UintQueue) Get(i int) uint

Get gets the specified element in the queue. Panics if the index is out of range or the queue is nil.

func (*UintQueue) Head added in v0.9.0

func (queue *UintQueue) Head() uint

Head gets the first element in the queue. Head is the opposite of Last. Panics if queue is empty or nil.

func (*UintQueue) HeadOption added in v0.9.0

func (queue *UintQueue) HeadOption() (uint, bool)

HeadOption returns the oldest item in the queue without removing it. If the queue is nil or empty, it returns the zero value instead.

func (*UintQueue) IsEmpty added in v0.9.0

func (queue *UintQueue) IsEmpty() bool

IsEmpty returns true if the queue is empty.

func (*UintQueue) IsFull added in v0.9.0

func (queue *UintQueue) IsFull() bool

IsFull returns true if the queue is full.

func (*UintQueue) IsOverwriting added in v0.9.0

func (queue *UintQueue) IsOverwriting() bool

IsOverwriting returns true if the queue is overwriting, false if refusing.

func (*UintQueue) IsSequence added in v0.9.0

func (queue *UintQueue) IsSequence() bool

IsSequence returns true for ordered lists and queues.

func (*UintQueue) IsSet added in v0.9.0

func (queue *UintQueue) IsSet() bool

IsSet returns false for lists or queues.

func (*UintQueue) Last added in v0.9.0

func (queue *UintQueue) Last() uint

Last gets the the newest item in the queue (i.e. last element pushed) without removing it. Last is the opposite of Head. Panics if queue is empty or nil.

func (*UintQueue) LastOption added in v0.9.0

func (queue *UintQueue) LastOption() (uint, bool)

LastOption returns the newest item in the queue without removing it. If the queue is nil empty, it returns the zero value instead.

func (*UintQueue) Len added in v0.9.0

func (queue *UintQueue) Len() int

Len gets the current length of this queue. This is an alias for Size.

func (*UintQueue) Less added in v0.9.0

func (queue *UintQueue) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j. The queue must have been created with a non-nil 'less' comparison function and it must not be empty.

func (*UintQueue) Map added in v0.9.0

func (queue *UintQueue) Map(f func(uint) uint) *UintQueue

Map returns a new UintQueue by transforming every element with function f. The resulting queue is the same size as the original queue. The original queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (*UintQueue) MapToString added in v0.9.0

func (queue *UintQueue) MapToString(f func(uint) string) []string

MapToString returns a new []string by transforming every element with function f. The resulting slice is the same size as the queue. The queue is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (UintQueue) MarshalJSON added in v0.9.0

func (queue UintQueue) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this queue type.

func (*UintQueue) Max added in v0.9.0

func (queue *UintQueue) Max() (result uint)

Max returns the first element containing the maximum value, when compared to other elements. Panics if the collection is empty.

func (*UintQueue) MaxBy added in v0.9.0

func (queue *UintQueue) MaxBy(less func(uint, uint) bool) uint

MaxBy returns an element of UintQueue containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (*UintQueue) Min added in v0.9.0

func (queue *UintQueue) Min() uint

Min returns the first element containing the minimum value, when compared to other elements. Panics if the collection is empty.

func (*UintQueue) MinBy added in v0.9.0

func (queue *UintQueue) MinBy(less func(uint, uint) bool) uint

MinBy returns an element of UintQueue containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (*UintQueue) MkString added in v0.9.0

func (queue *UintQueue) MkString(sep string) string

MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.

func (*UintQueue) MkString3 added in v0.9.0

func (queue *UintQueue) MkString3(before, between, after string) string

MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.

func (*UintQueue) NonEmpty added in v0.9.0

func (queue *UintQueue) NonEmpty() bool

NonEmpty returns true if the queue is not empty.

func (*UintQueue) Offer added in v0.9.0

func (queue *UintQueue) Offer(items ...uint) []uint

Offer appends as many items to the end of the queue as it can. If the queue is already full, what happens depends on whether the queue is configured to overwrite. If it is, the oldest items will be overwritten. Otherwise, it will be filled to capacity and any unwritten items are returned.

If the capacity is too small for the number of items, the excess items are returned. The queue capacity is never altered.

func (*UintQueue) Partition added in v0.9.0

func (queue *UintQueue) Partition(p func(uint) bool) (*UintQueue, *UintQueue)

Partition returns two new UintQueues whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't. The relative order of the elements in the results is the same as in the original queue.

The original queue is not modified

func (*UintQueue) Pop added in v0.9.0

func (queue *UintQueue) Pop(n int) []uint

Pop removes and returns the oldest items from the queue. If the queue is empty, it returns a nil slice. If n is larger than the current queue length, it returns all the available elements, so in this case the returned slice will be shorter than n.

func (*UintQueue) Pop1 added in v0.9.0

func (queue *UintQueue) Pop1() (uint, bool)

Pop1 removes and returns the oldest item from the queue. If the queue is empty, it returns the zero value instead. The boolean is true only if the element was available.

func (*UintQueue) Push added in v0.9.0

func (queue *UintQueue) Push(items ...uint) *UintQueue

Push appends items to the end of the queue. If the queue does not have enough space, more will be allocated: how this happens depends on the overwriting mode.

When overwriting, the oldest items are overwritten with the new data; it expands the queue only if there is still not enough space.

Otherwise, the queue might be reallocated if necessary, ensuring that all the data is pushed without any older items being affected.

The modified queue is returned.

func (*UintQueue) Reallocate added in v0.9.0

func (queue *UintQueue) Reallocate(capacity int, overwrite bool) *UintQueue

Reallocate adjusts the allocated capacity of the queue and allows the overwriting behaviour to be changed.

If the new queue capacity is different to the current capacity, the queue is re-allocated to the new capacity. If this is less than the current number of elements, the oldest items in the queue are discarded so that the remaining data can fit in the new space available.

If the new queue capacity is the same as the current capacity, the queue is not altered except for adopting the new overwrite flag's value. Therefore this is the means to change the overwriting behaviour.

Reallocate adjusts the storage space but does not clone the underlying elements.

The queue must not be nil.

func (*UintQueue) Send added in v0.9.0

func (queue *UintQueue) Send() <-chan uint

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed. The channel will be closed when all the elements have been sent.

func (*UintQueue) Size added in v0.9.0

func (queue *UintQueue) Size() int

Size gets the number of elements currently in this queue. This is an alias for Len.

func (*UintQueue) Sort added in v0.9.0

func (queue *UintQueue) Sort()

Sort sorts the queue using the 'less' comparison function, which must not be nil. This function will panic if the collection was created with a nil 'less' function (see NewUintSortedQueue).

func (*UintQueue) Space added in v0.9.0

func (queue *UintQueue) Space() int

Space returns the space available in the queue.

func (*UintQueue) StableSort added in v0.9.0

func (queue *UintQueue) StableSort()

StableSort sorts the queue using the 'less' comparison function, which must not be nil. The result is stable so that repeated calls will not arbitrarily swap equal items. This function will panic if the collection was created with a nil 'less' function (see NewUintSortedQueue).

func (*UintQueue) String added in v0.9.0

func (queue *UintQueue) String() string

String implements the Stringer interface to render the queue as a comma-separated string enclosed in square brackets.

func (*UintQueue) StringList added in v0.9.0

func (queue *UintQueue) StringList() []string

StringList gets a list of strings that depicts all the elements.

func (*UintQueue) Sum added in v0.9.0

func (queue *UintQueue) Sum() uint

Sum returns the sum of all the elements in the queue.

func (*UintQueue) Swap added in v0.9.0

func (queue *UintQueue) Swap(i, j int)

Swap swaps the elements with indexes i and j. The queue must not be empty.

func (*UintQueue) ToInterfaceSlice added in v0.9.0

func (queue *UintQueue) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the queue as a slice of arbitrary type. The queue is not altered.

func (*UintQueue) ToSlice added in v0.9.0

func (queue *UintQueue) ToSlice() []uint

ToSlice returns the elements of the queue as a slice. The queue is not altered.

func (*UintQueue) UnmarshalJSON added in v0.9.0

func (queue *UintQueue) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this queue type.

type UintSequence added in v0.9.0

type UintSequence interface {
	UintCollection

	// Head gets the first element in the sequence. Head plus Tail include the whole sequence. Head is the opposite of Last.
	Head() uint

	// HeadOption gets the first element in the sequence, if possible.
	HeadOption() (uint, bool)

	// Last gets the last element in the sequence. Init plus Last include the whole sequence. Last is the opposite of Head.
	Last() uint

	// LastOption gets the last element in the sequence, if possible.
	LastOption() (uint, bool)
}

UintSequence defines an interface for sequence methods on uint.

type UintSet added in v0.3.0

type UintSet map[uint]struct{}

UintSet is the primary type that represents a set

func BuildUintSetFromChan added in v0.3.0

func BuildUintSetFromChan(source <-chan uint) UintSet

BuildUintSetFromChan constructs a new UintSet from a channel that supplies a sequence of values until it is closed. The function doesn't return until then.

func ConvertUintSet added in v0.3.0

func ConvertUintSet(values ...interface{}) (UintSet, bool)

ConvertUintSet constructs a new set containing the supplied values, if any. The returned boolean will be false if any of the values could not be converted correctly. The returned set will contain all the values that were correctly converted.

func NewUintSet added in v0.3.0

func NewUintSet(values ...uint) UintSet

NewUintSet creates and returns a reference to an empty set.

func (UintSet) Add added in v0.3.0

func (set UintSet) Add(more ...uint) UintSet

Add adds items to the current set, returning the modified set.

func (UintSet) Append added in v0.3.0

func (set UintSet) Append(more ...uint) UintSet

Append inserts more items into a clone of the set. It returns the augmented set. The original set is unmodified.

func (UintSet) Cardinality added in v0.3.0

func (set UintSet) Cardinality() int

Cardinality returns how many items are currently in the set. This is a synonym for Size.

func (*UintSet) Clear added in v0.3.0

func (set *UintSet) Clear()

Clear the entire set. Aterwards, it will be an empty set.

func (UintSet) Clone added in v0.3.0

func (set UintSet) Clone() UintSet

Clone returns a shallow copy of the set. It does not clone the underlying elements.

func (UintSet) Contains added in v0.3.0

func (set UintSet) Contains(i uint) bool

Contains determines whether a given item is already in the set, returning true if so.

func (UintSet) ContainsAll added in v0.3.0

func (set UintSet) ContainsAll(i ...uint) bool

ContainsAll determines whether a given item is already in the set, returning true if so.

func (UintSet) CountBy added in v0.3.0

func (set UintSet) CountBy(p func(uint) bool) (result int)

CountBy gives the number elements of UintSet that return true for the predicate p.

func (UintSet) Difference added in v0.3.0

func (set UintSet) Difference(other UintSet) UintSet

Difference returns a new set with items in the current set but not in the other set

func (UintSet) Equals added in v0.3.0

func (set UintSet) Equals(other UintSet) bool

Equals determines whether two sets are equal to each other, returning true if so. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for sets to be equal.

func (UintSet) Exists added in v0.3.0

func (set UintSet) Exists(p func(uint) bool) bool

Exists applies a predicate p to every element in the set. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (UintSet) Filter added in v0.3.0

func (set UintSet) Filter(p func(uint) bool) UintSet

Filter returns a new UintSet whose elements return true for the predicate p.

The original set is not modified

func (UintSet) Find added in v0.3.0

func (set UintSet) Find(p func(uint) bool) (uint, bool)

Find returns the first uint that returns true for the predicate p. If there are many matches one is arbtrarily chosen. False is returned if none match.

func (UintSet) FlatMap added in v0.3.0

func (set UintSet) FlatMap(f func(uint) []uint) UintSet

FlatMap returns a new UintSet by transforming every element with a function f that returns zero or more items in a slice. The resulting set may have a different size to the original set. The original set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (UintSet) FlatMapToString added in v0.3.0

func (set UintSet) FlatMapToString(f func(uint) []string) []string

FlatMapToString returns a new []string by transforming every element with function f that returns zero or more items in a slice. The resulting slice may have a different size to the set. The set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (UintSet) Fold added in v0.9.0

func (set UintSet) Fold(initial uint, fn func(uint, uint) uint) uint

Fold aggregates all the values in the set using a supplied function, starting from some initial value.

func (UintSet) Forall added in v0.3.0

func (set UintSet) Forall(p func(uint) bool) bool

Forall applies a predicate function p to every element in the set. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (UintSet) Foreach added in v0.3.0

func (set UintSet) Foreach(f func(uint))

Foreach iterates over the set and executes the function f against each element.

func (UintSet) Intersect added in v0.3.0

func (set UintSet) Intersect(other UintSet) UintSet

Intersect returns a new set with items that exist only in both sets.

func (UintSet) IsEmpty added in v0.3.0

func (set UintSet) IsEmpty() bool

IsEmpty returns true if the set is empty.

func (UintSet) IsSequence added in v0.3.0

func (set UintSet) IsSequence() bool

IsSequence returns true for lists and queues.

func (UintSet) IsSet added in v0.3.0

func (set UintSet) IsSet() bool

IsSet returns false for lists or queues.

func (UintSet) IsSubset added in v0.3.0

func (set UintSet) IsSubset(other UintSet) bool

IsSubset determines whether every item in the other set is in this set, returning true if so.

func (UintSet) IsSuperset added in v0.3.0

func (set UintSet) IsSuperset(other UintSet) bool

IsSuperset determines whether every item of this set is in the other set, returning true if so.

func (UintSet) Map added in v0.3.0

func (set UintSet) Map(f func(uint) uint) UintSet

Map returns a new UintSet by transforming every element with a function f. The original set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (UintSet) MapToString added in v0.3.0

func (set UintSet) MapToString(f func(uint) string) []string

MapToString returns a new []string by transforming every element with function f. The resulting slice is the same size as the set. The set is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (UintSet) MarshalJSON added in v0.3.0

func (set UintSet) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this set type.

func (UintSet) Max added in v0.3.0

func (set UintSet) Max() uint

Max returns the first element containing the maximum value, when compared to other elements. Panics if the collection is empty.

func (UintSet) MaxBy added in v0.3.0

func (set UintSet) MaxBy(less func(uint, uint) bool) uint

MaxBy returns an element of UintSet containing the maximum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally maximal, the first such element is returned. Panics if there are no elements.

func (UintSet) Min added in v0.3.0

func (set UintSet) Min() uint

Min returns the first element containing the minimum value, when compared to other elements. Panics if the collection is empty.

func (UintSet) MinBy added in v0.3.0

func (set UintSet) MinBy(less func(uint, uint) bool) uint

MinBy returns an element of UintSet containing the minimum value, when compared to other elements using a passed func defining ‘less’. In the case of multiple items being equally minimal, the first such element is returned. Panics if there are no elements.

func (UintSet) MkString added in v0.3.0

func (set UintSet) MkString(sep string) string

MkString concatenates the values as a string using a supplied separator. No enclosing marks are added.

func (UintSet) MkString3 added in v0.3.0

func (set UintSet) MkString3(before, between, after string) string

MkString3 concatenates the values as a string, using the prefix, separator and suffix supplied.

func (UintSet) NonEmpty added in v0.3.0

func (set UintSet) NonEmpty() bool

NonEmpty returns true if the set is not empty.

func (UintSet) Partition added in v0.3.0

func (set UintSet) Partition(p func(uint) bool) (UintSet, UintSet)

Partition returns two new UintSets whose elements return true or false for the predicate, p. The first result consists of all elements that satisfy the predicate and the second result consists of all elements that don't.

The original set is not modified

func (UintSet) Remove added in v0.3.0

func (set UintSet) Remove(i uint)

Remove a single item from the set.

func (UintSet) Send added in v0.3.0

func (set UintSet) Send() <-chan uint

Send returns a channel that will send all the elements in order. A goroutine is created to send the elements; this only terminates when all the elements have been consumed

func (UintSet) Size added in v0.3.0

func (set UintSet) Size() int

Size returns how many items are currently in the set. This is a synonym for Cardinality.

func (UintSet) String added in v0.3.0

func (set UintSet) String() string

String implements the Stringer interface to render the set as a comma-separated string enclosed in square brackets.

func (UintSet) StringList added in v0.3.0

func (set UintSet) StringList() []string

StringList gets a list of strings that depicts all the elements.

func (UintSet) StringMap added in v0.3.0

func (set UintSet) StringMap() map[string]bool

StringMap renders the set as a map of strings. The value of each item in the set becomes stringified as a key in the resulting map.

func (UintSet) Sum added in v0.3.0

func (set UintSet) Sum() uint

Sum returns the sum of all the elements in the set.

func (UintSet) SymmetricDifference added in v0.3.0

func (set UintSet) SymmetricDifference(other UintSet) UintSet

SymmetricDifference returns a new set with items in the current set or the other set but not in both.

func (UintSet) ToInterfaceSlice added in v0.3.0

func (set UintSet) ToInterfaceSlice() []interface{}

ToInterfaceSlice returns the elements of the current set as a slice of arbitrary type.

func (UintSet) ToList added in v0.3.0

func (set UintSet) ToList() UintList

ToList returns the elements of the set as a list. The returned list is a shallow copy; the set is not altered.

func (UintSet) ToSet added in v0.3.0

func (set UintSet) ToSet() UintSet

ToSet returns the set; this is an identity operation in this case.

func (UintSet) ToSlice added in v0.3.0

func (set UintSet) ToSlice() []uint

ToSlice returns the elements of the current set as a slice.

func (UintSet) Union added in v0.3.0

func (set UintSet) Union(other UintSet) UintSet

Union returns a new set with all items in both sets.

func (UintSet) UnmarshalJSON added in v0.3.0

func (set UintSet) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this set type.

type UintSizer added in v0.3.0

type UintSizer interface {
	// IsEmpty tests whether UintCollection is empty.
	IsEmpty() bool

	// NonEmpty tests whether UintCollection is empty.
	NonEmpty() bool

	// Size returns the number of items in the collection - an alias of Len().
	Size() int
}

UintSizer defines an interface for sizing methods on uint collections.

type UintStringMap added in v0.3.0

type UintStringMap map[uint]string

UintStringMap is the primary type that represents a map

func NewUintStringMap added in v0.3.0

func NewUintStringMap(kv ...UintStringTuple) UintStringMap

NewUintStringMap creates and returns a reference to a map, optionally containing some items.

func NewUintStringMap1 added in v0.3.0

func NewUintStringMap1(k uint, v string) UintStringMap

NewUintStringMap1 creates and returns a reference to a map containing one item.

func (*UintStringMap) Clear added in v0.3.0

func (mm *UintStringMap) Clear()

Clear clears the entire map.

func (UintStringMap) Clone added in v0.3.0

func (mm UintStringMap) Clone() UintStringMap

Clone returns a shallow copy of the map. It does not clone the underlying elements.

func (UintStringMap) ContainsAllKeys added in v0.3.0

func (mm UintStringMap) ContainsAllKeys(kk ...uint) bool

ContainsAllKeys determines if the given items are all in the map.

func (UintStringMap) ContainsKey added in v0.3.0

func (mm UintStringMap) ContainsKey(k uint) bool

ContainsKey determines if a given item is already in the map.

func (UintStringMap) DropWhere added in v0.3.0

func (mm UintStringMap) DropWhere(fn func(uint, string) bool) UintStringTuples

DropWhere applies a predicate function to every element in the map. If the function returns true, the element is dropped from the map. This is similar to Filter except that the map is modified.

func (UintStringMap) Equals added in v0.3.0

func (mm UintStringMap) Equals(other UintStringMap) bool

Equals determines if two maps are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for maps to be equal.

func (UintStringMap) Exists added in v0.3.0

func (mm UintStringMap) Exists(p func(uint, string) bool) bool

Exists applies the predicate p to every element in the map. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (UintStringMap) Filter added in v0.3.0

func (mm UintStringMap) Filter(p func(uint, string) bool) UintStringMap

Filter applies the predicate p to every element in the map and returns a copied map containing only the elements for which the predicate returned true. The original map is not modified.

func (UintStringMap) Find added in v0.3.0

func (mm UintStringMap) Find(p func(uint, string) bool) (UintStringTuple, bool)

Find returns the first string that returns true for the predicate p. False is returned if none match. The original map is not modified.

func (UintStringMap) FlatMap added in v0.3.0

func (mm UintStringMap) FlatMap(f func(uint, string) []UintStringTuple) UintStringMap

FlatMap returns a new StringMap by transforming every element with the function f that returns zero or more items in a slice. The resulting map may have a different size to the original map. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (UintStringMap) Forall added in v0.3.0

func (mm UintStringMap) Forall(p func(uint, string) bool) bool

Forall applies the predicate p to every element in the map. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (UintStringMap) Foreach added in v0.3.0

func (mm UintStringMap) Foreach(f func(uint, string))

Foreach applies the function f to every element in the map. The function can safely alter the values via side-effects.

func (UintStringMap) Get added in v0.3.0

func (mm UintStringMap) Get(k uint) (string, bool)

Get returns one of the items in the map, if present.

func (UintStringMap) IsEmpty added in v0.3.0

func (mm UintStringMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (UintStringMap) Keys added in v0.3.0

func (mm UintStringMap) Keys() UintList

Keys returns the keys of the current map as a slice.

func (UintStringMap) Map added in v0.3.0

func (mm UintStringMap) Map(f func(uint, string) (uint, string)) UintStringMap

Map returns a new StringMap by transforming every element with the function f. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (UintStringMap) MkString added in v0.3.0

func (mm UintStringMap) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (UintStringMap) MkString4 added in v0.7.0

func (mm UintStringMap) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (UintStringMap) NonEmpty added in v0.3.0

func (mm UintStringMap) NonEmpty() bool

NonEmpty returns true if the map is not empty.

func (UintStringMap) OrderedSlice added in v0.6.0

func (mm UintStringMap) OrderedSlice(keys UintList) UintStringTuples

OrderedSlice returns the key/value pairs as a slice in the order specified by keys.

func (UintStringMap) Partition added in v0.3.0

func (mm UintStringMap) Partition(p func(uint, string) bool) (matching UintStringMap, others UintStringMap)

Partition applies the predicate p to every element in the map. It divides the map into two copied maps, the first containing all the elements for which the predicate returned true, and the second containing all the others. The original map is not modified.

func (UintStringMap) Pop added in v0.3.0

func (mm UintStringMap) Pop(k uint) (string, bool)

Pop removes a single item from the map, returning the value present prior to removal.

func (UintStringMap) Put added in v0.3.0

func (mm UintStringMap) Put(k uint, v string) bool

Put adds an item to the current map, replacing any prior value.

func (UintStringMap) Remove added in v0.3.0

func (mm UintStringMap) Remove(k uint)

Remove a single item from the map.

func (UintStringMap) Size added in v0.3.0

func (mm UintStringMap) Size() int

Size returns how many items are currently in the map. This is a synonym for Len.

func (UintStringMap) String added in v0.3.0

func (mm UintStringMap) String() string

String implements the Stringer interface to render the set as a comma-separated string enclosed in square brackets.

func (UintStringMap) ToSlice added in v0.3.0

func (mm UintStringMap) ToSlice() UintStringTuples

ToSlice returns the key/value pairs as a slice.

func (UintStringMap) Values added in v0.3.0

func (mm UintStringMap) Values() StringList

Values returns the values of the current map as a slice.

type UintStringTuple added in v0.3.0

type UintStringTuple struct {
	Key uint
	Val string
}

UintStringTuple represents a key/value pair.

func (UintStringTuple) MarshalJSON added in v0.6.0

func (t UintStringTuple) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding.Marshaler interface.

func (UintStringTuple) UnmarshalJSON added in v0.6.0

func (t UintStringTuple) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this tuple type.

type UintStringTuples added in v0.3.0

type UintStringTuples []UintStringTuple

UintStringTuples can be used as a builder for unmodifiable maps.

func UintStringZip added in v0.3.0

func UintStringZip(keys ...uint) UintStringTuples

UintStringZip is used with the Values method to zip (i.e. interleave) a slice of keys with a slice of values. These can then be passed in to the NewUintStringMap constructor function.

func (UintStringTuples) Append1 added in v0.3.0

func (ts UintStringTuples) Append1(k uint, v string) UintStringTuples

Append1 adds one item.

func (UintStringTuples) Append2 added in v0.3.0

func (ts UintStringTuples) Append2(k1 uint, v1 string, k2 uint, v2 string) UintStringTuples

Append2 adds two items.

func (UintStringTuples) Append3 added in v0.3.0

func (ts UintStringTuples) Append3(k1 uint, v1 string, k2 uint, v2 string, k3 uint, v3 string) UintStringTuples

Append3 adds three items.

func (UintStringTuples) MkString added in v0.6.0

func (ts UintStringTuples) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (UintStringTuples) MkString4 added in v0.7.0

func (ts UintStringTuples) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (UintStringTuples) String added in v0.6.0

func (ts UintStringTuples) String() string

func (UintStringTuples) ToMap added in v0.6.0

func (ts UintStringTuples) ToMap() UintStringMap

ToMap converts the tuples to a map.

func (UintStringTuples) Values added in v0.3.0

func (ts UintStringTuples) Values(values ...string) UintStringTuples

Values sets the values in a tuple slice. Use this with UintStringZip.

type UintUintMap added in v0.3.0

type UintUintMap map[uint]uint

UintUintMap is the primary type that represents a map

func NewUintUintMap added in v0.3.0

func NewUintUintMap(kv ...UintUintTuple) UintUintMap

NewUintUintMap creates and returns a reference to a map, optionally containing some items.

func NewUintUintMap1 added in v0.3.0

func NewUintUintMap1(k uint, v uint) UintUintMap

NewUintUintMap1 creates and returns a reference to a map containing one item.

func (*UintUintMap) Clear added in v0.3.0

func (mm *UintUintMap) Clear()

Clear clears the entire map.

func (UintUintMap) Clone added in v0.3.0

func (mm UintUintMap) Clone() UintUintMap

Clone returns a shallow copy of the map. It does not clone the underlying elements.

func (UintUintMap) ContainsAllKeys added in v0.3.0

func (mm UintUintMap) ContainsAllKeys(kk ...uint) bool

ContainsAllKeys determines if the given items are all in the map.

func (UintUintMap) ContainsKey added in v0.3.0

func (mm UintUintMap) ContainsKey(k uint) bool

ContainsKey determines if a given item is already in the map.

func (UintUintMap) DropWhere added in v0.3.0

func (mm UintUintMap) DropWhere(fn func(uint, uint) bool) UintUintTuples

DropWhere applies a predicate function to every element in the map. If the function returns true, the element is dropped from the map. This is similar to Filter except that the map is modified.

func (UintUintMap) Equals added in v0.3.0

func (mm UintUintMap) Equals(other UintUintMap) bool

Equals determines if two maps are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for maps to be equal.

func (UintUintMap) Exists added in v0.3.0

func (mm UintUintMap) Exists(p func(uint, uint) bool) bool

Exists applies the predicate p to every element in the map. If the function returns true, the iteration terminates early. The returned value is true if an early return occurred. or false if all elements were visited without finding a match.

func (UintUintMap) Filter added in v0.3.0

func (mm UintUintMap) Filter(p func(uint, uint) bool) UintUintMap

Filter applies the predicate p to every element in the map and returns a copied map containing only the elements for which the predicate returned true. The original map is not modified.

func (UintUintMap) Find added in v0.3.0

func (mm UintUintMap) Find(p func(uint, uint) bool) (UintUintTuple, bool)

Find returns the first uint that returns true for the predicate p. False is returned if none match. The original map is not modified.

func (UintUintMap) FlatMap added in v0.3.0

func (mm UintUintMap) FlatMap(f func(uint, uint) []UintUintTuple) UintUintMap

FlatMap returns a new UintMap by transforming every element with the function f that returns zero or more items in a slice. The resulting map may have a different size to the original map. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (UintUintMap) Forall added in v0.3.0

func (mm UintUintMap) Forall(p func(uint, uint) bool) bool

Forall applies the predicate p to every element in the map. If the function returns false, the iteration terminates early. The returned value is true if all elements were visited, or false if an early return occurred.

Note that this method can also be used simply as a way to visit every element using a function with some side-effects; such a function must always return true.

func (UintUintMap) Foreach added in v0.3.0

func (mm UintUintMap) Foreach(f func(uint, uint))

Foreach applies the function f to every element in the map. The function can safely alter the values via side-effects.

func (UintUintMap) Get added in v0.3.0

func (mm UintUintMap) Get(k uint) (uint, bool)

Get returns one of the items in the map, if present.

func (UintUintMap) IsEmpty added in v0.3.0

func (mm UintUintMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (UintUintMap) Keys added in v0.3.0

func (mm UintUintMap) Keys() UintList

Keys returns the keys of the current map as a slice.

func (UintUintMap) Map added in v0.3.0

func (mm UintUintMap) Map(f func(uint, uint) (uint, uint)) UintUintMap

Map returns a new UintMap by transforming every element with the function f. The original map is not modified.

This is a domain-to-range mapping function. For bespoke transformations to other types, copy and modify this method appropriately.

func (UintUintMap) MkString added in v0.3.0

func (mm UintUintMap) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (UintUintMap) MkString4 added in v0.7.0

func (mm UintUintMap) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (UintUintMap) NonEmpty added in v0.3.0

func (mm UintUintMap) NonEmpty() bool

NonEmpty returns true if the map is not empty.

func (UintUintMap) OrderedSlice added in v0.6.0

func (mm UintUintMap) OrderedSlice(keys UintList) UintUintTuples

OrderedSlice returns the key/value pairs as a slice in the order specified by keys.

func (UintUintMap) Partition added in v0.3.0

func (mm UintUintMap) Partition(p func(uint, uint) bool) (matching UintUintMap, others UintUintMap)

Partition applies the predicate p to every element in the map. It divides the map into two copied maps, the first containing all the elements for which the predicate returned true, and the second containing all the others. The original map is not modified.

func (UintUintMap) Pop added in v0.3.0

func (mm UintUintMap) Pop(k uint) (uint, bool)

Pop removes a single item from the map, returning the value present prior to removal.

func (UintUintMap) Put added in v0.3.0

func (mm UintUintMap) Put(k uint, v uint) bool

Put adds an item to the current map, replacing any prior value.

func (UintUintMap) Remove added in v0.3.0

func (mm UintUintMap) Remove(k uint)

Remove a single item from the map.

func (UintUintMap) Size added in v0.3.0

func (mm UintUintMap) Size() int

Size returns how many items are currently in the map. This is a synonym for Len.

func (UintUintMap) String added in v0.3.0

func (mm UintUintMap) String() string

String implements the Stringer interface to render the set as a comma-separated string enclosed in square brackets.

func (UintUintMap) ToSlice added in v0.3.0

func (mm UintUintMap) ToSlice() UintUintTuples

ToSlice returns the key/value pairs as a slice.

func (UintUintMap) Values added in v0.3.0

func (mm UintUintMap) Values() UintList

Values returns the values of the current map as a slice.

type UintUintTuple added in v0.3.0

type UintUintTuple struct {
	Key uint
	Val uint
}

UintUintTuple represents a key/value pair.

func (UintUintTuple) MarshalJSON added in v0.6.0

func (t UintUintTuple) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding.Marshaler interface.

func (UintUintTuple) UnmarshalJSON added in v0.6.0

func (t UintUintTuple) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this tuple type.

type UintUintTuples added in v0.3.0

type UintUintTuples []UintUintTuple

UintUintTuples can be used as a builder for unmodifiable maps.

func UintUintZip added in v0.3.0

func UintUintZip(keys ...uint) UintUintTuples

UintUintZip is used with the Values method to zip (i.e. interleave) a slice of keys with a slice of values. These can then be passed in to the NewUintUintMap constructor function.

func (UintUintTuples) Append1 added in v0.3.0

func (ts UintUintTuples) Append1(k uint, v uint) UintUintTuples

Append1 adds one item.

func (UintUintTuples) Append2 added in v0.3.0

func (ts UintUintTuples) Append2(k1 uint, v1 uint, k2 uint, v2 uint) UintUintTuples

Append2 adds two items.

func (UintUintTuples) Append3 added in v0.3.0

func (ts UintUintTuples) Append3(k1 uint, v1 uint, k2 uint, v2 uint, k3 uint, v3 uint) UintUintTuples

Append3 adds three items.

func (UintUintTuples) MkString added in v0.6.0

func (ts UintUintTuples) MkString(sep string) string

MkString concatenates the map key/values as a string using a supplied separator. No enclosing marks are added.

func (UintUintTuples) MkString4 added in v0.7.0

func (ts UintUintTuples) MkString4(before, between, after, equals string) string

MkString4 concatenates the map key/values as a string, using the prefix, separator and suffix supplied.

func (UintUintTuples) String added in v0.6.0

func (ts UintUintTuples) String() string

func (UintUintTuples) ToMap added in v0.6.0

func (ts UintUintTuples) ToMap() UintUintMap

ToMap converts the tuples to a map.

func (UintUintTuples) Values added in v0.3.0

func (ts UintUintTuples) Values(values ...uint) UintUintTuples

Values sets the values in a tuple slice. Use this with UintUintZip.

Directories

Path Synopsis
package immutable provides immutable collection types for core Go built-in types.
package immutable provides immutable collection types for core Go built-in types.
package shared provides shareable collection types for core Go built-in types.
package shared provides shareable collection types for core Go built-in types.

Jump to

Keyboard shortcuts

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