From 65c607d9fcf06da27d0cf872712e3bc7b9b9a0da Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Sun, 12 Jan 2020 15:22:39 +0100 Subject: [PATCH] #to_h can also be reversed or be provided offsets. --- src/dodb.cr | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dodb.cr b/src/dodb.cr index 7014ba1..8efb3ab 100644 --- a/src/dodb.cr +++ b/src/dodb.cr @@ -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