parent
9bde9a1404
commit
80f17f9405
1 changed files with 10 additions and 0 deletions
|
|
@ -120,6 +120,11 @@ iterator items*[A](s: HashSet[A]): A =
|
||||||
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
|
||||||
|
|
||||||
|
proc hash*[A](x: HashSet[A]): Hash =
|
||||||
|
## hashing of HashSet
|
||||||
|
for item in x: result = result !& hash(item)
|
||||||
|
result = !$result
|
||||||
|
|
||||||
const
|
const
|
||||||
growthFactor = 2
|
growthFactor = 2
|
||||||
|
|
||||||
|
|
@ -690,6 +695,11 @@ iterator items*[A](s: OrderedSet[A]): A =
|
||||||
forAllOrderedPairs:
|
forAllOrderedPairs:
|
||||||
yield s.data[h].key
|
yield s.data[h].key
|
||||||
|
|
||||||
|
proc hash*[A](x: OrderedSet[A]): Hash =
|
||||||
|
## hashing of OrderedSet
|
||||||
|
for item in x: result = result !& hash(item)
|
||||||
|
result = !$result
|
||||||
|
|
||||||
iterator pairs*[A](s: OrderedSet[A]): tuple[a: int, b: A] =
|
iterator pairs*[A](s: OrderedSet[A]): tuple[a: int, b: A] =
|
||||||
assert s.isValid, "The set needs to be initialized"
|
assert s.isValid, "The set needs to be initialized"
|
||||||
forAllOrderedPairs:
|
forAllOrderedPairs:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue