MCPcopy Index your code
hub / github.com/OmkarPathak/pygorithm / insert_and_think

Method insert_and_think

pygorithm/data_structures/quadtree.py:279–299  ·  view source on GitHub ↗

Insert the entity into this or the appropriate child. This also acts as thinking (recursively). Using :py:meth:`.insert_and_think` iteratively is slightly less efficient but has more predictable performance than initializing with a large number of entities t

(self, entity)

Source from the content-addressed store, hash-verified

277
278
279 def insert_and_think(self, entity):
280 """
281 Insert the entity into this or the appropriate child.
282
283 This also acts as thinking (recursively). Using :py:meth:`.insert_and_think`
284 iteratively is slightly less efficient but has more predictable performance
285 than initializing with a large number of entities then thinking is slightly
286 faster but may hang. Both may exceed recursion depth if :py:attr:`.max_depth`
287 is too large.
288
289 :param entity: the entity to insert
290 :type entity: :class:`.QuadTreeEntity`
291 """
292 if not self.children and len(self.entities) == self.bucket_size and self.depth < self.max_depth:
293 self.split()
294
295 quad = self.get_quadrant(entity) if self.children else -1
296 if quad < 0:
297 self.entities.append(entity)
298 else:
299 self.children[quad].insert_and_think(entity)
300
301 def retrieve_collidables(self, entity, predicate = None):
302 """

Callers 9

test_insertMethod · 0.95
test_retrieveMethod · 0.95
test_ents_per_depthMethod · 0.95
test_nodes_per_depthMethod · 0.95
test_sum_entsMethod · 0.95
test_misplaced_entsMethod · 0.95
test_reprMethod · 0.95
test_strMethod · 0.95

Calls 2

splitMethod · 0.95
get_quadrantMethod · 0.95

Tested by 9

test_insertMethod · 0.76
test_retrieveMethod · 0.76
test_ents_per_depthMethod · 0.76
test_nodes_per_depthMethod · 0.76
test_sum_entsMethod · 0.76
test_misplaced_entsMethod · 0.76
test_reprMethod · 0.76
test_strMethod · 0.76