Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsSingle ¶
func ContainsSingle(a SortedInts, x int) bool
ContainsSingle returns if a contains x.
func ContainsSorted ¶
func ContainsSorted(a, b SortedInts) bool
ContainsSorted returns if a contains the SortedInts b.
func IntersectionSize ¶
func IntersectionSize(a, b SortedInts) int
IntersectionSize returns the number of elements in both a and b.
Types ¶
type SortedInts ¶
type SortedInts []int
SortedInts is used to hold a collection of sorted ints without repeats. This is generally used as a way of storing a set of ints.
func Complement ¶
func Complement(n int, a SortedInts) SortedInts
Complement returns a new SortedInts containing the elements in {0,..., n-1} but not a. a is not modified.
func Intersection ¶
func Intersection(a, b SortedInts) SortedInts
Intersection returns a new SortedInts containing the elements in a and b. a and b are not modified.
func NewSortedInts ¶
func NewSortedInts(x ...int) SortedInts
NewSortedInts creates a SortedInts from the set input x.
func Range ¶
func Range(start, end, step int) SortedInts
Range creates a SortedInts by adding all the elements of the form start + i*step which lie in [start, end).
func SetMinus ¶
func SetMinus(a, b SortedInts) SortedInts
SetMinus returns a new SortedInts containing the elements in a but not b. a and b are not modified.
func Union ¶
func Union(a, b SortedInts) SortedInts
Union returns are new SortedInts which is the union of a and b. a and b are not modified.
func XOR ¶
func XOR(a, b SortedInts) SortedInts
XOR returns a new SortedInts containing the elements in a or b but not both. a and b are not modified.
func (*SortedInts) Add ¶
func (s *SortedInts) Add(x ...int)
Add modifies s by adding the element x... if they are not already present. The arguments do not need to be sorted.
func (*SortedInts) Remove ¶
func (s *SortedInts) Remove(x int)
Remove modifies s by removing the element x if it is present.
func (*SortedInts) Union ¶
func (s *SortedInts) Union(b SortedInts)
Union adds the elements in a to s.Union This is more efficient than Add as it doesn't create any extra slices.