shared

package
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: 10 Imported by: 0

Documentation

Overview

package shared provides shareable collection types for core Go built-in types. These are safe for sharing across multiple goroutines because they lock access using mutexes. However, take care because any sequence of multiple operations will not be atomic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnyCollection

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

	// Clear the entire collection.
	Clear()

	// Add adds items to the current collection.
	Add(more ...interface{})

	// 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

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

AnyList contains a slice of type interface{}. It encapsulates the slice and provides methods to access or mutate it.

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

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

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

func MakeAnyList(length, capacity int) *AnyList

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

func NewAnyList

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

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

func (*AnyList) Add

func (list *AnyList) Add(more ...interface{})

Add adds items to the current list. This is a synonym for Append.

func (*AnyList) Append

func (list *AnyList) Append(more ...interface{}) *AnyList

Append adds items to the current list. If the list is nil, a new list is allocated and returned. Otherwise the modified list is returned.

func (*AnyList) Clear

func (list *AnyList) Clear()

Clear the entire collection.

func (*AnyList) Clone

func (list *AnyList) Clone() *AnyList

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

func (*AnyList) Contains

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

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

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

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

func (list *AnyList) DoDeleteAt(index, n int) *AnyList

DoDeleteAt modifies a AnyList by deleting n elements from a given index.

The list is modified and the modified list is returned. Panics if the index is out of range or n is large enough to take the index out of range.

func (*AnyList) DoDeleteFirst

func (list *AnyList) DoDeleteFirst(n int) *AnyList

DoDeleteFirst modifies a AnyList by deleting n elements from the start of the list.

If the list is nil, a new list is allocated and returned. Otherwise the modified list is returned. Panics if n is large enough to take the index out of range.

func (*AnyList) DoDeleteLast

func (list *AnyList) DoDeleteLast(n int) *AnyList

DoDeleteLast modifies a AnyList by deleting n elements from the end of the list.

The list is modified and the modified list is returned. Panics if n is large enough to take the index out of range.

func (*AnyList) DoInsertAt

func (list *AnyList) DoInsertAt(index int, more ...interface{}) *AnyList

DoInsertAt modifies a AnyList by inserting elements at a given index. This is a generalised version of Append.

If the list is nil, a new list is allocated and returned. Otherwise the modified list is returned. Panics if the index is out of range.

func (*AnyList) DoKeepWhere

func (list *AnyList) DoKeepWhere(p func(interface{}) bool) *AnyList

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

The list is modified and the modified list is returned.

func (*AnyList) DoReverse

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

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

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

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

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

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. Nil lists are considered to be empty.

func (*AnyList) Exists

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

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. See also DoKeepWhere (which does modify the original list).

func (*AnyList) Find

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

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

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

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

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

func (*AnyList) Get

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.

func (*AnyList) GobDecode

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

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

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

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

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

func (*AnyList) IndexWhere

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

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

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

func (list *AnyList) IsEmpty() bool

IsEmpty tests whether AnyList is empty.

func (*AnyList) IsSequence

func (list *AnyList) IsSequence() bool

IsSequence returns true for lists and queues.

func (*AnyList) IsSet

func (list *AnyList) IsSet() bool

IsSet returns false for lists or queues.

func (*AnyList) Last

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

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

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

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

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

func (*AnyList) Len

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

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

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

MarshalJSON implements JSON encoding for this list type.

func (*AnyList) MaxBy

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

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

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

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

func (list *AnyList) NonEmpty() bool

NonEmpty tests whether AnyList is empty.

func (*AnyList) Partition

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

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

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

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

func (list *AnyList) Size() int

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

func (*AnyList) SortBy

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

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

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

func (list *AnyList) StringList() []string

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

func (*AnyList) Swap

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

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

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

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

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

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

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

func (*AnyList) ToList

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

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

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

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

func (*AnyList) UnmarshalJSON

func (list *AnyList) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this list type.

type AnyMkStringer

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

	// implements json.Marshaler interface {
	MarshalJSON() ([]byte, error)

	// implements json.Unmarshaler interface {
	UnmarshalJSON(b []byte) error

	// 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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *AnyQueue) Cap() int

Cap gets the capacity of this queue.

func (*AnyQueue) Clear added in v0.8.0

func (queue *AnyQueue) Clear()

Clear the entire queue.

func (*AnyQueue) Clone added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *AnyQueue) IsEmpty() bool

IsEmpty returns true if the queue is empty.

func (*AnyQueue) IsFull added in v0.8.0

func (queue *AnyQueue) IsFull() bool

IsFull returns true if the queue is full.

func (*AnyQueue) IsOverwriting added in v0.8.0

func (queue *AnyQueue) IsOverwriting() bool

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

func (*AnyQueue) IsSequence added in v0.8.0

func (queue *AnyQueue) IsSequence() bool

IsSequence returns true for ordered lists and queues.

func (*AnyQueue) IsSet added in v0.8.0

func (queue *AnyQueue) IsSet() bool

IsSet returns false for lists or queues.

func (*AnyQueue) Last added in v0.8.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.8.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.8.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.8.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.8.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.8.0

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

MarshalJSON implements JSON encoding for this queue type.

func (*AnyQueue) MaxBy added in v0.8.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.8.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.8.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.8.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.8.0

func (queue *AnyQueue) NonEmpty() bool

NonEmpty returns true if the queue is not empty.

func (*AnyQueue) Offer added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *AnyQueue) Space() int

Space returns the space available in the queue.

func (*AnyQueue) StableSort added in v0.8.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.8.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.8.0

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

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

func (*AnyQueue) Swap added in v0.8.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.8.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) ToList added in v0.9.0

func (queue *AnyQueue) ToList() *AnyList

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

func (*AnyQueue) ToSet added in v0.8.0

func (queue *AnyQueue) ToSet() *AnySet

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

func (*AnyQueue) ToSlice added in v0.8.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.8.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

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

AnySet is the primary type that represents a set.

func BuildAnySetFromChan

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

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

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

NewAnySet creates and returns a reference to an empty set.

func (*AnySet) Add

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

Add adds items to the current set.

func (*AnySet) Cardinality

func (set *AnySet) Cardinality() int

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

func (*AnySet) Clear

func (set *AnySet) Clear()

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

func (*AnySet) Clone

func (set *AnySet) Clone() *AnySet

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

func (*AnySet) Contains

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

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

ContainsAll determines whether the given items are all in the set, returning true if so.

func (*AnySet) CountBy

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

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

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

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

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

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

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

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

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

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

func (*AnySet) GobDecode

func (set *AnySet) GobDecode(b []byte) error

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

func (AnySet) GobEncode

func (set AnySet) 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 (*AnySet) Intersect

func (set *AnySet) Intersect(other *AnySet) *AnySet

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

func (*AnySet) IsEmpty

func (set *AnySet) IsEmpty() bool

IsEmpty returns true if the set is empty.

func (*AnySet) IsSequence

func (set *AnySet) IsSequence() bool

IsSequence returns true for lists and queues.

func (*AnySet) IsSet

func (set *AnySet) IsSet() bool

IsSet returns false for lists or queues.

func (*AnySet) IsSubset

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

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

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

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

MarshalJSON implements JSON encoding for this set type.

func (*AnySet) MaxBy

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

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

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

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

func (set *AnySet) NonEmpty() bool

NonEmpty returns true if the set is not empty.

func (*AnySet) Partition

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 relative order of the elements in the results is the same as in the original list.

The original set is not modified

func (*AnySet) Remove

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

Remove a single item from the set.

func (*AnySet) Send

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

func (set *AnySet) Size() int

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

func (*AnySet) String

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

func (set *AnySet) StringList() []string

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

func (*AnySet) StringMap

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

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

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

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

func (*AnySet) ToList

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

func (set *AnySet) ToSet() *AnySet

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

func (*AnySet) ToSlice

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

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

func (*AnySet) Union

func (set *AnySet) Union(other *AnySet) *AnySet

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

func (*AnySet) UnmarshalJSON

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

UnmarshalJSON implements JSON decoding for this set type.

type AnySizer

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)

	// MapToString returns a new []string by transforming every element with function f.
	// The resulting slice is the same size as the collection. The collection is not modified.
	MapToString(f func(int64) string) []string

	// FlatMapString 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
	// collection. The collection is not modified.
	FlatMapToString(f func(int64) []string) []string

	// 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

	// Clear the entire collection.
	Clear()

	// Add adds items to the current collection.
	Add(more ...int64)

	// 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 struct {
	// contains filtered or unexported fields
}

Int64Int64Map is the primary type that represents a thread-safe 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) GobDecode

func (mm *Int64Int64Map) GobDecode(b []byte) error

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

func (*Int64Int64Map) GobEncode

func (mm *Int64Int64Map) GobEncode() ([]byte, error)

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

func (*Int64Int64Map) IsEmpty

func (mm *Int64Int64Map) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (*Int64Int64Map) Keys

