nontree.TreeMap
The TreeMap contains a NonTree (or QuadTree, BiTree) and maps its points to payload data.
A single point can map to multiple data objects.
The TreeMap provides methods to make use of the underlying NonTree (or QuadTree, BiTree).
It also provides a dict-ish interface.
Parameters
- rect: A rectangle in the shape of (x, y, width, height).
- lvl: Maximum nesting depth. None for automatic heuristic value. >= 0
- bucket: Maximum number of points in a tree, before it is split into subtrees. >= 1
- mode: Number of subtrees a tree is split into. 9: NonTree, 4: QuadTree, 2: BiTree
- initial_dict: A dict with points (x, y) as keys and lists of objects as values for initial filling.
Raises
- ValueError: If lvl, bucket, mode is out of bounds.
Gets payload data of all points that are within a rectangle.
Parameters
- rect: A rectangle in shape of (x, y, width, height).
Returns
A list of objects.
Gets payload data of all points that are within a circle.
Parameters
- circ: A circle in the shape of (x, y, radius).
Returns
A list of objects.
Gets payload data of point if it is in the tree.
Parameters
- point: A point in the shape of (x, y).
Returns
A list of objects.
Tests if there are points within a rectangle.
Parameters
- rect: A rectangle in shape of (x, y, width, height).
Returns
True if there are points within the rectangle, False if not.
Tests if there are points within a circle.
Parameters
- circ: A circle in the shape of (x, y, radius).
Returns
True if there are points within the circle, False if not.
Tests if point is in the tree.
Parameters
- point: A point in the shape of (x, y).
Returns
True if point is in the tree, False if not.
Deletes points within a rectangle.
Parameters
- rect: A rectangle in shape of (x, y, width, height).
Returns
True if there have been points to delete, False if not.
Deletes points within a circle.
Parameters
- circ: A circle in the shape of (x, y, radius).
Returns
True if there have been points to delete, False if not.
Deletes a point from the tree.
Parameters
- point: A point in the shape of (x, y).
Returns
True if there has been a point to delete, False if not.
Pops a point from the tree and returns its payload data.
Parameters
- point: A point in the shape of (x, y).
- default: Optional default value if point is not in tree.
Returns
A list of objects.
Raises
- KeyError: If point is not in the tree, and no default is given.
Adds payload data to a point in the tree. Also adds the point itself to the tree, if not yet existing.
Parameters
- point: A point in the shape of (x, y).
- value: An object.
Adds points with payload data to the tree.
Parameters
- datapoints: An iterable of datapoints in the shape of ((x, y), value).
Extends this tree with points and payload data from a dictionary.
Parameters
- extend_dict: A dict with points (x, y) as keys and lists of objects as values.
Discards a payload value from a point in the tree. Also deletes the point if it has no payload values left.
Parameters
- point: A point in the shape of (x, y).
- value: An object.
Discards datapoints from the tree.
Parameters
- datapoints: An iterable of datapoints in the shape of ((x, y), value).
Inherited Members
- collections.abc.MutableMapping
- pop
- popitem
- update
- setdefault
- collections.abc.Mapping
- get
- items
- values