Compare commits
5 commits
1392b07894
...
7799ec70ac
Author | SHA1 | Date | |
---|---|---|---|
Bruno BELANYI | 7799ec70ac | ||
Bruno BELANYI | 8acb675b16 | ||
Bruno BELANYI | 74d4aa87e6 | ||
Bruno BELANYI | a12642a9bd | ||
Bruno BELANYI | e3a3930ff3 |
|
@ -72,13 +72,6 @@ class KdLeafNode[T]:
|
|||
|
||||
def __init__(self):
|
||||
self.points = {}
|
||||
|
||||
# Convenience constructor used when splitting a node
|
||||
@classmethod
|
||||
def from_items(cls, items: Iterable[tuple[Point, T]]) -> KdLeafNode[T]:
|
||||
res = cls()
|
||||
res.points.update(items)
|
||||
return res
|
||||
```
|
||||
|
||||
#### Split node
|
||||
|
@ -117,6 +110,13 @@ class KdNode[T]:
|
|||
def __init__(self):
|
||||
self.inner = KdLeafNode()
|
||||
|
||||
# Convenience constructor used when splitting a node
|
||||
@classmethod
|
||||
def from_items(cls, items: Iterable[tuple[Point, T]]) -> KdNode[T]:
|
||||
res = cls()
|
||||
res.inner.points.update(items)
|
||||
return res
|
||||
|
||||
class KdTree[T]:
|
||||
_root: KdNode[T]
|
||||
|
||||
|
@ -165,7 +165,7 @@ def split_leaf[T](node: KdLeafNode[T], axis: Axis) -> KdSplitNode[T]:
|
|||
return KdSplitNode(
|
||||
split_axis,
|
||||
mid,
|
||||
(KdLeafNode.from_items(left), KdLeafNode.from_items(right)),
|
||||
(KdNode.from_items(left), KdNode.from_items(right)),
|
||||
)
|
||||
|
||||
class KdTree[T]:
|
||||
|
|
Loading…
Reference in a new issue