func (mm *Int64Int64Map) Keys() collection.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

func (mm *Int64Int64Map) OrderedSlice(keys collection.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. The boolean result is true only if the key had been present.

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() collection.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

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

MarshalJSON implements encoding.Marshaler interface.

func (Int64Int64Tuple) UnmarshalJSON

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

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

func (ts Int64Int64Tuples) String() string

func (Int64Int64Tuples) ToMap

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 struct {
	// contains filtered or unexported fields
}

Int64List contains a slice of type int64. It encapsulates the slice and provides methods to access or mutate it.

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

func (list *Int64List) Add(more ...int64)

Add adds items to the current list. This is a synonym for Append.

func (*Int64List) Append

func (list *Int64List) Append(more ...int64) *Int64List

Append adds items to the current list. If the list is nil, a new list is allocated and returned. Otherwise the modified list is returned.

func (*Int64List) Clear

func (list *Int64List) Clear()

Clear the entire collection.

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

func (list *Int64List) DoDeleteAt(index, n int) *Int64List

DoDeleteAt modifies a Int64List by deleting n elements from a given index.

The list is modified and the modified list is returned. Panics if the index is out of range or n is large enough to take the index out of range.

func (*Int64List) DoDeleteFirst

func (list *Int64List) DoDeleteFirst(n int) *Int64List

DoDeleteFirst modifies a Int64List by deleting n elements from the start of the list.

If the list is nil, a new list is allocated and returned. Otherwise the modified list is returned. Panics if n is large enough to take the index out of range.

func (*Int64List) DoDeleteLast

func (list *Int64List) DoDeleteLast(n int) *Int64List

DoDeleteLast modifies a Int64List by deleting n elements from the end of the list.

The list is modified and the modified list is returned. Panics if n is large enough to take the index out of range.

func (*Int64List) DoInsertAt

func (list *Int64List) DoInsertAt(index int, more ...int64) *Int64List

DoInsertAt modifies a Int64List by inserting elements at a given index. This is a generalised version of Append.

If the list is nil, a new list is allocated and returned. Otherwise the modified list is returned. Panics if the index is out of range.

func (*Int64List) DoKeepWhere

func (list *Int64List) DoKeepWhere(p func(int64) bool) *Int64List

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

The list is modified and the modified list is returned.

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. Nil lists are considered to be empty.

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. See also DoKeepWhere (which does modify the original list).

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

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. The function can safely alter the values via side-effects.

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.

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

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

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

MarshalJSON implements JSON encoding for this list type.

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 current list as a slice.

func (*Int64List) UnmarshalJSON

func (list *Int64List) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this list type.

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

	// implements json.Marshaler interface {
	MarshalJSON() ([]byte, error)

	// implements json.Unmarshaler interface {
	UnmarshalJSON(b []byte) error

	// 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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *Int64Queue) Cap() int

Cap gets the capacity of this queue.

func (*Int64Queue) Clear added in v0.8.0

func (queue *Int64Queue) Clear()

Clear the entire queue.

func (*Int64Queue) Clone added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *Int64Queue) IsEmpty() bool

IsEmpty returns true if the queue is empty.

func (*Int64Queue) IsFull added in v0.8.0

func (queue *Int64Queue) IsFull() bool

IsFull returns true if the queue is full.

func (*Int64Queue) IsOverwriting added in v0.8.0

func (queue *Int64Queue) IsOverwriting() bool

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

func (*Int64Queue) IsSequence added in v0.8.0

func (queue *Int64Queue) IsSequence() bool

IsSequence returns true for ordered lists and queues.

func (*Int64Queue) IsSet added in v0.8.0

func (queue *Int64Queue) IsSet() bool

IsSet returns false for lists or queues.

func (*Int64Queue) Last added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.0

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

MarshalJSON implements JSON encoding for this queue type.

func (*Int64Queue) Max added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *Int64Queue) NonEmpty() bool

NonEmpty returns true if the queue is not empty.

func (*Int64Queue) Offer added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *Int64Queue) Space() int

Space returns the space available in the queue.

func (*Int64Queue) StableSort added in v0.8.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.8.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.8.0

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

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

func (*Int64Queue) Sum added in v0.8.0

func (queue *Int64Queue) Sum() int64

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

func (*Int64Queue) Swap added in v0.8.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.8.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) ToList added in v0.9.0

func (queue *Int64Queue) ToList() *Int64List

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

func (*Int64Queue) ToSet added in v0.8.0

func (queue *Int64Queue) ToSet() *Int64Set

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

func (*Int64Queue) ToSlice added in v0.8.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.8.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 struct {
	// contains filtered or unexported fields
}

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)

Add adds items to the current set.

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 the given items are all 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. The function can safely alter the values via side-effects.

func (*Int64Set) GobDecode

func (set *Int64Set) GobDecode(b []byte) error

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

func (Int64Set) GobEncode

func (set Int64Set) 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 (*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() (result 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 relative order of the elements in the results is the same as in the original list.

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

StringSet 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

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

Int64StringMap is the primary type that represents a thread-safe map

func NewInt64StringMap

func NewInt64StringMap(kv ...Int64StringTuple) *Int64StringMap

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

func NewInt64StringMap1

func NewInt64StringMap1(k int64, v string) *Int64StringMap

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

func (*Int64StringMap) Clear

func (mm *Int64StringMap) Clear()

Clear clears the entire map.

func (*Int64StringMap) Clone

func (mm *Int64StringMap) Clone() *Int64StringMap

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

func (*Int64StringMap) ContainsAllKeys

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

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

func (*Int64StringMap) ContainsKey

func (mm *Int64StringMap) ContainsKey(k int64) bool

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

func (*Int64StringMap) DropWhere

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

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

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

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

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

func (mm *Int64StringMap) FlatMap(f func(int64, string) []Int64StringTuple) *Int64StringMap

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

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

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

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

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

func (*Int64StringMap) GobDecode

func (mm *Int64StringMap) GobDecode(b []byte) error

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

func (*Int64StringMap) GobEncode

func (mm *Int64StringMap) GobEncode() ([]byte, error)

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

func (*Int64StringMap) IsEmpty

func (mm *Int64StringMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (*Int64StringMap) Keys

func (mm *Int64StringMap) Keys() collection.Int64List

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

func (*Int64StringMap) Map

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

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

func (mm *Int64StringMap) NonEmpty() bool

NonEmpty returns true if the map is not empty.

func (*Int64StringMap) OrderedSlice

func (mm *Int64StringMap) OrderedSlice(keys collection.Int64List) Int64StringTuples

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

func (*Int64StringMap) Partition

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

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

Pop removes a single item from the map, returning the value present prior to removal. The boolean result is true only if the key had been present.

func (*Int64StringMap) Put

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

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

func (*Int64StringMap) Remove

func (mm *Int64StringMap) Remove(k int64)

Remove a single item from the map.

func (*Int64StringMap) Size

func (mm *Int64StringMap) Size() int

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

func (*Int64StringMap) String

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

func (mm *Int64StringMap) ToSlice() Int64StringTuples

ToSlice returns the key/value pairs as a slice

func (*Int64StringMap) Values

func (mm *Int64StringMap) Values() collection.StringList

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

type Int64StringTuple

type Int64StringTuple struct {
	Key int64
	Val string
}

Int64StringTuple represents a key/value pair.

func (Int64StringTuple) MarshalJSON

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

MarshalJSON implements encoding.Marshaler interface.

func (Int64StringTuple) UnmarshalJSON

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

UnmarshalJSON implements JSON decoding for this tuple type.

type Int64StringTuples

type Int64StringTuples []Int64StringTuple

Int64StringTuples can be used as a builder for unmodifiable maps.

func Int64StringZip

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

Append1 adds one item.

func (Int64StringTuples) Append2

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

Append2 adds two items.

func (Int64StringTuples) Append3

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

Append3 adds three items.

func (Int64StringTuples) MkString

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

func (ts Int64StringTuples) String() string

func (Int64StringTuples) ToMap

func (ts Int64StringTuples) ToMap() *Int64StringMap

ToMap converts the tuples to a map.

func (Int64StringTuples) Values

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)

	// MapToString returns a new []string by transforming every element with function f.
	// The resulting slice is the same size as the collection. The collection is not modified.
	MapToString(f func(int) string) []string

	// FlatMapString 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
	// collection. The collection is not modified.
	FlatMapToString(f func(int) []string) []string

	// 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

	// Clear the entire collection.
	Clear()

	// Add adds items to the current collection.
	Add(more ...int)

	// 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 struct {
	// contains filtered or unexported fields
}

IntIntMap is the primary type that represents a thread-safe 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) GobDecode

func (mm *IntIntMap) GobDecode(b []byte) error

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

func (*IntIntMap) GobEncode

func (mm *IntIntMap) GobEncode() ([]byte, error)

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

func (*IntIntMap) IsEmpty

