sets

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: 2 Imported by: 1

Documentation

Overview

The module util/sets implements the type Set, a set of non-negative integers, represented by intervals.

Index

Constants

View Source
const (

	// The smallest integer in sets.
	SMin = 0

	// The largest integer in sets.
	SMax = 1<<31 - 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

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

Set of non-negative integers.

func Full

func Full() *Set

Returns the largest set available: SMin..SMax.

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 S.Set) *Set

Returns the set corresponding to the bitset se

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 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

Test 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) First

func (i *SetIterator) First() (min, max int, ok bool)

On return, min..max is the first interval of the set attached to i. Returns true in ok if such an interval exists. Usage: min, max, ok := i.First(); for ok { ... min, max, ok = i.Next()}

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) Next

func (i *SetIterator) Next() (min, max int, ok bool)

On return, min..max is the next interval of the set attached to i. Returns true in ok if such an interval exists. i.First must have been called once before i.Next. Usage: min, max, ok := i.First(); for ok { ... min, max, ok = i.Next()}

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