Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* fix some warnings

* close nim-lang#15767

* Revert "fix some warnings"

This reverts commit 39f2f23.
  • Loading branch information
ringabout authored and ardek66 committed Mar 26, 2021
1 parent 099308d commit 594b198
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/pure/collections/sets.nim
Expand Up @@ -241,8 +241,11 @@ iterator items*[A](s: HashSet[A]): A =
## assert a.len == 2
## echo b
## # --> {(a: 1, b: 3), (a: 0, b: 4)}
let length = s.len
for h in 0 .. high(s.data):
if isFilled(s.data[h].hcode): yield s.data[h].key
if isFilled(s.data[h].hcode):
yield s.data[h].key
assert(len(s) == length, "the length of the HashSet changed while iterating over it")

proc containsOrIncl*[A](s: var HashSet[A], key: A): bool =
## Includes `key` in the set `s` and tells if `key` was already in `s`.
Expand Down Expand Up @@ -901,8 +904,10 @@ iterator items*[A](s: OrderedSet[A]): A =
## # --> Got 5
## # --> Got 8
## # --> Got 4
let length = s.len
forAllOrderedPairs:
yield s.data[h].key
assert(len(s) == length, "the length of the OrderedSet changed while iterating over it")

iterator pairs*[A](s: OrderedSet[A]): tuple[a: int, b: A] =
## Iterates through (position, value) tuples of OrderedSet `s`.
Expand All @@ -913,5 +918,7 @@ iterator pairs*[A](s: OrderedSet[A]): tuple[a: int, b: A] =
p.add(x)
assert p == @[(0, 'a'), (1, 'b'), (2, 'r'), (3, 'c'), (4, 'd')]

let length = s.len
forAllOrderedPairs:
yield (idx, s.data[h].key)
assert(len(s) == length, "the length of the OrderedSet changed while iterating over it")

0 comments on commit 594b198

Please sign in to comment.