func (mm *IntIntMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (*IntIntMap) Keys

func (mm *IntIntMap) Keys() collection.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

func (mm *IntIntMap) OrderedSlice(keys collection.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. The boolean result is true only if the key had been present.

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() collection.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

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

MarshalJSON implements encoding.Marshaler interface.

func (IntIntTuple) UnmarshalJSON

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

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

func (ts IntIntTuples) String() string

func (IntIntTuples) ToMap

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 struct {
	// contains filtered or unexported fields
}

IntList contains a slice of type int. It encapsulates the slice and provides methods to access or mutate it.

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

func (list *IntList) Add(more ...int)

Add adds items to the current list. This is a synonym for Append.

func (*IntList) Append

func (list *IntList) Append(more ...int) *IntList

Append adds items to the current list. If the list is nil, a new list is allocated and returned. Otherwise the modified list is returned.

func (*IntList) Clear

func (list *IntList) Clear()

Clear the entire collection.

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

func (list *IntList) DoDeleteAt(index, n int) *IntList

DoDeleteAt modifies a IntList by deleting n elements from a given index.

The list is modified and the modified list is returned. Panics if the index is out of range or n is large enough to take the index out of range.

func (*IntList) DoDeleteFirst

func (list *IntList) DoDeleteFirst(n int) *IntList

DoDeleteFirst modifies a IntList by deleting n elements from the start of the list.

If the list is nil, a new list is allocated and returned. Otherwise the modified list is returned. Panics if n is large enough to take the index out of range.

func (*IntList) DoDeleteLast

func (list *IntList) DoDeleteLast(n int) *IntList

DoDeleteLast modifies a IntList by deleting n elements from the end of the list.

The list is modified and the modified list is returned. Panics if n is large enough to take the index out of range.

func (*IntList) DoInsertAt

func (list *IntList) DoInsertAt(index int, more ...int) *IntList

DoInsertAt modifies a IntList by inserting elements at a given index. This is a generalised version of Append.

If the list is nil, a new list is allocated and returned. Otherwise the modified list is returned. Panics if the index is out of range.

func (*IntList) DoKeepWhere

func (list *IntList) DoKeepWhere(p func(int) bool) *IntList

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

The list is modified and the modified list is returned.

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. Nil lists are considered to be empty.

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. See also DoKeepWhere (which does modify the original list).

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

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. The function can safely alter the values via side-effects.

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.

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

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

func (list IntList) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this list type.

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 current list as a slice.

func (*IntList) UnmarshalJSON

func (list *IntList) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this list type.

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

	// implements json.Marshaler interface {
	MarshalJSON() ([]byte, error)

	// implements json.Unmarshaler interface {
	UnmarshalJSON(b []byte) error

	// 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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *IntQueue) Cap() int

Cap gets the capacity of this queue.

func (*IntQueue) Clear added in v0.8.0

func (queue *IntQueue) Clear()

Clear the entire queue.

func (*IntQueue) Clone added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *IntQueue) IsEmpty() bool

IsEmpty returns true if the queue is empty.

func (*IntQueue) IsFull added in v0.8.0

func (queue *IntQueue) IsFull() bool

IsFull returns true if the queue is full.

func (*IntQueue) IsOverwriting added in v0.8.0

func (queue *IntQueue) IsOverwriting() bool

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

func (*IntQueue) IsSequence added in v0.8.0

func (queue *IntQueue) IsSequence() bool

IsSequence returns true for ordered lists and queues.

func (*IntQueue) IsSet added in v0.8.0

func (queue *IntQueue) IsSet() bool

IsSet returns false for lists or queues.

func (*IntQueue) Last added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.0

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

MarshalJSON implements JSON encoding for this queue type.

func (*IntQueue) Max added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *IntQueue) NonEmpty() bool

NonEmpty returns true if the queue is not empty.

func (*IntQueue) Offer added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *IntQueue) Space() int

Space returns the space available in the queue.

func (*IntQueue) StableSort added in v0.8.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.8.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.8.0

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

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

func (*IntQueue) Sum added in v0.8.0

func (queue *IntQueue) Sum() int

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

func (*IntQueue) Swap added in v0.8.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.8.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) ToList added in v0.9.0

func (queue *IntQueue) ToList() *IntList

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

func (*IntQueue) ToSet added in v0.8.0

func (queue *IntQueue) ToSet() *IntSet

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

func (*IntQueue) ToSlice added in v0.8.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.8.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 struct {
	// contains filtered or unexported fields
}

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)

Add adds items to the current set.

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 the given items are all 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. The function can safely alter the values via side-effects.

func (*IntSet) GobDecode

func (set *IntSet) GobDecode(b []byte) error

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

func (IntSet) GobEncode

