summaryrefslogtreecommitdiff
path: root/docs/std/set.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/std/set.md')
-rw-r--r--docs/std/set.md38
1 files changed, 38 insertions, 0 deletions
diff --git a/docs/std/set.md b/docs/std/set.md
new file mode 100644
index 0000000..0d62a66
--- /dev/null
+++ b/docs/std/set.md
@@ -0,0 +1,38 @@
+# Set (`std/set.zc`)
+
+The `std/set` module provides a Generic Hash Set `Set<T>`.
+
+## Usage
+
+```zc
+import "std/set.zc"
+```
+
+## Types
+
+### Struct `Set<T>`
+
+A set of unique elements.
+
+#### Methods
+
+- **`fn new() -> Set<T>`**
+ Creates a new empty set.
+
+- **`fn add(self, val: T) -> bool`**
+ Adds a value to the set. Returns `true` if the value was added, `false` if it was already present.
+
+- **`fn contains(self, val: T) -> bool`**
+ Returns `true` if the set contains the value.
+
+- **`fn remove(self, val: T) -> bool`**
+ Removes a value from the set. Returns `true` if present and removed.
+
+- **`fn length(self) -> usize`**
+ Returns the number of elements in the set.
+
+- **`fn is_empty(self) -> bool`**
+ Returns `true` if the set is empty.
+
+- **`fn clear(self)`**
+ Removes all elements from the set.