From 91c33e1237d42215380a4fadd71915a1ca57fd49 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Thu, 9 Apr 2015 20:30:39 +0700 Subject: [PATCH] quadtree: use new constructors Signed-off-by: Jean Privat --- lib/geometry/quadtree.nit | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/lib/geometry/quadtree.nit b/lib/geometry/quadtree.nit index 97c0783..8c2df3c 100644 --- a/lib/geometry/quadtree.nit +++ b/lib/geometry/quadtree.nit @@ -29,7 +29,7 @@ import pipeline abstract class QuadTree[E: Boxed[Numeric]] super BoxedCollection[E] - protected var center: nullable Point[Numeric] + protected var center: nullable Point[Numeric] = null var data: Array[E] = new Array[E] # ________________ @@ -39,20 +39,14 @@ abstract class QuadTree[E: Boxed[Numeric]] # | 0 | 3 | # |_______|_______| - protected var child0: nullable QuadTree[E] - protected var child1: nullable QuadTree[E] - protected var child2: nullable QuadTree[E] - protected var child3: nullable QuadTree[E] + protected var child0: nullable QuadTree[E] = null + protected var child1: nullable QuadTree[E] = null + protected var child2: nullable QuadTree[E] = null + protected var child3: nullable QuadTree[E] = null # represent the threshold before subdividing the node - protected var item_limit = 4 - protected var parent_node: nullable QuadTree[E] - - # create the quadtree and set the item limit for each node - init(limit: Int) - do - self.item_limit = limit - end + protected var item_limit: Int + protected var parent_node: nullable QuadTree[E] = null # create a node, giving him self as a parent. Used to create children nodes init with_parent(limit: Int, parent: QuadTree[E]) @@ -221,17 +215,10 @@ class SQuadTree[E: Boxed[Numeric]] # the height of the current node of the QuadTree var height: Numeric - init(l: Int, c: Point[Numeric], w: Numeric, h: Numeric) - do - self.item_limit = l - self.center = c - self.width = w - self.height = h - end - init with_parent(l: Int, c: Point[Numeric], w: Numeric, h: Numeric, p: QuadTree[E]) do - init(l, c, w, h) + init(l, w, h) + center = c self.parent_node = p end -- 1.7.9.5