func (set IntSet) 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 (*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() (result 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 relative order of the elements in the results is the same as in the original list.

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

StringSet 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 struct {
	// contains filtered or unexported fields
}

IntStringMap is the primary type that represents a thread-safe 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) GobDecode

func (mm *IntStringMap) GobDecode(b []byte) error

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

func (*IntStringMap) GobEncode

func (mm *IntStringMap) GobEncode() ([]byte, error)

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

func (*IntStringMap) IsEmpty

func (mm *IntStringMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (*IntStringMap) Keys

func (mm *IntStringMap) Keys() collection.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

func (mm *IntStringMap) OrderedSlice(keys collection.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. The boolean result is true only if the key had been present.

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() collection.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

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

MarshalJSON implements encoding.Marshaler interface.

func (IntStringTuple) UnmarshalJSON

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

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

func (ts IntStringTuples) String() string

func (IntStringTuples) ToMap

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

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

StringAnyMap is the primary type that represents a thread-safe map

func NewStringAnyMap

func NewStringAnyMap(kv ...StringAnyTuple) *StringAnyMap

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

func NewStringAnyMap1

func NewStringAnyMap1(k string, v interface{}) *StringAnyMap

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

func (*StringAnyMap) Clear

func (mm *StringAnyMap) Clear()

Clear clears the entire map.

func (*StringAnyMap) Clone

func (mm *StringAnyMap) Clone() *StringAnyMap

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

func (*StringAnyMap) ContainsAllKeys

func (mm *StringAnyMap) ContainsAllKeys(kk ...string) bool

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

func (*StringAnyMap) ContainsKey

func (mm *StringAnyMap) ContainsKey(k string) bool

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

func (*StringAnyMap) DropWhere

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

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

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

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

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

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

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

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

func (mm *StringAnyMap) Get(k string) (interface{}, bool)

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

func (*StringAnyMap) GobDecode

func (mm *StringAnyMap) GobDecode(b []byte) error

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

func (*StringAnyMap) GobEncode

func (mm *StringAnyMap) GobEncode() ([]byte, error)

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

func (*StringAnyMap) IsEmpty

func (mm *StringAnyMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (*StringAnyMap) Keys

func (mm *StringAnyMap) Keys() collection.StringList

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

func (*StringAnyMap) Map

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

func (mm *StringAnyMap) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this map type.

func (*StringAnyMap) MkString

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

func (mm *StringAnyMap) NonEmpty() bool

NonEmpty returns true if the map is not empty.

func (*StringAnyMap) OrderedSlice

func (mm *StringAnyMap) OrderedSlice(keys collection.StringList) StringAnyTuples

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

func (*StringAnyMap) Partition

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

func (mm *StringAnyMap) Pop(k string) (interface{}, bool)

Pop removes a single item from the map, returning the value present prior to removal. The boolean result is true only if the key had been present.

func (*StringAnyMap) Put

func (mm *StringAnyMap) Put(k string, v interface{}) bool

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

func (*StringAnyMap) Remove

func (mm *StringAnyMap) Remove(k string)

Remove a single item from the map.

func (*StringAnyMap) Size

func (mm *StringAnyMap) Size() int

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

func (*StringAnyMap) String

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

func (mm *StringAnyMap) ToSlice() StringAnyTuples

ToSlice returns the key/value pairs as a slice

func (*StringAnyMap) UnmarshalJSON

func (mm *StringAnyMap) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this map type.

func (*StringAnyMap) Values

func (mm *StringAnyMap) Values() collection.AnyList

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

type StringAnyTuple

type StringAnyTuple struct {
	Key string
	Val interface{}
}

StringAnyTuple represents a key/value pair.

func (StringAnyTuple) MarshalJSON

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

MarshalJSON implements encoding.Marshaler interface.

func (StringAnyTuple) UnmarshalJSON

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

UnmarshalJSON implements JSON decoding for this tuple type.

type StringAnyTuples

type StringAnyTuples []StringAnyTuple

StringAnyTuples can be used as a builder for unmodifiable maps.

func StringAnyZip

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

func (ts StringAnyTuples) Append1(k string, v interface{}) StringAnyTuples

Append1 adds one item.

func (StringAnyTuples) Append2

func (ts StringAnyTuples) Append2(k1 string, v1 interface{}, k2 string, v2 interface{}) StringAnyTuples

Append2 adds two items.

func (StringAnyTuples) Append3

func (ts StringAnyTuples) Append3(k1 string, v1 interface{}, k2 string, v2 interface{}, k3 string, v3 interface{}) StringAnyTuples

Append3 adds three items.

func (StringAnyTuples) MkString

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

func (ts StringAnyTuples) String() string

func (StringAnyTuples) ToMap

func (ts StringAnyTuples) ToMap() *StringAnyMap

ToMap converts the tuples to a map.

func (StringAnyTuples) Values

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)

	// MapToInt returns a new []int by transforming every element with function f.
	// The resulting slice is the same size as the collection. The collection is not modified.
	MapToInt(f func(string) int) []int

	// FlatMapInt 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
	// collection. The collection is not modified.
	FlatMapToInt(f func(string) []int) []int

	// 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

	// Clear the entire collection.
	Clear()

	// Add adds items to the current collection.
	Add(more ...string)

	// 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 struct {
	// contains filtered or unexported fields
}

StringIntMap is the primary type that represents a thread-safe 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) GobDecode

func (mm *StringIntMap) GobDecode(b []byte) error

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

func (*StringIntMap) GobEncode

func (mm *StringIntMap) GobEncode() ([]byte, error)

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

func (*StringIntMap) IsEmpty

func (mm *StringIntMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (*StringIntMap) Keys

func (mm *StringIntMap) Keys() collection.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) MarshalJSON

func (mm *StringIntMap) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this map type.

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

func (mm *StringIntMap) OrderedSlice(keys collection.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. The boolean result is true only if the key had been present.

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

func (mm *StringIntMap) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this map type.

func (*StringIntMap) Values

func (mm *StringIntMap) Values() collection.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

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

MarshalJSON implements encoding.Marshaler interface.

func (StringIntTuple) UnmarshalJSON

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

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

func (ts StringIntTuples) String() string

func (StringIntTuples) ToMap

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 struct {
	// contains filtered or unexported fields
}

StringList contains a slice of type string. It encapsulates the slice and provides methods to access or mutate it.

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

func (list *StringList) Add(more ...string)

Add adds items to the current list. This is a synonym for Append.

func (*StringList) Append

func (list *StringList) Append(more ...string) *StringList

Append adds items to the current list. If the list is nil, a new list is allocated and returned. Otherwise the modified list is returned.

func (*StringList) Clear

func (list *StringList) Clear()

Clear the entire collection.

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

func (list *StringList) DoDeleteAt(index, n int) *StringList

DoDeleteAt modifies a StringList by deleting n elements from a given index.

The list is modified and the modified list is returned. Panics if the index is out of range or n is large enough to take the index out of range.

func (*StringList) DoDeleteFirst

func (list *StringList) DoDeleteFirst(n int) *StringList

DoDeleteFirst modifies a StringList by deleting n elements from the start of the list.

If the list is nil, a new list is allocated and returned. Otherwise the modified list is returned. Panics if n is large enough to take the index out of range.

func (*StringList) DoDeleteLast

func (list *StringList) DoDeleteLast(n int) *StringList

DoDeleteLast modifies a StringList by deleting n elements from the end of the list.

The list is modified and the modified list is returned. Panics if n is large enough to take the index out of range.

func (*StringList) DoInsertAt

func (list *StringList) DoInsertAt(index int, more ...string) *StringList

DoInsertAt modifies a StringList by inserting elements at a given index. This is a generalised version of Append.

If the list is nil, a new list is allocated and returned. Otherwise the modified list is returned. Panics if the index is out of range.

func (*StringList) DoKeepWhere

func (list *StringList) DoKeepWhere(p func(string) bool) *StringList

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

The list is modified and the modified list is returned.

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. Nil lists are considered to be empty.

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. See also DoKeepWhere (which does modify the original list).

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

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. The function can safely alter the values via side-effects.

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.

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

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

func (list StringList) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this list type.

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

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 current list as a slice.

func (*StringList) UnmarshalJSON

func (list *StringList) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this list type.

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

	// implements json.Marshaler interface {
	MarshalJSON() ([]byte, error)

	// implements json.Unmarshaler interface {
	UnmarshalJSON(b []byte) error

	// 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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *StringQueue) Cap() int

Cap gets the capacity of this queue.

func (*StringQueue) Clear added in v0.8.0

func (queue *StringQueue) Clear()

Clear the entire queue.

func (*StringQueue) Clone added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *StringQueue) IsEmpty() bool

IsEmpty returns true if the queue is empty.

func (*StringQueue) IsFull added in v0.8.0

func (queue *StringQueue) IsFull() bool

IsFull returns true if the queue is full.

func (*StringQueue) IsOverwriting added in v0.8.0

func (queue *StringQueue) IsOverwriting() bool

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

func (*StringQueue) IsSequence added in v0.8.0

func (queue *StringQueue) IsSequence() bool

IsSequence returns true for ordered lists and queues.

func (*StringQueue) IsSet added in v0.8.0

func (queue *StringQueue) IsSet() bool

IsSet returns false for lists or queues.

func (*StringQueue) Last added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.0

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

MarshalJSON implements JSON encoding for this queue type.

func (*StringQueue) MaxBy added in v0.8.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.8.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.8.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.8.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.8.0

func (queue *StringQueue) NonEmpty() bool

NonEmpty returns true if the queue is not empty.

func (*StringQueue) Offer added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *StringQueue) Space() int

Space returns the space available in the queue.

func (*StringQueue) StableSort added in v0.8.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.8.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.8.0

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

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

func (*StringQueue) Swap added in v0.8.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.8.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) ToList added in v0.9.0

func (queue *StringQueue) ToList() *StringList

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

func (*StringQueue) ToSet added in v0.8.0

func (queue *StringQueue) ToSet() *StringSet

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

func (*StringQueue) ToSlice added in v0.8.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.8.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 struct {
	// contains filtered or unexported fields
}

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)

Add adds items to the current set.

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 the given items are all 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. The function can safely alter the values via side-effects.

func (*StringSet) GobDecode

func (set *StringSet) GobDecode(b []byte) error

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

func (StringSet) GobEncode

func (set StringSet) 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 (*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 relative order of the elements in the results is the same as in the original list.

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

StringSet 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 struct {
	// contains filtered or unexported fields
}

StringStringMap is the primary type that represents a thread-safe 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) GobDecode

func (mm *StringStringMap) GobDecode(b []byte) error

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

func (*StringStringMap) GobEncode

func (mm *StringStringMap) GobEncode() ([]byte, error)

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

func (*StringStringMap) IsEmpty

