- Take a balanced tree implementation off the web. I was thinking finger tree but then though better to start with a simpler implementation. I chose an AVL tree. (I may revert the code to a red and black tree to simplify).
- Add a node field to store the augmentation (a generic type)
- Refactor the code by replacing the call of the node constructor by a call to a function that will first build an augmentation and then call the node constructor
- Pass the generic augmentation "maker" function as argument to the function calls
Monday, March 21, 2011
Personalize your containers (in F#)
Many years ago I implemented an augmented tree structure in C++. Inspired, I decided to implement the structure in F#. FYI by augmentation I mean storing extra data at each node of the tree that will accelerate the later operations on the tree. In DB terms, augmentations are typically used include secondary key conditions in your tree query.
This is what I did:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment