Skip to content

Commit

Permalink
Rename 'has()' -> 'contains()'
Browse files Browse the repository at this point in the history
  • Loading branch information
rvanasa committed Dec 6, 2023
1 parent 36f9f95 commit 59c73dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/TrieSet.mo
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ module {
return true;
};

/// @deprecated: use `TrieSet.has()`
/// @deprecated: use `TrieSet.contains()`
///
/// Test if a set contains a given element.
public func mem<T>(s : Set<T>, x : T, xh : Hash, eq : (T, T) -> Bool) : Bool {
has(s, x, xh, eq)
contains(s, x, xh, eq)
};

/// Test if a set contains a given element.
public func has<T>(s : Set<T>, x : T, xh : Hash, eq : (T, T) -> Bool) : Bool {
public func contains<T>(s : Set<T>, x : T, xh : Hash, eq : (T, T) -> Bool) : Bool {
switch (Trie.find<T, ()>(s, { key = x; hash = xh }, eq)) {
case null { false };
case (?_) { true }
Expand Down
9 changes: 7 additions & 2 deletions test/TrieSet.test.mo
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ let simpleTests = do {
"TrieSet fromArray",
[
Suite.test(
"has",
TrieSet.has<Nat>(set1, 1, 1, Nat.equal),
"mem",
TrieSet.mem<Nat>(set1, 1, 1, Nat.equal),
M.equals(T.bool true)
),
Suite.test(
"contains",
TrieSet.contains<Nat>(set1, 1, 1, Nat.equal),
M.equals(T.bool true)
),
Suite.test(
Expand Down

0 comments on commit 59c73dc

Please sign in to comment.