set

package module
v0.0.0-...-3ac7503 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

README

set

Generic set implementation for Go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OrderedSet

type OrderedSet[T comparable] struct {
	Elems []T        `json:"set_elems"`
	EMap  map[T]bool `json:"set_e_map"`
}

func NewOrdered

func NewOrdered[T comparable](elems ...T) *OrderedSet[T]

func (*OrderedSet[T]) Add

func (s *OrderedSet[T]) Add(elems ...T)

Add one or more elements to the set

func (*OrderedSet[T]) Contains

func (s *OrderedSet[T]) Contains(e T) bool

func (*OrderedSet[T]) Count

func (s *OrderedSet[T]) Count() int

Count returns the number of elements in the set

func (*OrderedSet[T]) Diff

func (s *OrderedSet[T]) Diff(other *OrderedSet[T]) *OrderedSet[T]

Diff returns a new set with elements in this set, but not in the other set

func (*OrderedSet[T]) Intersection

func (s *OrderedSet[T]) Intersection(other *OrderedSet[T]) *OrderedSet[T]

Intersection returns a new set that has common elements present in both sets

func (*OrderedSet[T]) IsEmpty

func (s *OrderedSet[T]) IsEmpty() bool

func (*OrderedSet[T]) IsEqual

func (s *OrderedSet[T]) IsEqual(other *OrderedSet[T]) bool

Equals returns true if every element is same between this and the other set, and in the same order

func (*OrderedSet[T]) Remove

func (s *OrderedSet[T]) Remove(elems ...T)

Remove the given elements from the current set

func (OrderedSet[T]) String

func (s OrderedSet[T]) String() string

func (*OrderedSet[T]) ToList

func (s *OrderedSet[T]) ToList() []T

func (*OrderedSet[T]) Union

func (s *OrderedSet[T]) Union(other *OrderedSet[T]) *OrderedSet[T]

Union returns a new set that has all elements from both sets

type Set

type Set[T comparable] struct {
	EMap map[T]bool `json:"set_e_map"`
}

func New

func New[T comparable](elems ...T) *Set[T]

func (*Set[T]) Add

func (s *Set[T]) Add(elems ...T)

Add one or more elements to the set

func (*Set[T]) Contains

func (s *Set[T]) Contains(e T) bool

func (*Set[T]) Count

func (s *Set[T]) Count() int

Count returns the number of elements in the set

func (*Set[T]) Diff

func (s *Set[T]) Diff(other *Set[T]) *Set[T]

Diff returns a new set with elements in this set, but not in the other set

func (*Set[T]) Intersection

func (s *Set[T]) Intersection(other *Set[T]) *Set[T]

Intersection returns a new set that has common elements present in both sets

func (*Set[T]) IsEmpty

func (s *Set[T]) IsEmpty() bool

func (*Set[T]) IsEqual

func (s *Set[T]) IsEqual(other *Set[T]) bool

Equals returns true if every element is same between this and the other set

func (*Set[T]) Remove

func (s *Set[T]) Remove(elems ...T)

Remove the given elements from the current set

func (Set[T]) String

func (s Set[T]) String() string

func (*Set[T]) ToList

func (s *Set[T]) ToList() []T

func (*Set[T]) Union

func (s *Set[T]) Union(other *Set[T]) *Set[T]

Union returns a new set that has all elements from both sets

Jump to

Keyboard shortcuts

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