set

package
v4.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2021 License: Apache-2.0 Imports: 1 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set interface {
	Add(items ...interface{})
	Remove(items ...interface{})
	Pop() interface{}
	Has(items ...interface{}) bool
	Size() int
	Clear()
	IsEmpty() bool
	IsEqual(s Set) bool
	IsSubset(s Set) bool
	IsSuperset(s Set) bool
	Each(func(interface{}) bool)
	List() []interface{}
	Copy() Set
	Merge(s Set)
	Separate(t Set)
}

Set interface shared between Thread-Safe and Thread-Unsafe implementations

func Difference

func Difference(set1, set2 Set, sets ...Set) Set

Difference calculates the difference of two or more sets

func Intersection

func Intersection(set1, set2 Set, sets ...Set) Set

Intersection calculates the intersection of two or more sets

func SymmetricDifference

func SymmetricDifference(s Set, t Set) Set

SymmetricDifference calculates the symmetric difference of two or more sets

func Union

func Union(set1, set2 Set, sets ...Set) Set

Union calculates the union of two or more sets

type ThreadSafeSet

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

ThreadSafeSet is a thread safe implementation of the set data structure

func NewThreadSafeSet

func NewThreadSafeSet(items ...interface{}) *ThreadSafeSet

NewThreadSafeSet instantiates a new ThreadSafeSet

func (*ThreadSafeSet) Add

func (s *ThreadSafeSet) Add(items ...interface{})

Add adds a new element to the set

func (*ThreadSafeSet) Clear

func (s *ThreadSafeSet) Clear()

Clear removes all the elements in the set

func (*ThreadSafeSet) Copy

func (s *ThreadSafeSet) Copy() Set

Copy returns a copy of the this thread

func (*ThreadSafeSet) Each

func (s *ThreadSafeSet) Each(f func(item interface{}) bool)

Each executes the passed function on each item from the set

func (*ThreadSafeSet) Has

func (s *ThreadSafeSet) Has(items ...interface{}) bool

Has returns true if the element passed is in the set

func (*ThreadSafeSet) IsEmpty

func (s *ThreadSafeSet) IsEmpty() bool

IsEmpty returns true if the set has no elements

func (*ThreadSafeSet) IsEqual

func (s *ThreadSafeSet) IsEqual(t Set) bool

IsEqual returns true if the set contains the same elements as the passed one

func (*ThreadSafeSet) IsSubset

func (s *ThreadSafeSet) IsSubset(t Set) (subset bool)

IsSubset returns true if the passed set is a subset of this one

func (*ThreadSafeSet) IsSuperset

func (s *ThreadSafeSet) IsSuperset(t Set) bool

IsSuperset returns true if the passed set is a supertset of this one

func (*ThreadSafeSet) List

func (s *ThreadSafeSet) List() []interface{}

List returns a list with all the elements of the set

func (*ThreadSafeSet) Merge

func (s *ThreadSafeSet) Merge(t Set)

Merge adds all the elements of the passed set into this one

func (*ThreadSafeSet) Pop

func (s *ThreadSafeSet) Pop() interface{}

Pop removes an element from the set and returns it

func (*ThreadSafeSet) Remove

func (s *ThreadSafeSet) Remove(items ...interface{})

Remove deletes an elemenet from the set.

func (*ThreadSafeSet) Separate

func (s *ThreadSafeSet) Separate(t Set)

Separate removes all the items that are present in the passed set from this set

func (*ThreadSafeSet) Size

func (s *ThreadSafeSet) Size() int

Size returns the number of elements in the set

type ThreadUnsafeSet

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

ThreadUnsafeSet structure. Container of unique items with O(1) access time. NOT THREAD SAFE

func NewSet

func NewSet(items ...interface{}) *ThreadUnsafeSet

NewSet Constructs a new set from an optinal slice of items

func (*ThreadUnsafeSet) Add

func (s *ThreadUnsafeSet) Add(items ...interface{})

Add adds new items to the set

func (*ThreadUnsafeSet) Clear

func (s *ThreadUnsafeSet) Clear()

Clear removes all elements from the set

func (*ThreadUnsafeSet) Copy

func (s *ThreadUnsafeSet) Copy() Set

Copy returns a new set with a copy of the elements

func (*ThreadUnsafeSet) Each

func (s *ThreadUnsafeSet) Each(f func(item interface{}) bool)

Each executes a passed function on each of the items passed.

func (*ThreadUnsafeSet) Has

func (s *ThreadUnsafeSet) Has(items ...interface{}) bool

Has returns true if the items passed are present in the set

func (*ThreadUnsafeSet) IsEmpty

func (s *ThreadUnsafeSet) IsEmpty() bool

IsEmpty returns true if the set has no elements

func (*ThreadUnsafeSet) IsEqual

func (s *ThreadUnsafeSet) IsEqual(t Set) bool

IsEqual returns true if the received set is equal to this one

func (*ThreadUnsafeSet) IsSubset

func (s *ThreadUnsafeSet) IsSubset(t Set) (subset bool)

IsSubset returns true if the passed set is a subset of this one

func (*ThreadUnsafeSet) IsSuperset

func (s *ThreadUnsafeSet) IsSuperset(t Set) bool

IsSuperset returns true if the passed set is a supertset of this one

func (*ThreadUnsafeSet) List

func (s *ThreadUnsafeSet) List() []interface{}

List returns a slice of the items in th set

func (*ThreadUnsafeSet) Merge

func (s *ThreadUnsafeSet) Merge(t Set)

Merge adds all the elefements in the passed set to this one.

func (*ThreadUnsafeSet) Pop

func (s *ThreadUnsafeSet) Pop() interface{}

Pop removes an item from the set and returns it.

func (*ThreadUnsafeSet) Remove

func (s *ThreadUnsafeSet) Remove(items ...interface{})

Remove removes items from the set

func (*ThreadUnsafeSet) Separate

func (s *ThreadUnsafeSet) Separate(t Set)

Separate removes all the items that are present in the passed set from this set

func (*ThreadUnsafeSet) Size

func (s *ThreadUnsafeSet) Size() int

Size returns the size of the set

Jump to

Keyboard shortcuts

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