stefankoegl / kdtree

A Python implementation of a kd-tree
ISC License
365 stars 118 forks source link

Add payload example to readme #24

Closed uozuAho closed 9 years ago

uozuAho commented 9 years ago

Add explanation of how to add extra data to tree nodes. It wasn't immediately obvious how to do this, even though it's quite simple.

stefankoegl commented 9 years ago

I am not sure if this should be the documented (and therefore recommended) way of adding payload to nodes.

One alternative way would be to index not tuples but other data structures that already contain the payload. It might also be worth considering to provide the payload through the add() method.

Currently I'm leaning more towards recommending to have the payload in the indexed data structure.

uozuAho commented 9 years ago

A defined data type for each node sounds good. I guess it just needs to be indexable, right? (My Python's not that great).

I noticed rebalance() recreates nodes, so any extra attached data is lost. I fixed this without specifying a node data type, but I don't think it's an elegant solution.