internal

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2016 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(s1, s2 Set) bool

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

func Same

func Same(s1, s2 Set) bool

Same determines whether two sets are backed by the same store. In the current implementation using hash maps it makes use of the fact that hash maps (at least in the gc implementation) are passed as a pointer to a runtime Hmap struct.

A map is not seen by the runtime as a pointer though, so we cannot directly compare the sets converted to unsafe.Pointer and need to take the sets' addressed and dereference them as pointers to some comparable type.

Types

type BySliceValues

type BySliceValues [][]int

BySliceValues implements the sort.Interface sorting a slice of []int lexically by the values of the []int.

func (BySliceValues) Len

func (c BySliceValues) Len() int

func (BySliceValues) Less

func (c BySliceValues) Less(i, j int) bool

func (BySliceValues) Swap

func (c BySliceValues) Swap(i, j int)

type IntSet

type IntSet map[int]struct{}

IntSet is a set of integer identifiers.

func (IntSet) Add

func (s IntSet) Add(e int)

Add inserts an element into the set.

func (IntSet) Count

func (s IntSet) Count() int

Count reports the number of elements stored in the set.

func (IntSet) Has

func (s IntSet) Has(e int) bool

Has reports the existence of the element in the set.

func (IntSet) Remove

func (s IntSet) Remove(e int)

Remove deletes the specified element from the set.

type NodeQueue

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

NodeQueue implements a FIFO queue.

func (*NodeQueue) Dequeue

func (q *NodeQueue) Dequeue() graph.Node

Dequeue returns the graph.Node at the front of the queue and removes it from the queue.

func (*NodeQueue) Enqueue

func (q *NodeQueue) Enqueue(n graph.Node)

Enqueue adds the node n to the back of the queue.

func (*NodeQueue) Len

func (q *NodeQueue) Len() int

Len returns the number of graph.Nodes in the queue.

func (*NodeQueue) Reset

func (q *NodeQueue) Reset()

Reset clears the queue for reuse.

type NodeStack

type NodeStack []graph.Node

NodeStack implements a LIFO stack of graph.Node.

func (*NodeStack) Len

func (s *NodeStack) Len() int

Len returns the number of graph.Nodes on the stack.

func (*NodeStack) Pop

func (s *NodeStack) Pop() graph.Node

Pop returns the last graph.Node on the stack and removes it from the stack.

func (*NodeStack) Push

func (s *NodeStack) Push(n graph.Node)

Push adds the node n to the stack at the last position.

type Set

type Set map[int]graph.Node

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

func Clear

func Clear(s Set) Set

Clear returns an empty set, possibly using the same backing store. Clear is not provided as a method since there is no way to replace the calling value if clearing is performed by a make(set). Clear should never be called without keeping the returned value.

func (Set) Add

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

Add inserts an element into the set.

func (Set) Copy

func (dst Set) Copy(src Set) Set

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

func (Set) Has

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

Has reports the existence of the element in the set.

func (Set) Intersect

func (dst Set) Intersect(s1, s2 Set) Set

Intersect takes the intersection of s1 and s2, and stores it in dst.

The intersection of two sets, s1 and s2, 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 (Set) Remove

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

Remove deletes the specified element from the set.

func (Set) Union

func (dst Set) Union(s1, s2 Set) Set

Union takes the union of s1 and s2, and stores it in dst.

The union of two sets, s1 and s2, 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}

Jump to

Keyboard shortcuts

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