Skip to content

Commit

Permalink
add keys values
Browse files Browse the repository at this point in the history
  • Loading branch information
chenkovsky committed Mar 26, 2018
1 parent b57325f commit 6547954
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/preshed.cr
Expand Up @@ -87,6 +87,26 @@ module Preshed
end
end

def keys
arr = Array(UInt64).new
(0...@capacity).each do |i|
if (@cells + i).value.key != EMPTY_KEY
arr << (@cells + i).value.key
end
end
return arr
end

def values
arr = Array(V).new
(0...@capacity).each do |i|
if (@cells + i).value.key != EMPTY_KEY
arr << (@cells + i).value.value
end
end
return arr
end

private def resize
new_capacity = @capacity * 2
cells = Pointer(Cell(V)).malloc(new_capacity, Cell(V).new(EMPTY_KEY, @default))
Expand Down

0 comments on commit 6547954

Please sign in to comment.