Method: Containers::KDTree#initialize
- Defined in:
- lib/containers/kd_tree.rb
#initialize(points) ⇒ KDTree
Points is a hash of id => [coord, coord] pairs.
30 31 32 33 34 35 |
# File 'lib/containers/kd_tree.rb', line 30 def initialize(points) raise "must pass in a hash" unless points.kind_of?(Hash) @dimensions = points[ points.keys.first ].size @root = build_tree(points.to_a) @nearest = [] end |