Skip to content

Commit

Permalink
remove includes
Browse files Browse the repository at this point in the history
  • Loading branch information
chenkovsky committed Mar 27, 2018
1 parent 6547954 commit bd8773c
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions src/preshed.cr
Expand Up @@ -28,14 +28,7 @@ module Preshed
initial_size = Math.pw2ceil(initial_size)
@capacity = initial_size.to_u64
@size = 0_u64
@cells = Pointer(Cell(V)).malloc(@capacity)
(0...@capacity).each do |i|
@cells[i] = Cell(V).new(EMPTY_KEY, @default)
end
end

def include?(key : UInt64)
!self[key]?.nil?
@cells = Pointer(Cell(V)).malloc(@capacity, Cell(V).new(EMPTY_KEY, @default))
end

def []=(key : UInt64, val : V)
Expand Down Expand Up @@ -87,26 +80,6 @@ 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 bd8773c

Please sign in to comment.