func (mm *StringStringMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (*StringStringMap) Keys

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

func (*StringStringMap) Map

func (mm *StringStringMap) Map(f func(string, string) (string, string)) *StringStringMap

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

func (mm *StringStringMap) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this map type.

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

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. The boolean result is true only if the key had been present.

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

func (mm *StringStringMap) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this map type.

func (*StringStringMap) Values

func (mm *StringStringMap) Values() collection.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

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

MarshalJSON implements encoding.Marshaler interface.

func (StringStringTuple) UnmarshalJSON

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

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

func (ts StringStringTuples) String() string

func (StringStringTuples) ToMap

func (ts StringStringTuples) ToMap() *StringStringMap

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

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

StringUintMap is the primary type that represents a thread-safe map

func NewStringUintMap

func NewStringUintMap(kv ...StringUintTuple) *StringUintMap

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

func NewStringUintMap1

func NewStringUintMap1(k string, v uint) *StringUintMap

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

func (*StringUintMap) Clear

func (mm *StringUintMap) Clear()

Clear clears the entire map.

func (*StringUintMap) Clone

func (mm *StringUintMap) Clone() *StringUintMap

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

func (*StringUintMap) ContainsAllKeys

func (mm *StringUintMap) ContainsAllKeys(kk ...string) bool

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

func (*StringUintMap) ContainsKey

func (mm *StringUintMap) ContainsKey(k string) bool

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

func (*StringUintMap) DropWhere

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

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

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

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

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

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

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

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

func (mm *StringUintMap) Get(k string) (uint, bool)

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

func (*StringUintMap) GobDecode

func (mm *StringUintMap) GobDecode(b []byte) error

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

func (*StringUintMap) GobEncode

func (mm *StringUintMap) GobEncode() ([]byte, error)

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

func (*StringUintMap) IsEmpty

func (mm *StringUintMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (*StringUintMap) Keys

func (mm *StringUintMap) Keys() collection.StringList

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

func (*StringUintMap) Map

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

func (mm *StringUintMap) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this map type.

func (*StringUintMap) MkString

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

func (mm *StringUintMap) NonEmpty() bool

NonEmpty returns true if the map is not empty.

func (*StringUintMap) OrderedSlice

func (mm *StringUintMap) OrderedSlice(keys collection.StringList) StringUintTuples

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

func (*StringUintMap) Partition

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

func (mm *StringUintMap) Pop(k string) (uint, bool)

Pop removes a single item from the map, returning the value present prior to removal. The boolean result is true only if the key had been present.

func (*StringUintMap) Put

func (mm *StringUintMap) Put(k string, v uint) bool

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

func (*StringUintMap) Remove

func (mm *StringUintMap) Remove(k string)

Remove a single item from the map.

func (*StringUintMap) Size

func (mm *StringUintMap) Size() int

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

func (*StringUintMap) String

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

func (mm *StringUintMap) ToSlice() StringUintTuples

ToSlice returns the key/value pairs as a slice

func (*StringUintMap) UnmarshalJSON

func (mm *StringUintMap) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this map type.

func (*StringUintMap) Values

func (mm *StringUintMap) Values() collection.UintList

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

type StringUintTuple

type StringUintTuple struct {
	Key string
	Val uint
}

StringUintTuple represents a key/value pair.

func (StringUintTuple) MarshalJSON

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

MarshalJSON implements encoding.Marshaler interface.

func (StringUintTuple) UnmarshalJSON

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

UnmarshalJSON implements JSON decoding for this tuple type.

type StringUintTuples

type StringUintTuples []StringUintTuple

StringUintTuples can be used as a builder for unmodifiable maps.

func StringUintZip

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

func (ts StringUintTuples) Append1(k string, v uint) StringUintTuples

Append1 adds one item.

func (StringUintTuples) Append2

func (ts StringUintTuples) Append2(k1 string, v1 uint, k2 string, v2 uint) StringUintTuples

Append2 adds two items.

func (StringUintTuples) Append3

func (ts StringUintTuples) Append3(k1 string, v1 uint, k2 string, v2 uint, k3 string, v3 uint) StringUintTuples

Append3 adds three items.

func (StringUintTuples) MkString

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

func (ts StringUintTuples) String() string

func (StringUintTuples) ToMap

func (ts StringUintTuples) ToMap() *StringUintMap

ToMap converts the tuples to a map.

func (StringUintTuples) Values

func (ts StringUintTuples) Values(values ...uint) StringUintTuples

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

type Uint64Collection

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)

	// MapToString returns a new []string by transforming every element with function f.
	// The resulting slice is the same size as the collection. The collection is not modified.
	MapToString(f func(uint64) string) []string

	// FlatMapString 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
	// collection. The collection is not modified.
	FlatMapToString(f func(uint64) []string) []string

	// 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

	// Clear the entire collection.
	Clear()

	// Add adds items to the current collection.
	Add(more ...uint64)

	// 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

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

Uint64List contains a slice of type uint64. It encapsulates the slice and provides methods to access or mutate it.

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

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

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

func MakeUint64List(length, capacity int) *Uint64List

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

func NewUint64List

func NewUint64List(values ...uint64) *Uint64List

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

func (*Uint64List) Add

func (list *Uint64List) Add(more ...uint64)

Add adds items to the current list. This is a synonym for Append.

func (*Uint64List) Append

func (list *Uint64List) Append(more ...uint64) *Uint64List

Append adds items to the current list. If the list is nil, a new list is allocated and returned. Otherwise the modified list is returned.

func (*Uint64List) Clear

func (list *Uint64List) Clear()

Clear the entire collection.

func (*Uint64List) Clone

func (list *Uint64List) Clone() *Uint64List

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

func (*Uint64List) Contains

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

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

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

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

func (list *Uint64List) DoDeleteAt(index, n int) *Uint64List

DoDeleteAt modifies a Uint64List by deleting n elements from a given index.

The list is modified and the modified list is returned. Panics if the index is out of range or n is large enough to take the index out of range.

func (*Uint64List) DoDeleteFirst

func (list *Uint64List) DoDeleteFirst(n int) *Uint64List

DoDeleteFirst modifies a Uint64List by deleting n elements from the start of the list.

If the list is nil, a new list is allocated and returned. Otherwise the modified list is returned. Panics if n is large enough to take the index out of range.

func (*Uint64List) DoDeleteLast

func (list *Uint64List) DoDeleteLast(n int) *Uint64List

DoDeleteLast modifies a Uint64List by deleting n elements from the end of the list.

The list is modified and the modified list is returned. Panics if n is large enough to take the index out of range.

func (*Uint64List) DoInsertAt

func (list *Uint64List) DoInsertAt(index int, more ...uint64) *Uint64List

DoInsertAt modifies a Uint64List by inserting elements at a given index. This is a generalised version of Append.

If the list is nil, a new list is allocated and returned. Otherwise the modified list is returned. Panics if the index is out of range.

func (*Uint64List) DoKeepWhere

func (list *Uint64List) DoKeepWhere(p func(uint64) bool) *Uint64List

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

The list is modified and the modified list is returned.

func (*Uint64List) DoReverse

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

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

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

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

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

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. Nil lists are considered to be empty.

func (*Uint64List) Exists

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

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. See also DoKeepWhere (which does modify the original list).

func (*Uint64List) Find

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

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

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

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

func (list *Uint64List) Foreach(f func(uint64))

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

func (*Uint64List) Get

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.

func (*Uint64List) GobDecode

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

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

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

func (list *Uint64List) HeadOption() (uint64, bool)

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

func (*Uint64List) IndexWhere

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

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

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

func (list *Uint64List) IsEmpty() bool

IsEmpty tests whether Uint64List is empty.

func (*Uint64List) IsSequence

func (list *Uint64List) IsSequence() bool

IsSequence returns true for lists and queues.

func (*Uint64List) IsSet

func (list *Uint64List) IsSet() bool

IsSet returns false for lists or queues.

func (*Uint64List) Last

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

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

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

func (list *Uint64List) LastOption() (uint64, bool)

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

func (*Uint64List) Len

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

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

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

func (list Uint64List) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this list type.

func (*Uint64List) Max

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

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

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

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

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

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

func (list *Uint64List) NonEmpty() bool

NonEmpty tests whether Uint64List is empty.

func (*Uint64List) Partition

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

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

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

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

func (list *Uint64List) Size() int

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

func (*Uint64List) SortBy

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

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

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

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

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

func (list *Uint64List) StringList() []string

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

func (*Uint64List) Sum

func (list *Uint64List) Sum() uint64

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

func (*Uint64List) Swap

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

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

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

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

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

func (list *Uint64List) ToInterfaceSlice() []interface{}

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

func (*Uint64List) ToList

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

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

func (list *Uint64List) ToSlice() []uint64

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

func (*Uint64List) UnmarshalJSON

func (list *Uint64List) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this list type.

type Uint64MkStringer

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

	// implements json.Marshaler interface {
	MarshalJSON() ([]byte, error)

	// implements json.Unmarshaler interface {
	UnmarshalJSON(b []byte) error

	// 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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *Uint64Queue) Cap() int

Cap gets the capacity of this queue.

func (*Uint64Queue) Clear added in v0.8.0

func (queue *Uint64Queue) Clear()

Clear the entire queue.

func (*Uint64Queue) Clone added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *Uint64Queue) IsEmpty() bool

IsEmpty returns true if the queue is empty.

func (*Uint64Queue) IsFull added in v0.8.0

func (queue *Uint64Queue) IsFull() bool

IsFull returns true if the queue is full.

func (*Uint64Queue) IsOverwriting added in v0.8.0

func (queue *Uint64Queue) IsOverwriting() bool

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

func (*Uint64Queue) IsSequence added in v0.8.0

func (queue *Uint64Queue) IsSequence() bool

IsSequence returns true for ordered lists and queues.

func (*Uint64Queue) IsSet added in v0.8.0

func (queue *Uint64Queue) IsSet() bool

IsSet returns false for lists or queues.

func (*Uint64Queue) Last added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.0

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

MarshalJSON implements JSON encoding for this queue type.

func (*Uint64Queue) Max added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *Uint64Queue) NonEmpty() bool

NonEmpty returns true if the queue is not empty.

func (*Uint64Queue) Offer added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *Uint64Queue) Space() int

Space returns the space available in the queue.

func (*Uint64Queue) StableSort added in v0.8.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.8.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.8.0

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

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

func (*Uint64Queue) Sum added in v0.8.0

func (queue *Uint64Queue) Sum() uint64

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

func (*Uint64Queue) Swap added in v0.8.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.8.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) ToList added in v0.9.0

func (queue *Uint64Queue) ToList() *Uint64List

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

func (*Uint64Queue) ToSet added in v0.8.0

func (queue *Uint64Queue) ToSet() *Uint64Set

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

func (*Uint64Queue) ToSlice added in v0.8.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.8.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

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

Uint64Set is the primary type that represents a set.

func BuildUint64SetFromChan

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

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

func NewUint64Set(values ...uint64) *Uint64Set

NewUint64Set creates and returns a reference to an empty set.

func (*Uint64Set) Add

func (set *Uint64Set) Add(more ...uint64)

Add adds items to the current set.

