Class: KdTree::Tree
- Inherits:
-
Object
- Object
- KdTree::Tree
- Includes:
- DataConversion, Dimensions, Finders
- Defined in:
- lib/ffi-kdtree/tree.rb
Constant Summary
Constants included from Dimensions
Dimensions::DIMENSIONAL_ARRAY_CLASSES
Instance Attribute Summary collapse
-
#tree ⇒ Object
readonly
Returns the value of attribute tree.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #add(position, value) ⇒ Object
-
#initialize(size, type = :object) ⇒ Tree
constructor
A new instance of Tree.
Methods included from Finders
#find_nearest, #find_nearest_range
Methods included from Dimensions
#build_position, #dimensions, #distance, #distance_sq, #new_position
Constructor Details
#initialize(size, type = :object) ⇒ Tree
Returns a new instance of Tree.
14 15 16 17 18 19 20 |
# File 'lib/ffi-kdtree/tree.rb', line 14 def initialize(size, type = :object) tree_ptr = FFI::AutoPointer.new( LibKdTree::kd_create(size), PointerHelpers::TreePointerHelper.method(:release)) @tree = LibKdTree::Tree.new(tree_ptr) @type = type end |
Instance Attribute Details
#tree ⇒ Object (readonly)
Returns the value of attribute tree.
8 9 10 |
# File 'lib/ffi-kdtree/tree.rb', line 8 def tree @tree end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/ffi-kdtree/tree.rb', line 8 def type @type end |
Instance Method Details
#add(position, value) ⇒ Object
22 23 24 25 |
# File 'lib/ffi-kdtree/tree.rb', line 22 def add(position, value) position = build_position(position) unless FFI::Struct === position 0 == LibKdTree::kd_insert(self.tree, position, data_from_value(value)) end |