MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / New

Function New

structure/set/set.go:7–15  ·  view source on GitHub ↗

New gives new set.

(items ...T)

Source from the content-addressed store, hash-verified

5
6// New gives new set.
7func New[T comparable](items ...T) Set[T] {
8 st := set[T]{
9 elements: make(map[T]bool),
10 }
11 for _, item := range items {
12 st.Add(item)
13 }
14 return &st
15}
16
17// Set is an interface of possible methods on 'set'.
18type Set[T comparable] interface {

Callers 12

ExampleSetFunction · 0.70
TestNewFunction · 0.70
TestAddFunction · 0.70
TestDeleteFunction · 0.70
TestIsSubsetOfFunction · 0.70
TestIsProperSubsetOfFunction · 0.70
TestIsSupersetOfFunction · 0.70
TestIsProperSupersetOfFunction · 0.70
TestUnionFunction · 0.70
TestIntersectionFunction · 0.70
TestDifferenceFunction · 0.70
TestSymmetricDifferenceFunction · 0.70

Calls 1

AddMethod · 0.95

Tested by 12

ExampleSetFunction · 0.56
TestNewFunction · 0.56
TestAddFunction · 0.56
TestDeleteFunction · 0.56
TestIsSubsetOfFunction · 0.56
TestIsProperSubsetOfFunction · 0.56
TestIsSupersetOfFunction · 0.56
TestIsProperSupersetOfFunction · 0.56
TestUnionFunction · 0.56
TestIntersectionFunction · 0.56
TestDifferenceFunction · 0.56
TestSymmetricDifferenceFunction · 0.56