* fix some warnings

* close #15767

* Revert "fix some warnings"

This reverts commit 39f2f23b0026d50c42af7be3ad80edf0f1f19610.
This commit is contained in:
flywind 2021-02-08 04:47:28 -06:00 • committed by GitHub
commit 0cf3ba159c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -241,8 +241,11 @@ iterator items*[A](s: HashSet[A]): A =
## assert a.len == 2 ## assert a.len == 2
## echo b ## echo b
## # --> {(a: 1, b: 3), (a: 0, b: 4)} ## # --> {(a: 1, b: 3), (a: 0, b: 4)}
let length = s.len
for h in 0 .. high(s.data): 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 = proc containsOrIncl*[A](s: var HashSet[A], key: A): bool =
## Includes `key` in the set `s` and tells if `key` was already in `s`. ## Includes `key` in the set `s` and tells if `key` was already in `s`.
@ -901,8 +904,10 @@ iterator items*[A](s: OrderedSet[A]): A =
## # --> Got 5 ## # --> Got 5
## # --> Got 8 ## # --> Got 8
## # --> Got 4 ## # --> Got 4
let length = s.len
forAllOrderedPairs: forAllOrderedPairs:
yield s.data[h].key 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] = iterator pairs*[A](s: OrderedSet[A]): tuple[a: int, b: A] =
## Iterates through (position, value) tuples of OrderedSet `s`. ## Iterates through (position, value) tuples of OrderedSet `s`.
@ -913,5 +918,7 @@ iterator pairs*[A](s: OrderedSet[A]): tuple[a: int, b: A] =
p.add(x) p.add(x)
assert p == @[(0, 'a'), (1, 'b'), (2, 'r'), (3, 'c'), (4, 'd')] assert p == @[(0, 'a'), (1, 'b'), (2, 'r'), (3, 'c'), (4, 'd')]
let length = s.len
forAllOrderedPairs: forAllOrderedPairs:
yield (idx, s.data[h].key) yield (idx, s.data[h].key)
assert(len(s) == length, "the length of the OrderedSet changed while iterating over it")