@@ -24,6 +24,12 @@ A thread-safe array with a fixed size.
24
24
- ` NewArray(size int) *Array[T] ` - Creates a new thread-safe array with the given size.
25
25
- ` (*Array[T]) Get(index int) (T, bool) ` - Retrieves the value at the given index.
26
26
- ` (*Array[T]) Set(index int, value T) bool ` - Sets the value at the given index.
27
+ - ` (*Array[T]) Append(value T) ` - Appends a value to the array.
28
+ - ` (*Array[T]) Remove(index int) bool ` - Removes the element at the given index.
29
+ - ` (*Array[T]) Contains(value T) bool ` - Checks if the array contains the specified value.
30
+ - ` (*Array[T]) Clear() ` - Clears all elements from the array.
31
+ - ` (*Array[T]) Insert(index int, value T) bool ` - Inserts a value at the specified index.
32
+ - ` (*Array[T]) Copy() *Array[T] ` - Returns a copy of the array.
27
33
- ` (*Array[T]) Length() int ` - Returns the length of the array.
28
34
29
35
#### Example
@@ -63,6 +69,12 @@ A dynamically-sized, thread-safe slice.
63
69
- ` (*Slice[T]) Append(value T) ` - Appends a value to the slice.
64
70
- ` (*Slice[T]) Get(index int) (T, bool) ` - Retrieves the value at the given index.
65
71
- ` (*Slice[T]) Set(index int, value T) bool ` - Sets the value at the given index.
72
+ - ` (*Slice[T]) Remove(index int) bool ` - Removes the element at the given index.
73
+ - ` (*Slice[T]) Contains(value T) bool ` - Checks if the slice contains the specified value.
74
+ - ` (*Slice[T]) Clear() ` - Clears all elements from the slice.
75
+ - ` (*Slice[T]) Insert(index int, value T) bool ` - Inserts a value at the specified index.
76
+ - ` (*Slice[T]) Copy() *Slice[T] ` - Returns a copy of the slice.
77
+ - ` (*Slice[T]) Values() []T ` - Returns a slice of all values present in the slice.
66
78
- ` (*Slice[T]) Length() int ` - Returns the length of the slice.
67
79
68
80
#### Example
@@ -113,6 +125,9 @@ A thread-safe map for storing key-value pairs.
113
125
- ` (*Map[K, V]) Get(key K) (V, bool) ` - Retrieves the value associated with the key.
114
126
- ` (*Map[K, V]) Set(key K, value V) ` - Sets the value for the given key.
115
127
- ` (*Map[K, V]) Delete(key K) ` - Deletes the value associated with the key.
128
+ - ` (*Map[K, V]) Contains(key K) bool ` - Checks if the map contains the specified key.
129
+ - ` (*Map[K, V]) Clear() ` - Clears all key-value pairs from the map.
130
+ - ` (*Map[K, V]) Copy() *Map[K, V] ` - Returns a copy of the map.
116
131
- ` (*Map[K, V]) Length() int ` - Returns the number of key-value pairs in the map.
117
132
- ` (*Map[K, V]) Keys() []K ` - Returns a slice of all keys present in the map.
118
133
- ` (*Map[K, V]) Values() []V ` - Returns a slice of all values present in the map.
@@ -171,14 +186,18 @@ func main() {
171
186
172
187
A thread-safe stack for safely adding and removing items.
173
188
174
- ### Methods
189
+ #### APIs
175
190
176
- - ` NewStack() *Stack ` : Creates a new thread-safe stack.
177
- - ` Push(value interface{}) ` : Adds an element to the stack.
178
- - ` Pop() (interface{}, bool) ` : Removes and returns an element from the stack. Returns ` false ` if the stack is empty.
179
- - ` Len() int ` : Returns the number of elements in the stack.
191
+ - ` NewStack() *Stack ` - Creates a new thread-safe stack.
192
+ - ` (*Stack) Push(value interface{}) ` - Adds an element to the stack.
193
+ - ` (*Stack) Pop() (interface{}, bool) ` - Removes and returns an element from the stack. Returns ` false ` if the stack is empty.
194
+ - ` (*Stack) Peek() (interface{}, bool) ` - Returns the element at the top of the stack without removing it.
195
+ - ` (*Stack) IsEmpty() bool ` - Checks if the stack is empty.
196
+ - ` (*Stack) Clear() ` - Clears all elements from the stack.
197
+ - ` (*Stack) Values() []interface{} ` - Returns a slice of all elements in the stack.
198
+ - ` (*Stack) Len() int ` - Returns the number of elements in the stack.
180
199
181
- ### Example
200
+ #### Example
182
201
183
202
``` go
184
203
package main
@@ -213,12 +232,16 @@ func main() {
213
232
214
233
A thread-safe queue for safely adding and removing items.
215
234
216
- #### Methods
235
+ #### APIs
217
236
218
- - ` NewQueue() *Queue ` : Creates a new thread-safe queue.
219
- - ` Enqueue(value interface{}) ` : Adds an element to the queue.
220
- - ` Dequeue() (interface{}, bool) ` : Removes and returns an element from the queue. Returns ` false ` if the queue is empty.
221
- - ` Len() int ` : Returns the number of elements in the queue.
237
+ - ` NewQueue() *Queue ` - Creates a new thread-safe queue.
238
+ - ` (*Queue) Enqueue(value interface{}) ` - Adds an element to the queue.
239
+ - ` (*Queue) Dequeue() (interface{}, bool) ` - Removes and returns an element from the queue. Returns ` false ` if the queue is empty.
240
+ - ` (*Queue) Peek() (interface{}, bool) ` - Returns the element at the front of the queue without removing it.
241
+ - ` (*Queue) IsEmpty() bool ` - Checks if the queue is empty.
242
+ - ` (*Queue) Clear() ` - Clears all elements from the queue.
243
+ - ` (*Queue) Values() []interface{} ` - Returns a slice of all elements in the queue.
244
+ - ` (*Queue) Len() int ` - Returns the number of elements in the queue.
222
245
223
246
#### Queue Example
224
247
0 commit comments