set

package
Version: v0.0.0-...-3c8a918 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2015 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Overview

Implementation of a Set container

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set interface {
	// Returns a new Set that contains exactly the same elements as this set.
	Copy() Set

	// Returns the cardinality of this set.
	Len() int

	// Returns true if and only if this set contains v (according to Go equality rules).
	Contains(v interface{}) bool
	// Inserts v into this set.
	Add(v interface{})
	// Removes v from this set, if it is present.  Returns true if and only if v was present.
	Remove(v interface{}) bool

	// Executes f(v) for every element v in this set.  If f mutates this set, behavior is undefined.
	Do(f func(interface{}))
	// Executes f(v) once for every element v in the set, aborting if f ever returns false. If f
	// mutates this set, behavior is undefined.
	DoWhile(f func(interface{}) bool)
	// Returns a channel from which each element in the set can be read exactly once.  If this set
	// is mutated before the channel is emptied, the exact data read from the channel is undefined.
	Iter() <-chan interface{}

	// Adds every element in s into this set.
	Union(s Set)
	// Removes every element not in s from this set.
	Intersect(s Set)
	// Removes every element in s from this set.
	Subtract(s Set)
	// Removes all elements from the set.
	Init()
	// Returns true if and only if all elements in this set are elements in s.
	IsSubset(s Set) bool
	// Returns true if and only if all elements in s are elements in this set.
	IsSuperset(s Set) bool
	// Returns true if and only if this set and s contain exactly the same elements.
	IsEqual(s Set) bool
	// Removes all elements v from this set that satisfy f(v) == true.
	RemoveIf(f func(interface{}) bool)
}

An unordered collection of unique elements which supports lookups, insertions, deletions, iteration, and common binary set operations. It is not guaranteed to be thread-safe.

func Intersect

func Intersect(s1 Set, s2 Set) Set

Returns a new set which is the intersect of s1 and s2. s1 and s2 are unmodified.

func NewKeyedSet

func NewKeyedSet(keyf func(interface{}) interface{}, items ...interface{}) Set

Returns a new Set pre-populated with the given items

func NewSet

func NewSet(items ...interface{}) Set

Returns a new Set pre-populated with the given items

func Subtract

func Subtract(s1 Set, s2 Set) Set

Returns a new set which is the difference between s1 and s2. s1 and s2 are unmodified.

func Union

func Union(s1 Set, s2 Set) Set

Returns a new set which is the union of s1 and s2. s1 and s2 are unmodified.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL