class RnDB::Slice
Public Class Methods
new(min, max)
click to toggle source
A range that knows how to sort and intersect itself, private to Thickets.
Calls superclass method
# File lib/rndb/slice.rb, line 6 def initialize(min, max) super(min.to_i, max.to_i) end
Public Instance Methods
&(other)
click to toggle source
We need to intersect slices when processing query constraints.
# File lib/rndb/slice.rb, line 21 def &(other) return nil if min > other.max || max < other.min self.class.new([min, other.min].max, [max, other.max].min) end
<=>(other)
click to toggle source
Because Slices in a Thicket
are disjoint, we can sort by min or max.
# File lib/rndb/slice.rb, line 16 def <=>(other) min <=> other.min end
count()
click to toggle source
Just in case the Range implementation is inefficient.
# File lib/rndb/slice.rb, line 11 def count max - min + 1 end