Skip to content

Commit

Permalink
Add a regular items iterator to support for key in tab.
Browse files Browse the repository at this point in the history
  • Loading branch information
c-blake committed Oct 30, 2023
1 parent 7ef9ba6 commit 1a8202a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions adix/oats.nim
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ proc incl*[K,V,H,U](s: var Oat[K,V,H,U], key: K) =
s.getPut(i, key, hc): discard
do: echo "initialize cell ",i #XXX impl

iterator items*[K,V,H,U](s: Oat[K,V,H,U]): K =
for i in 0 ..< s.getCap: (if s.used(i): yield s.key(i))

iterator pairs*[K,V,H,U](s: Oat[K,V,H,U]): (K, V) =
when V is Void: {.error: "`pairs` called when V == Void".}
for i in 0 ..< s.getCap: (if s.used(i): yield (s.key(i), s.val(i)))
Expand Down

0 comments on commit 1a8202a

Please sign in to comment.