set

package
v0.0.0-...-d437eb7 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: NCSA Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const Max = int64(^uint64(0) >> 1)

Max is the maximum value of int64.

Variables

This section is empty.

Functions

func Equal

func Equal(a, b Nodes) bool

Equal reports set equality between the parameters. Sets are equal if and only if they have the same elements.

func Int64sEqual

func Int64sEqual(a, b Int64s) bool

Int64sEqual reports set equality between the parameters. Sets are equal if and only if they have the same elements.

func IntsEqual

func IntsEqual(a, b Ints) bool

IntsEqual reports set equality between the parameters. Sets are equal if and only if they have the same elements.

Types

type Int64s

type Int64s map[int64]struct{}

Int64s is a set of int64 identifiers.

func (Int64s) Add

func (s Int64s) Add(e int64)

Add inserts an element into the set.

func (Int64s) Count

func (s Int64s) Count() int

Count reports the number of elements stored in the set.

func (Int64s) Has

func (s Int64s) Has(e int64) bool

Has reports the existence of the element in the set.

func (Int64s) Remove

func (s Int64s) Remove(e int64)

Remove deletes the specified element from the set.

type Ints

type Ints map[int]struct{}

Ints is a set of int identifiers.

func (Ints) Add

func (s Ints) Add(e int)

Add inserts an element into the set.

func (Ints) Count

func (s Ints) Count() int

Count reports the number of elements stored in the set.

func (Ints) Has

func (s Ints) Has(e int) bool

Has reports the existence of the element in the set.

func (Ints) Remove

func (s Ints) Remove(e int)

Remove deletes the specified element from the set.

type Nodes

type Nodes map[int64]graph.Node

Nodes is a set of nodes keyed in their integer identifiers.

func (Nodes) Add

func (s Nodes) Add(n graph.Node)

Add inserts an element into the set.

func (Nodes) Copy

func (dst Nodes) Copy(src Nodes) Nodes

Copy performs a perfect copy from src to dst (meaning the sets will be equal).

func (Nodes) Has

func (s Nodes) Has(n graph.Node) bool

Has reports the existence of the element in the set.

func (Nodes) Intersect

func (dst Nodes) Intersect(a, b Nodes) Nodes

Intersect takes the intersection of a and b, and stores it in dst.

The intersection of two sets, a and b, is the set containing all the elements shared between the two sets, for instance:

{a,b,c} INTERSECT {b,c,d} = {b,c}

The intersection between a set and itself is itself, and thus effectively a copy operation:

{a,b,c} INTERSECT {a,b,c} = {a,b,c}

The intersection between two sets that share no elements is the empty set:

{a,b,c} INTERSECT {d,e,f} = {}

func (Nodes) Remove

func (s Nodes) Remove(e graph.Node)

Remove deletes the specified element from the set.

func (Nodes) Union

func (dst Nodes) Union(a, b Nodes) Nodes

Union takes the union of a and b, and stores it in dst.

The union of two sets, a and b, is the set containing all the elements of each, for instance:

{a,b,c} UNION {d,e,f} = {a,b,c,d,e,f}

Since sets may not have repetition, unions of two sets that overlap do not contain repeat elements, that is:

{a,b,c} UNION {b,c,d} = {a,b,c,d}

type Set

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

Set implements available ID storage.

func NewSet

func NewSet() Set

NewSet returns a new Set. The returned value should not be passed except by pointer.

func (*Set) NewID

func (s *Set) NewID() int64

NewID returns a new unique ID. The ID returned is not considered used until passed in a call to use.

func (*Set) Release

func (s *Set) Release(id int64)

Release frees the id for reuse.

func (*Set) Use

func (s *Set) Use(id int64)

Use adds the id to the used IDs in the Set.

Jump to

Keyboard shortcuts

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