func (*Uint64Set) Cardinality

func (set *Uint64Set) Cardinality() int

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

func (*Uint64Set) Clear

func (set *Uint64Set) Clear()

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

func (*Uint64Set) Clone

func (set *Uint64Set) Clone() *Uint64Set

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

func (*Uint64Set) Contains

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

func (set *Uint64Set) ContainsAll(i ...uint64) bool

ContainsAll determines whether the given items are all in the set, returning true if so.

func (*Uint64Set) CountBy

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

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

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

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

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

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

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

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

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

func (set *Uint64Set) Foreach(f func(uint64))

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

func (*Uint64Set) GobDecode

func (set *Uint64Set) GobDecode(b []byte) error

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

func (Uint64Set) GobEncode

func (set Uint64Set) 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 (*Uint64Set) Intersect

func (set *Uint64Set) Intersect(other *Uint64Set) *Uint64Set

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

func (*Uint64Set) IsEmpty

func (set *Uint64Set) IsEmpty() bool

IsEmpty returns true if the set is empty.

func (*Uint64Set) IsSequence

func (set *Uint64Set) IsSequence() bool

IsSequence returns true for lists and queues.

func (*Uint64Set) IsSet

func (set *Uint64Set) IsSet() bool

IsSet returns false for lists or queues.

func (*Uint64Set) IsSubset

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

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

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

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

func (set *Uint64Set) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this set type.

func (*Uint64Set) Max

func (set *Uint64Set) Max() (result uint64)

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

func (*Uint64Set) MaxBy

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

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

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

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

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

func (set *Uint64Set) NonEmpty() bool

NonEmpty returns true if the set is not empty.

func (*Uint64Set) Partition

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 relative order of the elements in the results is the same as in the original list.

The original set is not modified

func (*Uint64Set) Remove

func (set *Uint64Set) Remove(i uint64)

Remove a single item from the set.

func (*Uint64Set) Send

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

func (set *Uint64Set) Size() int

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

func (*Uint64Set) String

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

func (set *Uint64Set) StringList() []string

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

func (*Uint64Set) StringMap

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

func (set *Uint64Set) Sum() uint64

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

func (*Uint64Set) SymmetricDifference

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

func (set *Uint64Set) ToInterfaceSlice() []interface{}

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

func (*Uint64Set) ToList

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

func (set *Uint64Set) ToSet() *Uint64Set

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

func (*Uint64Set) ToSlice

func (set *Uint64Set) ToSlice() []uint64

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

func (*Uint64Set) Union

func (set *Uint64Set) Union(other *Uint64Set) *Uint64Set

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

func (*Uint64Set) UnmarshalJSON

func (set *Uint64Set) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this set type.

type Uint64Sizer

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

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

Uint64StringMap is the primary type that represents a thread-safe map

func NewUint64StringMap

func NewUint64StringMap(kv ...Uint64StringTuple) *Uint64StringMap

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

func NewUint64StringMap1

func NewUint64StringMap1(k uint64, v string) *Uint64StringMap

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

func (*Uint64StringMap) Clear

func (mm *Uint64StringMap) Clear()

Clear clears the entire map.

func (*Uint64StringMap) Clone

func (mm *Uint64StringMap) Clone() *Uint64StringMap

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

func (*Uint64StringMap) ContainsAllKeys

func (mm *Uint64StringMap) ContainsAllKeys(kk ...uint64) bool

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

func (*Uint64StringMap) ContainsKey

func (mm *Uint64StringMap) ContainsKey(k uint64) bool

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

func (*Uint64StringMap) DropWhere

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

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

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

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

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

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

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

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

func (mm *Uint64StringMap) Get(k uint64) (string, bool)

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

func (*Uint64StringMap) GobDecode

func (mm *Uint64StringMap) GobDecode(b []byte) error

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

func (*Uint64StringMap) GobEncode

func (mm *Uint64StringMap) GobEncode() ([]byte, error)

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

func (*Uint64StringMap) IsEmpty

func (mm *Uint64StringMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (*Uint64StringMap) Keys

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

func (*Uint64StringMap) Map

func (mm *Uint64StringMap) Map(f func(uint64, string) (uint64, string)) *Uint64StringMap

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

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

func (mm *Uint64StringMap) NonEmpty() bool

NonEmpty returns true if the map is not empty.

func (*Uint64StringMap) OrderedSlice

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

func (*Uint64StringMap) Partition

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

func (mm *Uint64StringMap) Pop(k uint64) (string, bool)

Pop removes a single item from the map, returning the value present prior to removal. The boolean result is true only if the key had been present.

func (*Uint64StringMap) Put

func (mm *Uint64StringMap) Put(k uint64, v string) bool

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

func (*Uint64StringMap) Remove

func (mm *Uint64StringMap) Remove(k uint64)

Remove a single item from the map.

func (*Uint64StringMap) Size

func (mm *Uint64StringMap) Size() int

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

func (*Uint64StringMap) String

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

func (mm *Uint64StringMap) ToSlice() Uint64StringTuples

ToSlice returns the key/value pairs as a slice

func (*Uint64StringMap) Values

func (mm *Uint64StringMap) Values() collection.StringList

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

type Uint64StringTuple

type Uint64StringTuple struct {
	Key uint64
	Val string
}

Uint64StringTuple represents a key/value pair.

func (Uint64StringTuple) MarshalJSON

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

MarshalJSON implements encoding.Marshaler interface.

func (Uint64StringTuple) UnmarshalJSON

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

UnmarshalJSON implements JSON decoding for this tuple type.

type Uint64StringTuples

type Uint64StringTuples []Uint64StringTuple

Uint64StringTuples can be used as a builder for unmodifiable maps.

func Uint64StringZip

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

Append1 adds one item.

func (Uint64StringTuples) Append2

func (ts Uint64StringTuples) Append2(k1 uint64, v1 string, k2 uint64, v2 string) Uint64StringTuples

Append2 adds two items.

func (Uint64StringTuples) Append3

func (ts Uint64StringTuples) Append3(k1 uint64, v1 string, k2 uint64, v2 string, k3 uint64, v3 string) Uint64StringTuples

Append3 adds three items.

func (Uint64StringTuples) MkString

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

func (ts Uint64StringTuples) String() string

func (Uint64StringTuples) ToMap

func (ts Uint64StringTuples) ToMap() *Uint64StringMap

ToMap converts the tuples to a map.

func (Uint64StringTuples) Values

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

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

type Uint64Uint64Map

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

Uint64Uint64Map is the primary type that represents a thread-safe map

func NewUint64Uint64Map

func NewUint64Uint64Map(kv ...Uint64Uint64Tuple) *Uint64Uint64Map

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

func NewUint64Uint64Map1

func NewUint64Uint64Map1(k uint64, v uint64) *Uint64Uint64Map

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

func (*Uint64Uint64Map) Clear

func (mm *Uint64Uint64Map) Clear()

Clear clears the entire map.

func (*Uint64Uint64Map) Clone

func (mm *Uint64Uint64Map) Clone() *Uint64Uint64Map

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

func (*Uint64Uint64Map) ContainsAllKeys

func (mm *Uint64Uint64Map) ContainsAllKeys(kk ...uint64) bool

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

func (*Uint64Uint64Map) ContainsKey

func (mm *Uint64Uint64Map) ContainsKey(k uint64) bool

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

func (*Uint64Uint64Map) DropWhere

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

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

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

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

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

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

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

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

func (mm *Uint64Uint64Map) Get(k uint64) (uint64, bool)

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

func (*Uint64Uint64Map) GobDecode

func (mm *Uint64Uint64Map) GobDecode(b []byte) error

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

func (*Uint64Uint64Map) GobEncode

func (mm *Uint64Uint64Map) GobEncode() ([]byte, error)

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

func (*Uint64Uint64Map) IsEmpty

func (mm *Uint64Uint64Map) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (*Uint64Uint64Map) Keys

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

func (*Uint64Uint64Map) Map

func (mm *Uint64Uint64Map) Map(f func(uint64, uint64) (uint64, uint64)) *Uint64Uint64Map

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

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

func (mm *Uint64Uint64Map) NonEmpty() bool

NonEmpty returns true if the map is not empty.

func (*Uint64Uint64Map) OrderedSlice

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

func (*Uint64Uint64Map) Partition

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

func (mm *Uint64Uint64Map) Pop(k uint64) (uint64, bool)

Pop removes a single item from the map, returning the value present prior to removal. The boolean result is true only if the key had been present.

func (*Uint64Uint64Map) Put

func (mm *Uint64Uint64Map) Put(k uint64, v uint64) bool

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

func (*Uint64Uint64Map) Remove

func (mm *Uint64Uint64Map) Remove(k uint64)

Remove a single item from the map.

func (*Uint64Uint64Map) Size

func (mm *Uint64Uint64Map) Size() int

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

func (*Uint64Uint64Map) String

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

func (mm *Uint64Uint64Map) ToSlice() Uint64Uint64Tuples

ToSlice returns the key/value pairs as a slice

func (*Uint64Uint64Map) Values

func (mm *Uint64Uint64Map) Values() collection.Uint64List

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

type Uint64Uint64Tuple

type Uint64Uint64Tuple struct {
	Key uint64
	Val uint64
}

Uint64Uint64Tuple represents a key/value pair.

func (Uint64Uint64Tuple) MarshalJSON

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

MarshalJSON implements encoding.Marshaler interface.

func (Uint64Uint64Tuple) UnmarshalJSON

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

UnmarshalJSON implements JSON decoding for this tuple type.

type Uint64Uint64Tuples

type Uint64Uint64Tuples []Uint64Uint64Tuple

Uint64Uint64Tuples can be used as a builder for unmodifiable maps.

func Uint64Uint64Zip

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

Append1 adds one item.

func (Uint64Uint64Tuples) Append2

func (ts Uint64Uint64Tuples) Append2(k1 uint64, v1 uint64, k2 uint64, v2 uint64) Uint64Uint64Tuples

Append2 adds two items.

func (Uint64Uint64Tuples) Append3

func (ts Uint64Uint64Tuples) Append3(k1 uint64, v1 uint64, k2 uint64, v2 uint64, k3 uint64, v3 uint64) Uint64Uint64Tuples

Append3 adds three items.

func (Uint64Uint64Tuples) MkString

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

func (ts Uint64Uint64Tuples) String() string

func (Uint64Uint64Tuples) ToMap

func (ts Uint64Uint64Tuples) ToMap() *Uint64Uint64Map

ToMap converts the tuples to a map.

func (Uint64Uint64Tuples) Values

func (ts Uint64Uint64Tuples) Values(values ...uint64) Uint64Uint64Tuples

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

type UintCollection

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)

	// MapToString returns a new []string by transforming every element with function f.
	// The resulting slice is the same size as the collection. The collection is not modified.
	MapToString(f func(uint) string) []string

	// FlatMapString 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
	// collection. The collection is not modified.
	FlatMapToString(f func(uint) []string) []string

	// 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

	// Clear the entire collection.
	Clear()

	// Add adds items to the current collection.
	Add(more ...uint)

	// 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

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

UintList contains a slice of type uint. It encapsulates the slice and provides methods to access or mutate it.

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

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

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

func MakeUintList(length, capacity int) *UintList

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

func NewUintList

func NewUintList(values ...uint) *UintList

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

func (*UintList) Add

func (list *UintList) Add(more ...uint)

Add adds items to the current list. This is a synonym for Append.

func (*UintList) Append

func (list *UintList) Append(more ...uint) *UintList

Append adds items to the current list. If the list is nil, a new list is allocated and returned. Otherwise the modified list is returned.

func (*UintList) Clear

func (list *UintList) Clear()

Clear the entire collection.

func (*UintList) Clone

func (list *UintList) Clone() *UintList

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

func (*UintList) Contains

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

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

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

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

func (list *UintList) DoDeleteAt(index, n int) *UintList

DoDeleteAt modifies a UintList by deleting n elements from a given index.

The list is modified and the modified list is returned. Panics if the index is out of range or n is large enough to take the index out of range.

func (*UintList) DoDeleteFirst

func (list *UintList) DoDeleteFirst(n int) *UintList

DoDeleteFirst modifies a UintList by deleting n elements from the start of the list.

If the list is nil, a new list is allocated and returned. Otherwise the modified list is returned. Panics if n is large enough to take the index out of range.

func (*UintList) DoDeleteLast

func (list *UintList) DoDeleteLast(n int) *UintList

DoDeleteLast modifies a UintList by deleting n elements from the end of the list.

The list is modified and the modified list is returned. Panics if n is large enough to take the index out of range.

func (*UintList) DoInsertAt

func (list *UintList) DoInsertAt(index int, more ...uint) *UintList

DoInsertAt modifies a UintList by inserting elements at a given index. This is a generalised version of Append.

If the list is nil, a new list is allocated and returned. Otherwise the modified list is returned. Panics if the index is out of range.

func (*UintList) DoKeepWhere

func (list *UintList) DoKeepWhere(p func(uint) bool) *UintList

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

The list is modified and the modified list is returned.

func (*UintList) DoReverse

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

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

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

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

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

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. Nil lists are considered to be empty.

func (*UintList) Exists

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

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. See also DoKeepWhere (which does modify the original list).

func (*UintList) Find

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

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

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

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

func (list *UintList) Foreach(f func(uint))

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

func (*UintList) Get

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.

func (*UintList) GobDecode

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

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

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

func (list *UintList) HeadOption() (uint, bool)

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

func (*UintList) IndexWhere

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

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

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

func (list *UintList) IsEmpty() bool

IsEmpty tests whether UintList is empty.

func (*UintList) IsSequence

func (list *UintList) IsSequence() bool

IsSequence returns true for lists and queues.

func (*UintList) IsSet

func (list *UintList) IsSet() bool

IsSet returns false for lists or queues.

func (*UintList) Last

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

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

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

func (list *UintList) LastOption() (uint, bool)

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

func (*UintList) Len

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

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

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

func (list UintList) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this list type.

func (*UintList) Max

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

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

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

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

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

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

func (list *UintList) NonEmpty() bool

NonEmpty tests whether UintList is empty.

func (*UintList) Partition

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

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

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

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

func (list *UintList) Size() int

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

func (*UintList) SortBy

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

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

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

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

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

func (list *UintList) StringList() []string

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

func (*UintList) Sum

func (list *UintList) Sum() uint

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

func (*UintList) Swap

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

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

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

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

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

func (list *UintList) ToInterfaceSlice() []interface{}

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

func (*UintList) ToList

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

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

func (list *UintList) ToSlice() []uint

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

func (*UintList) UnmarshalJSON

func (list *UintList) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this list type.

type UintMkStringer

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

	// implements json.Marshaler interface {
	MarshalJSON() ([]byte, error)

	// implements json.Unmarshaler interface {
	UnmarshalJSON(b []byte) error

	// 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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *UintQueue) Cap() int

Cap gets the capacity of this queue.

func (*UintQueue) Clear added in v0.8.0

func (queue *UintQueue) Clear()

Clear the entire queue.

func (*UintQueue) Clone added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *UintQueue) IsEmpty() bool

IsEmpty returns true if the queue is empty.

func (*UintQueue) IsFull added in v0.8.0

func (queue *UintQueue) IsFull() bool

IsFull returns true if the queue is full.

func (*UintQueue) IsOverwriting added in v0.8.0

func (queue *UintQueue) IsOverwriting() bool

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

func (*UintQueue) IsSequence added in v0.8.0

func (queue *UintQueue) IsSequence() bool

IsSequence returns true for ordered lists and queues.

func (*UintQueue) IsSet added in v0.8.0

func (queue *UintQueue) IsSet() bool

IsSet returns false for lists or queues.

func (*UintQueue) Last added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.0

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

MarshalJSON implements JSON encoding for this queue type.

func (*UintQueue) Max added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *UintQueue) NonEmpty() bool

NonEmpty returns true if the queue is not empty.

func (*UintQueue) Offer added in v0.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.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.8.0

func (queue *UintQueue) Space() int

Space returns the space available in the queue.

func (*UintQueue) StableSort added in v0.8.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.8.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.8.0

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

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

func (*UintQueue) Sum added in v0.8.0

func (queue *UintQueue) Sum() uint

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

func (*UintQueue) Swap added in v0.8.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.8.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) ToList added in v0.9.0

func (queue *UintQueue) ToList() *UintList

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

func (*UintQueue) ToSet added in v0.8.0

func (queue *UintQueue) ToSet() *UintSet

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

func (*UintQueue) ToSlice added in v0.8.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.8.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

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

UintSet is the primary type that represents a set.

func BuildUintSetFromChan

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

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

func NewUintSet(values ...uint) *UintSet

NewUintSet creates and returns a reference to an empty set.

func (*UintSet) Add

func (set *UintSet) Add(more ...uint)

Add adds items to the current set.

func (*UintSet) Cardinality

func (set *UintSet) Cardinality() int

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

func (*UintSet) Clear

func (set *UintSet) Clear()

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

func (*UintSet) Clone

func (set *UintSet) Clone() *UintSet

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

func (*UintSet) Contains

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

func (set *UintSet) ContainsAll(i ...uint) bool

ContainsAll determines whether the given items are all in the set, returning true if so.

func (*UintSet) CountBy

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

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

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

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

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

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

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

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

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

func (set *UintSet) Foreach(f func(uint))

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

func (*UintSet) GobDecode

func (set *UintSet) GobDecode(b []byte) error

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

func (UintSet) GobEncode

func (set UintSet) 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 (*UintSet) Intersect

func (set *UintSet) Intersect(other *UintSet) *UintSet

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

func (*UintSet) IsEmpty

