elegance
Today I wrote a TreeModel that proxies for another TreeModel, but via a filter. The code itself is quite simple - it works by creating a map from visible indices to underlying indices for each child node. Before you complain about it not working for infinite trees - it works as intended. If I need it to work outside the current constraints, I'll change it.
Anyway, it's been a while since I'd written a nice recursive method and the elegance of them always surprises me.
Here's a snippet of the tree filtering code:
(assume Map<TreeNode, IntList> maps has been declared in global scope)
Anyway, it's been a while since I'd written a nice recursive method and the elegance of them always surprises me.
Here's a snippet of the tree filtering code:
(assume Map<TreeNode, IntList> maps has been declared in global scope)

0 Comments:
Post a Comment
<< Home