gset

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder is a mutable builder for GSet (Generic Set). Functions that mutate instances of this type are not thread-safe.

func NewBuilder

func NewBuilder() Builder

NewBuilder returns a mutable GSet builder.

func (Builder) Add

func (b Builder) Add(key string, value GValue)

Add adds the supplied elements to the result. Calling Add after calling Result has no effect.

func (Builder) Result

func (b Builder) Result() GSet

Result returns the result GSet containing all elements that were previously added to this builder. Subsequent calls to Add have no effect.

type GSet

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

GSet is a thread-safe, immutable set-like data structure for names (strings)

func NewGSet

func NewGSet(elems ...KV) GSet

NewGSet returns a new GSet containing the supplied elements.

func (GSet) Clone

func (s GSet) Clone() GSet

Clone returns a copy of this G set.

func (GSet) Contains

func (s GSet) Contains(net string) bool

Contains returns true if the supplied element is present in this set.

func (GSet) Difference

func (s GSet) Difference(s2 GSet) GSet

Difference returns a new G set that contains all of the elements that are present in this set and not the supplied set, without mutating either source set.

func (GSet) Equals

func (s GSet) Equals(s2 GSet) bool

Equals returns true if the supplied set contains exactly the same elements as this set (s IsSubsetOf s2 and s2 IsSubsetOf s).

func (GSet) Filter

func (s GSet) Filter(predicate func(string) bool) GSet

Filter returns a new G set that contains all of the elements from this set that match the supplied predicate, without mutating the source set.

func (GSet) FilterNot

func (s GSet) FilterNot(predicate func(string) bool) GSet

FilterNot returns a new G set that contains all of the elements from this set that do not match the supplied predicate, without mutating the source set.

func (GSet) Intersection

func (s GSet) Intersection(s2 GSet) GSet

Intersection returns a new G set that contains all of the elements that are present in both this set and the supplied set, without mutating either source set.

func (GSet) IsEmpty

func (s GSet) IsEmpty() bool

IsEmpty returns true if there are zero elements in this set.

func (GSet) IsSubsetOf

func (s GSet) IsSubsetOf(s2 GSet) bool

IsSubsetOf returns true if the supplied set contains all the elements

func (GSet) Size

func (s GSet) Size() int

Size returns the number of elements in this set.

func (GSet) String

func (s GSet) String() string

String returns a new string representation of the elements in this G set

func (GSet) ToSlice

func (s GSet) ToSlice() KVSlice

ToSlice returns a slice of KV that contains all elements from this set.

func (GSet) Union

func (s GSet) Union(s2 GSet) GSet

Union returns a new G set that contains all of the elements from this set and all of the elements from the supplied set, without mutating either source set.

type GValue

type GValue interface{}

GValue a value object associated with the set element name

type KV

type KV struct {
	Key string
	Val GValue
}

KV a key/val for GSet where the key is the set element name

type KVSlice

type KVSlice []KV

KVSlice a slice of KV

func (KVSlice) Len

func (kv KVSlice) Len() int

Len implements KVSlice's Len method for the Sort interface

func (KVSlice) Less

func (kv KVSlice) Less(i, j int) bool

Less implements KVSlice's Less method for the Sort interface

func (KVSlice) Swap

func (kv KVSlice) Swap(i, j int)

Swap implements KVSlice's Swap method for the Sort interface

Jump to

Keyboard shortcuts

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