Sha256: 211ef816910167870cd50e2a52338b4f1fa0c6436563264db6e628b10c10164a
Contents?: true
Size: 553 Bytes
Versions: 396
Compression:
Stored size: 553 Bytes
Contents
module.exports = class BinarySearchTree constructor: (@data) -> @left = undefined @right = undefined insert: (value) -> if value <= @data @insertLeft value else @insertRight value insertLeft: (value) -> if not @left @left = new BinarySearchTree value else @left.insert value insertRight: (value) -> if not @right @right = new BinarySearchTree value else @right.insert value each: (fn) -> @left.each(fn) if @left fn.call @, @data @right.each(fn) if @right
Version data entries
396 entries across 396 versions & 1 rubygems