this code piece serves a usual purpose; it checks whether Key is present in Tree_0, and if so, then it updates the data of Key:
Code: Select all
if _Data = radixTree::lookup(Tree_0, Key) then
Tree_1 = radixTree::insert({ (A, B) = A + B }, Tree_0, Key, 1)
end if,
Class radixTree contains bulk operations merge, intersection, difference, and xor. A merge does not work here because the merge would also insert the keys (incl. data) from TreeB, which are not in TreeA, into TreeAB. The other bulk operations cannot solve the task either.
So it could make sense to introduce another bulk operation. The attached example gives a usecase of that bulk operation. I have simply named the operation update (I am but not completely happy with the name as it does not indicate that it is a set-operation).
The example outputs the results of some calls to predicates in class lstTrieSet. The class is a variant of class trieSet with a few additional predicates. Predicates delete and difference of class lstTrieSet are based on the update bulk operation for red-black trees.
Essentially my example just consists of moddings to your pfc code. I have left your copyright header in all files. Most probably, when you one day incorporate the bulk operations in red–black trees, you will do it better than me. Nevertheless, I hope that a look on the example's code can be helpful in somehow.