aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuslan Ustits <ustitsruslan@gmail.com>2024-05-29 08:57:48 +0100
committerLouis Pilfold <louis@lpil.uk>2024-05-29 10:05:30 +0100
commit6a298046764a31f9cdb12136728484e8b50209a0 (patch)
tree1c911824194b49571352fb116fe17dff7ff71ff6 /src
parentd0aec9235ee46cc89fd0917f6da1f0c77959a03c (diff)
downloadgleam_stdlib-6a298046764a31f9cdb12136728484e8b50209a0.tar.gz
gleam_stdlib-6a298046764a31f9cdb12136728484e8b50209a0.zip
Add set.is_empty
Diffstat (limited to 'src')
-rw-r--r--src/gleam/set.gleam18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/gleam/set.gleam b/src/gleam/set.gleam
index d0b4f16..12bfba1 100644
--- a/src/gleam/set.gleam
+++ b/src/gleam/set.gleam
@@ -51,6 +51,24 @@ pub fn size(set: Set(member)) -> Int {
dict.size(set.dict)
}
+/// Determines whether or not the set is empty.
+///
+/// ## Examples
+///
+/// ```gleam
+/// new() |> is_empty
+/// // -> True
+/// ```
+///
+/// ```gleam
+/// new() |> insert(1) |> is_empty
+/// // -> False
+/// ```
+///
+pub fn is_empty(set: Set(member)) -> Bool {
+ set == new()
+}
+
/// Inserts an member into the set.
///
/// This function runs in logarithmic time.