Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Equal ¶
Equal reports set equality between the parameters. Sets are equal if and only if they have the same elements.
func Same ¶
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) Count ¶
Count reports the number of elements stored in the set.
func (IntSet) Has ¶
Has reports the existence of the element in the set.
type NodeQueue ¶
type NodeQueue struct {
// contains filtered or unexported fields
}
NodeQueue implements a FIFO queue.
func (*NodeQueue) Dequeue ¶
Dequeue returns the graph.Node at the front of the queue and removes it from the queue.
func (*NodeQueue) Enqueue ¶
Enqueue adds the node n to the back of the queue.
func (*NodeQueue) Len ¶
Len returns the number of graph.Nodes in the queue.
type NodeStack ¶
NodeStack implements a LIFO stack of graph.Node.
func (*NodeStack) Len ¶
Len returns the number of graph.Nodes on the stack.
func (*NodeStack) Pop ¶
Pop returns the last graph.Node on the stack and removes it from the stack.
type Set ¶
A set is a set of nodes keyed in their integer identifiers.
func Clear ¶
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) Copy ¶
Copy performs a perfect copy from s1 to dst (meaning the sets will be equal).
func (Set) Has ¶
Has reports the existence of the element in the set.
func (Set) Intersect ¶
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 ¶
Remove deletes the specified element from the set.
func (Set) Union ¶
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}