set

package
v0.40.4 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Overview

Package set provides standard set classes and functionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unique

func Unique(strs []string) []string

Unique will return a slice of unique strings given an input slice

Types

type ByteSet

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

func NewByteSet

func NewByteSet(bytes []byte) *ByteSet

func (*ByteSet) Contains

func (bs *ByteSet) Contains(b byte) bool

func (*ByteSet) ContainsAll

func (bs *ByteSet) ContainsAll(bytes []byte) bool

type StrSet

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

StrSet is a simple set implementation providing standard set operations for strings.

func NewCaseInsensitiveStrSet

func NewCaseInsensitiveStrSet(items []string) *StrSet

func NewStrSet

func NewStrSet(items []string) *StrSet

func (*StrSet) Add

func (s *StrSet) Add(items ...string)

Add adds new items to the set

func (*StrSet) AsSlice

func (s *StrSet) AsSlice() []string

AsSlice converts the set to a slice of strings. If this is an insensitive set the resulting slice will be lowercase regardless of the case that was used when adding the string to the set.

func (*StrSet) AsSortedSlice

func (s *StrSet) AsSortedSlice() []string

AsSortedSlice converts the set to a slice of strings. If this is an insensitive set the resulting slice will be lowercase regardless of the case that was used when adding the string to the set. The slice is sorted in ascending order.

func (*StrSet) Contains

func (s *StrSet) Contains(item string) bool

Contains returns true if the item being checked is already in the set.

func (*StrSet) ContainsAll

func (s *StrSet) ContainsAll(items []string) bool

ContainsAll returns true if all the items being checked are already in the set.

func (*StrSet) Equals

func (s *StrSet) Equals(other *StrSet) bool

func (*StrSet) Iterate

func (s *StrSet) Iterate(callBack func(string) (cont bool))

Iterate accepts a callback which will be called once for each element in the set until all items have been exhausted or callback returns false.

func (*StrSet) JoinStrings

func (s *StrSet) JoinStrings(sep string) string

JoinStrings returns the sorted values from the set concatenated with a given sep

func (*StrSet) LeftIntersectionRight

func (s *StrSet) LeftIntersectionRight(other *StrSet) (left *StrSet, intersection *StrSet, right *StrSet)

LeftIntersectionRight takes a slice of strings and returns a slice of strings containing the intersection with the set, and a slice of strings for the ones missing from the set.

func (*StrSet) Remove

func (s *StrSet) Remove(items ...string)

Remove removes existing items from the set

func (*StrSet) Size

func (s *StrSet) Size() int

Size returns the number of unique elements in the set

type Uint64Set

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

func NewUint64Set

func NewUint64Set(uints []uint64) *Uint64Set

func (*Uint64Set) Add

func (us *Uint64Set) Add(vals ...uint64)

func (*Uint64Set) AsSlice

func (us *Uint64Set) AsSlice() []uint64

func (*Uint64Set) Contains

func (us *Uint64Set) Contains(i uint64) bool

func (*Uint64Set) ContainsAll

func (us *Uint64Set) ContainsAll(uints []uint64) bool

func (*Uint64Set) Intersection

func (us *Uint64Set) Intersection(other *Uint64Set) *Uint64Set

func (*Uint64Set) Iter

func (us *Uint64Set) Iter(fn func(uint64))

func (*Uint64Set) Remove

func (us *Uint64Set) Remove(i uint64)

func (*Uint64Set) Size

func (us *Uint64Set) Size() int

Jump to

Keyboard shortcuts

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