lib/d_heap.rb in d_heap-0.3.0 vs lib/d_heap.rb in d_heap-0.4.0
- old
+ new
@@ -12,11 +12,13 @@
# minimum. Additionally, _d_-ary heaps can have better memory cache behavior than
# binary heaps, allowing them to run more quickly in practice despite slower
# worst-case time complexity.
#
class DHeap
-
- def initialize_copy(other)
- raise NotImplementedError, "initialize_copy should deep copy array"
+ # ruby 3.0+ (2.x can just use inherited initialize_clone)
+ if Object.instance_method(:initialize_clone).arity == -1
+ def initialize_clone(other, freeze: nil)
+ __init_clone__(other, freeze ? true : freeze)
+ end
end
end