File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,46 @@ func main() {
42
42
43
43
## Data Structures
44
44
45
+ Certainly! Below is a README for the ` Set ` struct, following the format you provided:
46
+
47
+ ---
48
+
49
+ # Set
50
+
51
+ A set represents a collection of unique items.
52
+
53
+ ## Type
54
+
55
+ ``` go
56
+ type Set [T comparable]
57
+ ```
58
+
59
+ ## Constructor
60
+
61
+ ``` go
62
+ func New [T comparable]() *Set[T]
63
+ ```
64
+
65
+ ## Methods
66
+
67
+ - ` Add(item T) ` : Adds an item to the set.
68
+ - ` Remove(item T) ` : Removes an item from the set.
69
+ - ` Has(item T) bool ` : Returns ` true ` if the set contains the specified item.
70
+ - ` Clear() ` : Removes all items from the set.
71
+ - ` Len() int ` : Returns the number of items in the set.
72
+ - ` IsEmpty() bool ` : Returns ` true ` if the set is empty.
73
+ - ` Elements() []T ` : Returns a slice containing all items in the set.
74
+ - ` AddAll(items ...T) ` : Adds multiple items to the set.
75
+ - ` RemoveAll(items ...T) ` : Removes multiple items from the set.
76
+ - ` Diff(other *Set[T]) *Set[T] ` : Returns a new set containing items that are in the receiver set but not in the other set.
77
+ - ` Intersect(other *Set[T]) *Set[T] ` : Returns a new set containing items that are in both the receiver set and the other set.
78
+ - ` Union(other *Set[T]) *Set[T] ` : Returns a new set containing items that are in either the receiver set or the other set.
79
+ - ` IsSubset(other *Set[T]) bool ` : Returns ` true ` if the receiver set is a subset of the other set.
80
+ - ` IsSuperset(other *Set[T]) bool ` : Returns ` true ` if the receiver set is a superset of the other set.
81
+ - ` Equal(other *Set[T]) bool ` : Returns ` true ` if the receiver set is equal to the other set.
82
+
83
+ ---
84
+
45
85
### Deque
46
86
47
87
A double-ended queue (Deque) allows adding and removing elements from both the front and the back.
You can’t perform that action at this time.
0 commit comments