MCPcopy
hub / github.com/TheAlgorithms/Go / Set

Interface Set

structure/set/set.go:18–51  ·  view source on GitHub ↗

Set is an interface of possible methods on 'set'.

Source from the content-addressed store, hash-verified

16
17// Set is an interface of possible methods on 'set'.
18type Set[T comparable] interface {
19 // Add: adds new element to the set
20 Add(item T)
21 // Delete: deletes the passed element from the set if present
22 Delete(item T)
23 // Len: gives the length of the set (total no. of elements in set)
24 Len() int
25 // GetItems: gives the array( []T ) of elements of the set.
26 GetItems() []T
27 // In: checks whether item is present in set or not.
28 In(item T) bool
29 // IsSubsetOf: checks whether set is subset of set2 or not.
30 IsSubsetOf(set2 Set[T]) bool
31 // IsProperSubsetOf: checks whether set is proper subset of set2 or not.
32 // ex: [1,2,3] proper subset of [1,2,3,4] -> true
33 IsProperSubsetOf(set2 Set[T]) bool
34 // IsSupersetOf: checks whether set is superset of set2 or not.
35 IsSupersetOf(set2 Set[T]) bool
36 // IsProperSupersetOf: checks whether set is proper superset of set2 or not.
37 // ex: [1,2,3,4] proper superset of [1,2,3] -> true
38 IsProperSupersetOf(set2 Set[T]) bool
39 // Union: gives new union set of both sets.
40 // ex: [1,2,3] union [3,4,5] -> [1,2,3,4,5]
41 Union(set2 Set[T]) Set[T]
42 // Intersection: gives new intersection set of both sets.
43 // ex: [1,2,3] Intersection [3,4,5] -> [3]
44 Intersection(set2 Set[T]) Set[T]
45 // Difference: gives new difference set of both sets.
46 // ex: [1,2,3] Difference [3,4,5] -> [1,2]
47 Difference(set2 Set[T]) Set[T]
48 // SymmetricDifference: gives new symmetric difference set of both sets.
49 // ex: [1,2,3] SymmetricDifference [3,4,5] -> [1,2,4,5]
50 SymmetricDifference(set2 Set[T]) Set[T]
51}
52
53type set[T comparable] struct {
54 elements map[T]bool

Callers 44

FuzzRot13Function · 0.65
FuzzPolybiusFunction · 0.65
TestDSAFunction · 0.65
SignFunction · 0.65
FuzzTranspositionFunction · 0.65
FuzzCaesarFunction · 0.65
FuzzRsaFunction · 0.65
TestDeleteFunction · 0.65
JosephusProblemFunction · 0.65
TestDeleteFunction · 0.65
increaseFreqMethod · 0.65

Calls

no outgoing calls

Tested by

no test coverage detected