sets

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generic

type Generic map[string]SetObject

func NewGeneric

func NewGeneric(items ...SetObject) Generic

New creates a Generic from a list of values.

func (Generic) Delete

func (g Generic) Delete(items ...SetObject)

Delete removes all items from the set.

func (Generic) Difference

func (g Generic) Difference(g2 Generic) Generic

Difference returns a set of objects that are not in s2 For example: s1 = {a1, a2, a3} s2 = {a1, a2, a4, a5} s1.Difference(s2) = {a3} s2.Difference(s1) = {a4, a5}

func (Generic) Equal

func (g Generic) Equal(s2 Generic) bool

Equal returns true if and only if s1 is equal (as a set) to s2. Two sets are equal if their membership is identical. (In practice, this means same elements, order doesn't matter)

func (Generic) Has

func (g Generic) Has(item SetObject) bool

Has returns true if and only if item is contained in the set.

func (Generic) HasAll

func (g Generic) HasAll(items ...SetObject) bool

HasAll returns true if and only if all items are contained in the set.

func (Generic) HasAny

func (g Generic) HasAny(items ...SetObject) bool

HasAny returns true if any items are contained in the set.

func (Generic) Insert

func (g Generic) Insert(items ...SetObject)

Insert adds items to the set.

func (Generic) Intersection

func (g Generic) Intersection(s2 Generic) Generic

Intersection returns a new set which includes the item in BOTH s1 and s2 For example: s1 = {a1, a2} s2 = {a2, a3} s1.Intersection(s2) = {a2}

func (Generic) IsSuperset

func (g Generic) IsSuperset(s2 Generic) bool

IsSuperset returns true if and only if s1 is a superset of s2.

func (Generic) Len

func (g Generic) Len() int

Len returns the size of the set.

func (Generic) List

func (g Generic) List() []SetObject

List returns the contents as a sorted string slice.

func (Generic) ListKeys

func (g Generic) ListKeys() []string

List returns the contents as a sorted string slice.

func (Generic) PopAny

func (g Generic) PopAny() (SetObject, bool)

Returns a single element from the set.

func (Generic) Union

func (g Generic) Union(s2 Generic) Generic

Union returns a new set which includes items in either s1 or s2. For example: s1 = {a1, a2} s2 = {a3, a4} s1.Union(s2) = {a1, a2, a3, a4} s2.Union(s1) = {a1, a2, a3, a4}

func (Generic) UnsortedList

func (g Generic) UnsortedList() []SetObject

UnsortedList returns the slice with contents in random order.

func (Generic) UnsortedListKeys

func (g Generic) UnsortedListKeys() []string

UnsortedList returns the slice with contents in random order.

type SetObject

type SetObject interface {
	GetID() string
}

Jump to

Keyboard shortcuts

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