intset

package
v0.0.0-...-6fe4f4e Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MIT Imports: 2 Imported by: 0

README

Exercise 6.3 (P167)

(*IntSet).UnionWith computes the union of two sets using |, the word-parallel bitwise OR operator. Implement methods for IntersectWith, DifferenceWith and SymmetricDifference for the corresponding set operations. (The symmetric difference of two sets contains the elements present in one set or the other but not both.)

Documentation

Overview

Package intset provides a set of integers based on a bit vector.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IntSet

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

An IntSet is a set of small non-negative integers. Its zero value represents the empty set.

func (*IntSet) Add

func (s *IntSet) Add(x int)

Add adds the non-negative value x to the set.

func (*IntSet) AddAll

func (s *IntSet) AddAll(vals ...int)

AddAll addes all the non-negative values to the set.

func (*IntSet) Clear

func (s *IntSet) Clear()

Clear removes all elements from the set

func (*IntSet) Copy

func (s *IntSet) Copy() *IntSet

Copy return a copy of the set

func (*IntSet) DifferenceWith

func (s *IntSet) DifferenceWith(t *IntSet)

DifferenceWith sets s to the difference of s and t.

func (*IntSet) Has

func (s *IntSet) Has(x int) bool

Has reports whether the set contains the non-negative value x.

func (*IntSet) IntersectWith

func (s *IntSet) IntersectWith(t *IntSet)

IntersectWith sets s to the intersection of s and t.

func (*IntSet) Len

func (s *IntSet) Len() (l int)

Len return the number of elements

func (*IntSet) Remove

func (s *IntSet) Remove(x int)

Remove x from the set

func (*IntSet) String

func (s *IntSet) String() string

String returns the set as a string of the form "{1 2 3}".

func (*IntSet) SymmetricDifference

func (s *IntSet) SymmetricDifference(t *IntSet)

SymmetricDifference sets s to the difference of s and t.

func (*IntSet) UnionWith

func (s *IntSet) UnionWith(t *IntSet)

UnionWith sets s to the union of s and t.

Jump to

Keyboard shortcuts

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