#to_h can also be reversed or be provided offsets.

remotes/1708105384931250775/master
Luka Vandervelden 2020-01-12 15:22:39 +01:00
parent 011348b33a
commit 65c607d9fc
1 changed files with 6 additions and 2 deletions

View File

@ -250,10 +250,14 @@ class DODB::DataBase(V)
##
# CAUTION: Very slow. Try not to use.
def to_h
def to_h(reversed : Bool = false, start_offset = 0, end_offset : Int32? = nil)
hash = ::Hash(Int32, V).new
each_with_index do |element, index|
each_with_index(
reversed: reversed,
start_offset: start_offset,
end_offset: end_offset
) do |element, index|
hash[index] = element
end