class Hamster::SortedSet::PlainAVLNode
in their natural order
AVL node which does not use a comparator function; it keeps items sorted
@private
def self.from_items(items, from = 0, to = items.size-1) # items must be sorted
def self.from_items(items, from = 0, to = items.size-1) # items must be sorted size = to - from + 1 if size >= 3 middle = (to + from) / 2 PlainAVLNode.new(items[middle], PlainAVLNode.from_items(items, from, middle-1), PlainAVLNode.from_items(items, middle+1, to)) elsif size == 2 PlainAVLNode.new(items[from], PlainAVLNode::EmptyNode, PlainAVLNode.new(items[from+1], PlainAVLNode::EmptyNode, PlainAVLNode::EmptyNode)) elsif size == 1 PlainAVLNode.new(items[from], PlainAVLNode::EmptyNode, PlainAVLNode::EmptyNode) elsif size == 0 PlainAVLNode::EmptyNode end end
def clear
def clear PlainAVLNode::EmptyNode end
def derive(item, left, right)
def derive(item, left, right) PlainAVLNode.new(item, left, right) end
def direction(item)
def direction(item) item <=> @item end
def from_items(items)
def from_items(items) PlainAVLNode.from_items(items.sort) end
def initialize(item, left, right)
def initialize(item, left, right) @item, @left, @right = item, left, right @height = ((right.height > left.height) ? right.height : left.height) + 1 @size = right.size + left.size + 1 end
def natural_order?
def natural_order? true end