set

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set[T, H comparable] struct {
	*SimpleSet[T, H]
	// contains filtered or unexported fields
}

Set is a generic thread-safe data structure representing a unique collection of items, with synchronized access.

func New

func New[T comparable](items ...T) *Set[T, T]

func NewWithHash

func NewWithHash[T, H comparable](hashFunc func(T) H, items ...T) *Set[T, H]

func (*Set[T, H]) Append

func (s *Set[T, H]) Append(items ...T)

Append adds unique items in order to the end of the set

func (*Set[T, H]) Clear

func (s *Set[T, H]) Clear()

Clear resets the set

func (*Set[T, H]) Empty

func (s *Set[T, H]) Empty() bool

Empty checks if the set's content is 0

func (*Set[T, H]) Has

func (s *Set[T, H]) Has(item T) bool

Has checks the existance of an item in the set

func (*Set[T, H]) Items

func (s *Set[T, H]) Items() []T

Items returns a copy of the underlying item array

func (*Set[T, H]) ItemsMutable

func (s *Set[T, H]) ItemsMutable() []T

ItemsMutable returns a direct reference to the underlying item array. Use and modify at your own risk.

func (*Set[T, H]) Length

func (s *Set[T, H]) Length() int

Length returns the amount of items in the set

func (*Set[T, H]) Prepend

func (s *Set[T, H]) Prepend(items ...T)

Prepend adds unique items in order to the start of the set

func (*Set[T, H]) String

func (s *Set[T, H]) String() string

type SimpleSet

type SimpleSet[T, HashType comparable] struct {
	// contains filtered or unexported fields
}

SimpleSet is a generic data structure representing a unique collection of items. It is not thread safe, concurrent reads and writes will cause a panic. Use this version only if this is not a concern.

func NewSimpleSet

func NewSimpleSet[T comparable](items ...T) *SimpleSet[T, T]

New builds a new set object

func NewSimpleSetWithHash

func NewSimpleSetWithHash[T comparable, HashType comparable](hashFunc func(T) HashType, items ...T) *SimpleSet[T, HashType]

New builds a new set object

func (*SimpleSet[T, H]) Append

func (s *SimpleSet[T, H]) Append(items ...T)

Append adds unique items in order to the end of the set

func (*SimpleSet[T, H]) Clear

func (s *SimpleSet[T, H]) Clear()

Clear resets the set

func (*SimpleSet[T, H]) Empty

func (s *SimpleSet[T, H]) Empty() bool

Empty checks if the set's content is 0

func (*SimpleSet[T, H]) Has

func (s *SimpleSet[T, H]) Has(item T) bool

Has checks the existance of an item in the set

func (*SimpleSet[T, H]) Items

func (s *SimpleSet[T, H]) Items() []T

Items returns a copy of the underlying item array

func (*SimpleSet[T, H]) ItemsMutable

func (s *SimpleSet[T, H]) ItemsMutable() []T

ItemsMutable returns a direct reference to the underlying item array. Use and modify at your own risk.

func (*SimpleSet[T, H]) Length

func (s *SimpleSet[T, H]) Length() int

Length returns the amount of items in the set

func (*SimpleSet[T, H]) Prepend

func (s *SimpleSet[T, H]) Prepend(items ...T)

Prepend adds unique items in order to the start of the set

func (*SimpleSet[T, H]) String

func (s *SimpleSet[T, H]) String() string

Jump to

Keyboard shortcuts

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