Skip to content
This repository was archived by the owner on Apr 5, 2025. It is now read-only.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Reference Go Report Card

Retired in favour of github.com/deckarep/golang-set/v2

set

import "github.com/bruceesmith/set"

Package set is based on public code from John Arundel, goroutine safety added. It defines goroutine-safe methods for manipulating a generic set data structure via the standard operations Add, Contains, Intersection, Members, String and Union

Index

type Set

Set is a generics implementation of the set data type

type Set[E comparable] struct {
    // contains filtered or unexported fields
}

func New

func New[E comparable](vals ...E) *Set[E]

New creates a new Set

func (*Set[E]) Add

func (s *Set[E]) Add(vals ...E)

Add puts a new value into a Set

func (*Set[E]) Clear

func (s *Set[E]) Clear()

Clear removes all values from a Set

func (*Set[E]) Contains

func (s *Set[E]) Contains(v E) bool

Contains checks if a value is in the Set

func (*Set[E]) Delete

func (s *Set[E]) Delete(vals ...E)

Delete remove values(s) from a Set

func (*Set[E]) Difference

func (s *Set[E]) Difference(s2 *Set[E]) *Set[E]

Difference returns the set of values that are in s (set A) but not in s2 (set B) ... i.e. A - B

func (*Set[E]) Disjoint

func (s *Set[E]) Disjoint(s2 *Set[E]) bool

Disjoint returns true if the intersection of s with another set s2 is empty

func (*Set[E]) Empty

func (s *Set[E]) Empty() bool

Empty returns true if the Set is empty

func (*Set[E]) Intersection

func (s *Set[E]) Intersection(s2 *Set[E]) *Set[E]

Intersection returns the logical intersection of 2 Sets

func (*Set[E]) Members

func (s *Set[E]) Members() []E

Members returns a slice of the values in a Set

func (*Set[E]) Size

func (s *Set[E]) Size() int

Size returns the number of values in a Set

func (*Set[E]) String

func (s *Set[E]) String() string

String returns a string representation of the Set members

func (*Set[E]) Union

func (s *Set[E]) Union(s2 *Set[E]) *Set[E]

Union returns the logical union of 2 Sets

Generated by gomarkdoc

About

Package set defines goroutine-safe methods for manipulating a generic set data structure

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages