trie4j icon indicating copy to clipboard operation
trie4j copied to clipboard

removing an entry from a MapPatriciaTrie

Open Marlinski opened this issue 4 years ago • 2 comments

Hello,

is it possible to remove an entry from a MapPatriciaTrie ?

Marlinski avatar Sep 10 '20 16:09 Marlinski

There is no method for removing elements from Trie. You still can implement remove function by treating null value as delete flag.

takawitter avatar Sep 15 '20 12:09 takawitter

Functionnally that would work but the key would still be stored inside the trie. This is a problem if the use case is one of "routing" (which is mine). At any given time I may have only up to N element, however elements comes and without the ability to remove keys, the structure will keep growing. Would be nice to have a feature to either remove a key or at least a "clean" method that would remove all the "null" elements from the trie and perform pruning optimization accordingly (I reckon this can be done manually by creating a new trie and adding only non-null elements).

Marlinski avatar Nov 16 '20 08:11 Marlinski