set

package
v0.0.0-...-97ebcb8 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2023 License: Apache-2.0, BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Overview

The set package provides a generic set interface and some implementations of it.

Is this going too far?!

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitSet

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

func (*BitSet) Add

func (b *BitSet) Add(x Int)

func (*BitSet) Intersect

func (b *BitSet) Intersect(c, d *BitSet) *BitSet

func (*BitSet) Iter

func (b *BitSet) Iter() Iter[Int]

func (*BitSet) New

func (b *BitSet) New() *BitSet

func (*BitSet) Remove

func (b *BitSet) Remove(x Int)

func (*BitSet) Union

func (b *BitSet) Union(c, d *BitSet) *BitSet

type Equaler

type Equaler[T any] interface {
	Equal(t T) bool
}

type Int

type Int int

func (Int) Equal

func (i Int) Equal(j Int) bool

type Iter

type Iter[T any] interface {
	Next() bool
	Item() T
}

type Set

type Set[
	self any,
	elem Equaler[elem],
] interface {
	// New returns a new empty instance of the set.
	New() self

	// Union sets the contents of the receiver to
	// the union of a and b and returns the receiver.
	Union(a, b self) self

	// Intersect sets the contents of the receiver to
	// the union of a and b and returns the receiver.
	Intersect(a, b self) self

	// Iter returns an iterator that visits each member
	// of the set in turn.
	Iter() Iter[elem]

	// Add adds the given elements to the set.
	Add(elem)

	// Add removes the given elements to the set.
	Remove(elem)
}

Set defines a mutable set; members can be added and removed and the set can be combined with itself.

Jump to

Keyboard shortcuts

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