sets2

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2023 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SMin = 0         // The smallest integer in sets.
	SMax = 1<<31 - 2 // The largest integer in sets.

)

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set map[int]void

Set of non-negative integers.

func Interval

func Interval(min, max int) Set

Returns the set corresponding to the interval min..max.

func NewSet

func NewSet() Set

Creates and returns a new empty set.

func Small

func Small(se uint64) Set

Returns the set corresponding to the bitset se

func (Set) Add

func (s1 Set) Add(s2 Set)

Puts in s1 the union of s1 and s2

func (Set) Attach

func (s Set) Attach() *SetIterator

Attach the set s to a SetIterator and return the later.

func (Set) Clear

func (s Set) Clear(min, max int)

Removes the interval min..max from the set s.

func (Set) Copy

func (s Set) Copy() Set

Creates and returns a copy of s.

func (Set) Diff

func (s1 Set) Diff(s2 Set) Set

Returns the difference between s1 and s2.

func (Set) Equal

func (s1 Set) Equal(s2 Set) bool

Tests whether s1 = s2.

func (Set) Excl

func (s Set) Excl(e int)

Excludes the integer e from the set s.

func (Set) Fill

func (s Set) Fill(min, max int)

Adds the interval min..max to the set s.

func (Set) In

func (s Set) In(e int) bool

Tests whether the integer e is included in the set s.

func (Set) Incl

func (s Set) Incl(e int)

Includes the integer e in the set s.

func (Set) Inter

func (s1 Set) Inter(s2 Set) Set

Returns the intersection of s1 and s2.

func (Set) IsEmpty

func (s Set) IsEmpty() bool

Tests whether s is empty.

func (Set) NbElems

func (s Set) NbElems() int

Return the number of elements in s

func (Set) Subset

func (s1 Set) Subset(s2 Set) bool

Tests whether s1 is a subset of s2.

func (Set) Union

func (s1 Set) Union(s2 Set) Set

Returns the union of s1 and s2.

func (Set) XOR

func (s1 Set) XOR(s2 Set) Set

Returns the exclusive union of s1 and s2.

type SetIterator

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

func (*SetIterator) FirstE

func (i *SetIterator) FirstE() (e int, ok bool)

On return, e contains the first element of the set attached to i. Returns true in ok if such an element exists. Usage: e, ok := i.FirstE(); for ok { ... e, ok = i.NextE()}

func (*SetIterator) NextE

func (i *SetIterator) NextE() (e int, ok bool)

On return, e contains the next element of the set attached to i. Returns true in ok if such an element exists. i.FirstE must have been called once before i.NextE. Usage: e, ok := i.FirstE(); for ok { ... e, ok = i.NextE()}

Jump to

Keyboard shortcuts

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