func (set *UintSet) IsEmpty() bool

IsEmpty returns true if the set is empty.

func (*UintSet) IsSequence

func (set *UintSet) IsSequence() bool

IsSequence returns true for lists and queues.

func (*UintSet) IsSet

func (set *UintSet) IsSet() bool

IsSet returns false for lists or queues.

func (*UintSet) IsSubset

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

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

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

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

func (set *UintSet) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON encoding for this set type.

func (*UintSet) Max

func (set *UintSet) Max() (result uint)

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

func (*UintSet) MaxBy

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

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

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

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

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

func (set *UintSet) NonEmpty() bool

NonEmpty returns true if the set is not empty.

func (*UintSet) Partition

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 relative order of the elements in the results is the same as in the original list.

The original set is not modified

func (*UintSet) Remove

func (set *UintSet) Remove(i uint)

Remove a single item from the set.

func (*UintSet) Send

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

func (set *UintSet) Size() int

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

func (*UintSet) String

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

func (set *UintSet) StringList() []string

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

func (*UintSet) StringMap

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

func (set *UintSet) Sum() uint

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

func (*UintSet) SymmetricDifference

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

func (set *UintSet) ToInterfaceSlice() []interface{}

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

func (*UintSet) ToList

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

func (set *UintSet) ToSet() *UintSet

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

func (*UintSet) ToSlice

func (set *UintSet) ToSlice() []uint

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

func (*UintSet) Union

func (set *UintSet) Union(other *UintSet) *UintSet

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

func (*UintSet) UnmarshalJSON

func (set *UintSet) UnmarshalJSON(b []byte) error

UnmarshalJSON implements JSON decoding for this set type.

type UintSizer

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

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

UintStringMap is the primary type that represents a thread-safe map

func NewUintStringMap

func NewUintStringMap(kv ...UintStringTuple) *UintStringMap

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

func NewUintStringMap1

func NewUintStringMap1(k uint, v string) *UintStringMap

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

func (*UintStringMap) Clear

func (mm *UintStringMap) Clear()

Clear clears the entire map.

func (*UintStringMap) Clone

func (mm *UintStringMap) Clone() *UintStringMap

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

func (*UintStringMap) ContainsAllKeys

func (mm *UintStringMap) ContainsAllKeys(kk ...uint) bool

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

func (*UintStringMap) ContainsKey

func (mm *UintStringMap) ContainsKey(k uint) bool

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

func (*UintStringMap) DropWhere

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

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

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

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

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

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

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

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

func (mm *UintStringMap) Get(k uint) (string, bool)

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

func (*UintStringMap) GobDecode

func (mm *UintStringMap) GobDecode(b []byte) error

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

func (*UintStringMap) GobEncode

func (mm *UintStringMap) GobEncode() ([]byte, error)

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

func (*UintStringMap) IsEmpty

func (mm *UintStringMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (*UintStringMap) Keys

func (mm *UintStringMap) Keys() collection.UintList

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

func (*UintStringMap) Map

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

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

func (mm *UintStringMap) NonEmpty() bool

NonEmpty returns true if the map is not empty.

func (*UintStringMap) OrderedSlice

func (mm *UintStringMap) OrderedSlice(keys collection.UintList) UintStringTuples

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

func (*UintStringMap) Partition

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

func (mm *UintStringMap) Pop(k uint) (string, bool)

Pop removes a single item from the map, returning the value present prior to removal. The boolean result is true only if the key had been present.

func (*UintStringMap) Put

func (mm *UintStringMap) Put(k uint, v string) bool

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

func (*UintStringMap) Remove

func (mm *UintStringMap) Remove(k uint)

Remove a single item from the map.

func (*UintStringMap) Size

func (mm *UintStringMap) Size() int

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

func (*UintStringMap) String

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

func (mm *UintStringMap) ToSlice() UintStringTuples

ToSlice returns the key/value pairs as a slice

func (*UintStringMap) Values

func (mm *UintStringMap) Values() collection.StringList

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

type UintStringTuple

type UintStringTuple struct {
	Key uint
	Val string
}

UintStringTuple represents a key/value pair.

func (UintStringTuple) MarshalJSON

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

MarshalJSON implements encoding.Marshaler interface.

func (UintStringTuple) UnmarshalJSON

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

UnmarshalJSON implements JSON decoding for this tuple type.

type UintStringTuples

type UintStringTuples []UintStringTuple

UintStringTuples can be used as a builder for unmodifiable maps.

func UintStringZip

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

func (ts UintStringTuples) Append1(k uint, v string) UintStringTuples

Append1 adds one item.

func (UintStringTuples) Append2

func (ts UintStringTuples) Append2(k1 uint, v1 string, k2 uint, v2 string) UintStringTuples

Append2 adds two items.

func (UintStringTuples) Append3

func (ts UintStringTuples) Append3(k1 uint, v1 string, k2 uint, v2 string, k3 uint, v3 string) UintStringTuples

Append3 adds three items.

func (UintStringTuples) MkString

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

func (ts UintStringTuples) String() string

func (UintStringTuples) ToMap

func (ts UintStringTuples) ToMap() *UintStringMap

ToMap converts the tuples to a map.

func (UintStringTuples) Values

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

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

type UintUintMap

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

UintUintMap is the primary type that represents a thread-safe map

func NewUintUintMap

func NewUintUintMap(kv ...UintUintTuple) *UintUintMap

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

func NewUintUintMap1

func NewUintUintMap1(k uint, v uint) *UintUintMap

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

func (*UintUintMap) Clear

func (mm *UintUintMap) Clear()

Clear clears the entire map.

func (*UintUintMap) Clone

func (mm *UintUintMap) Clone() *UintUintMap

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

func (*UintUintMap) ContainsAllKeys

func (mm *UintUintMap) ContainsAllKeys(kk ...uint) bool

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

func (*UintUintMap) ContainsKey

func (mm *UintUintMap) ContainsKey(k uint) bool

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

func (*UintUintMap) DropWhere

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

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

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

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

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

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

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

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

func (mm *UintUintMap) Get(k uint) (uint, bool)

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

func (*UintUintMap) GobDecode

func (mm *UintUintMap) GobDecode(b []byte) error

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

func (*UintUintMap) GobEncode

func (mm *UintUintMap) GobEncode() ([]byte, error)

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

func (*UintUintMap) IsEmpty

func (mm *UintUintMap) IsEmpty() bool

IsEmpty returns true if the map is empty.

func (*UintUintMap) Keys

func (mm *UintUintMap) Keys() collection.UintList

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

func (*UintUintMap) Map

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

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

func (mm *UintUintMap) NonEmpty() bool

NonEmpty returns true if the map is not empty.

func (*UintUintMap) OrderedSlice

func (mm *UintUintMap) OrderedSlice(keys collection.UintList) UintUintTuples

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

func (*UintUintMap) Partition

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

func (mm *UintUintMap) Pop(k uint) (uint, bool)

Pop removes a single item from the map, returning the value present prior to removal. The boolean result is true only if the key had been present.

func (*UintUintMap) Put

func (mm *UintUintMap) Put(k uint, v uint) bool

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

func (*UintUintMap) Remove

func (mm *UintUintMap) Remove(k uint)

Remove a single item from the map.

func (*UintUintMap) Size

func (mm *UintUintMap) Size() int

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

func (*UintUintMap) String

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

func (mm *UintUintMap) ToSlice() UintUintTuples

ToSlice returns the key/value pairs as a slice

func (*UintUintMap) Values

func (mm *UintUintMap) Values() collection.UintList

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

type UintUintTuple

type UintUintTuple struct {
	Key uint
	Val uint
}

UintUintTuple represents a key/value pair.

func (UintUintTuple) MarshalJSON

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

MarshalJSON implements encoding.Marshaler interface.

func (UintUintTuple) UnmarshalJSON

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

UnmarshalJSON implements JSON decoding for this tuple type.

type UintUintTuples

type UintUintTuples []UintUintTuple

UintUintTuples can be used as a builder for unmodifiable maps.

func UintUintZip

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

func (ts UintUintTuples) Append1(k uint, v uint) UintUintTuples

Append1 adds one item.

func (UintUintTuples) Append2

func (ts UintUintTuples) Append2(k1 uint, v1 uint, k2 uint, v2 uint) UintUintTuples

Append2 adds two items.

func (UintUintTuples) Append3

func (ts UintUintTuples) Append3(k1 uint, v1 uint, k2 uint, v2 uint, k3 uint, v3 uint) UintUintTuples

Append3 adds three items.

func (UintUintTuples) MkString

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

func (ts UintUintTuples) String() string

func (UintUintTuples) ToMap

func (ts UintUintTuples) ToMap() *UintUintMap

ToMap converts the tuples to a map.

func (UintUintTuples) Values

func (ts UintUintTuples) Values(values ...uint) UintUintTuples

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

Jump to

Keyboard shortcuts

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