sets

package
v0.18.1 Latest Latest
Warning

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

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

Documentation

Overview

Package sets contains set data structures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hash added in v0.18.0

type Hash[T comparable] struct {
	// contains filtered or unexported fields
}

A Hash is a set implemented via a map.

func NewHash added in v0.18.0

func NewHash[T comparable]() *Hash[T]

NewHash creates a new Hash set.

func (*Hash[T]) Add added in v0.18.0

func (s *Hash[T]) Add(elements ...T)

Add adds a value to the set.

func (*Hash[T]) Has added in v0.18.0

func (s *Hash[T]) Has(element T) bool

Has returns true if the element is in the set.

func (*Hash[T]) Size added in v0.18.0

func (s *Hash[T]) Size() int

Size returns the size of the set.

type SizeLimitedStringSet

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

A SizeLimitedStringSet is a StringSet which is limited to a given size. Once the capacity is reached an element will be removed at random.

func NewSizeLimitedStringSet

func NewSizeLimitedStringSet(capacity int) *SizeLimitedStringSet

NewSizeLimitedStringSet create a new SizeLimitedStringSet.

func (*SizeLimitedStringSet) Add

func (s *SizeLimitedStringSet) Add(element string)

Add adds an element to the set.

func (*SizeLimitedStringSet) ForEach

func (s *SizeLimitedStringSet) ForEach(callback func(element string) bool)

ForEach iterates over all the elements in the set.

type SortedString

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

A SortedString is a set of strings with sorted iteration.

func NewSortedString

func NewSortedString() *SortedString

NewSortedString creates a new sorted string set.

func (*SortedString) Add

func (s *SortedString) Add(elements ...string)

Add adds a string to the set.

func (*SortedString) Clear

func (s *SortedString) Clear()

Clear clears the set.

func (*SortedString) Delete

func (s *SortedString) Delete(element string)

Delete deletes an element from the set.

func (*SortedString) ForEach

func (s *SortedString) ForEach(callback func(element string) bool)

ForEach iterates over the set in ascending order.

func (*SortedString) Has

func (s *SortedString) Has(element string) bool

Has returns true if the elment is in the set.

func (*SortedString) Size

func (s *SortedString) Size() int

Size returns the size of the set.

func (*SortedString) ToSlice

func (s *SortedString) ToSlice() []string

ToSlice returns a slice of all the elements in the set.

Jump to

Keyboard shortcuts

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