Documentation ¶
Index ¶
- type AdvancedSet
- func (t *AdvancedSet[T]) Add(element T) (added bool)
- func (t *AdvancedSet[T]) AddAll(elements *AdvancedSet[T]) (added bool)
- func (t *AdvancedSet[T]) Clone() (cloned *AdvancedSet[T])
- func (t *AdvancedSet[T]) Delete(element T) (deleted bool)
- func (t *AdvancedSet[T]) DeleteAll(other *AdvancedSet[T]) (removedElements *AdvancedSet[T])
- func (t *AdvancedSet[T]) Equal(other *AdvancedSet[T]) (equal bool)
- func (t *AdvancedSet[T]) Filter(predicate func(element T) bool) (filtered *AdvancedSet[T])
- func (t *AdvancedSet[T]) ForEach(callback func(element T) (err error)) (err error)
- func (t *AdvancedSet[T]) HasAll(other *AdvancedSet[T]) (hasAll bool)
- func (t *AdvancedSet[T]) Intersect(other *AdvancedSet[T]) (intersection *AdvancedSet[T])
- func (t *AdvancedSet[T]) Is(element T) bool
- func (t *AdvancedSet[T]) IsEmpty() (empty bool)
- func (t *AdvancedSet[T]) Iterator() *walker.Walker[T]
- func (t *AdvancedSet[T]) Slice() (slice []T)
- func (t *AdvancedSet[T]) String() (humanReadable string)
- type Set
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdvancedSet ¶
type AdvancedSet[T comparable] struct { orderedmap.OrderedMap[T, types.Empty] `serix:"0"` }
AdvancedSet is a set that offers advanced features.
func NewAdvancedSet ¶
func NewAdvancedSet[T comparable](elements ...T) *AdvancedSet[T]
NewAdvancedSet creates a new AdvancedSet with given elements.
func (*AdvancedSet[T]) Add ¶
func (t *AdvancedSet[T]) Add(element T) (added bool)
Add adds a new element to the Set and returns true if the element was not present in the set before.
func (*AdvancedSet[T]) AddAll ¶
func (t *AdvancedSet[T]) AddAll(elements *AdvancedSet[T]) (added bool)
AddAll adds all elements to the AdvancedSet and returns true if any element has been added.
func (*AdvancedSet[T]) Clone ¶
func (t *AdvancedSet[T]) Clone() (cloned *AdvancedSet[T])
Clone returns a new set that contains the same elements as the original set.
func (*AdvancedSet[T]) Delete ¶
func (t *AdvancedSet[T]) Delete(element T) (deleted bool)
Delete removes the element from the Set and returns true if it did exist.
func (*AdvancedSet[T]) DeleteAll ¶
func (t *AdvancedSet[T]) DeleteAll(other *AdvancedSet[T]) (removedElements *AdvancedSet[T])
DeleteAll deletes given elements from the set.
func (*AdvancedSet[T]) Equal ¶
func (t *AdvancedSet[T]) Equal(other *AdvancedSet[T]) (equal bool)
Equal returns true if both sets contain the same elements.
func (*AdvancedSet[T]) Filter ¶
func (t *AdvancedSet[T]) Filter(predicate func(element T) bool) (filtered *AdvancedSet[T])
Filter returns a new set that contains all elements that satisfy the given predicate.
func (*AdvancedSet[T]) ForEach ¶
func (t *AdvancedSet[T]) ForEach(callback func(element T) (err error)) (err error)
ForEach iterates through the set and calls the callback for every element.
func (*AdvancedSet[T]) HasAll ¶
func (t *AdvancedSet[T]) HasAll(other *AdvancedSet[T]) (hasAll bool)
HasAll returns true if all given elements are present in the set.
func (*AdvancedSet[T]) Intersect ¶
func (t *AdvancedSet[T]) Intersect(other *AdvancedSet[T]) (intersection *AdvancedSet[T])
Intersect returns a new set that contains all elements that are present in both sets.
func (*AdvancedSet[T]) Is ¶
func (t *AdvancedSet[T]) Is(element T) bool
Is returns true if the given element is the only element in the set.
func (*AdvancedSet[T]) IsEmpty ¶
func (t *AdvancedSet[T]) IsEmpty() (empty bool)
IsEmpty returns true if the set is empty.
func (*AdvancedSet[T]) Iterator ¶
func (t *AdvancedSet[T]) Iterator() *walker.Walker[T]
Iterator returns a new iterator for the set.
func (*AdvancedSet[T]) Slice ¶
func (t *AdvancedSet[T]) Slice() (slice []T)
Slice returns a slice of all elements in the set.
func (*AdvancedSet[T]) String ¶
func (t *AdvancedSet[T]) String() (humanReadable string)
Intersect returns a new set that contains all elements that are present in both sets.
type Set ¶
type Set[T comparable] interface { // Add adds a new element to the Set and returns true if the element was not present in the set before. Add(element T) bool // Delete removes the element from the Set and returns true if it did exist. Delete(element T) bool // Has returns true if the element exists in the Set. Has(element T) bool // ForEach iterates through the set and calls the callback for every element. ForEach(callback func(element T)) // Clear removes all elements from the Set. Clear() // Size returns the size of the Set. Size() int serix.Serializable serix.Deserializable }
Set is a collection of elements.
func New ¶
func New[T comparable](threadSafe ...bool) Set[T]
New returns a new Set that is thread safe if the optional threadSafe parameter is set to true.