emilydolson / python-red-black-trees

Red-black tree implementation in Python
Other
21 stars 5 forks source link

Allow for the addition of Node objects #13

Open Beakerboy opened 11 months ago

Beakerboy commented 11 months ago

A user may wish to extend the Node object, or implement the Node interface within a custom object. The RedBlackTree could be made to accept these objects and organize them appropriately. This would allow users to implement more complicated sorting strategies then just a singular int, like sorting against a tuple or a custom function.

One consideration is the delete function. Would the user have to provide the exact object they with to remove, or just a key? I guess both could work.

Beakerboy commented 10 months ago

Alternatively, do you feel the better approach is to use the existing Node, and the user should add their custom object as the Node’s value?