I am going to implement a pointer-based binary heap. What i would like, is for the heap to "work" in various ways depending on some parameters. For example, the heap could be represented in many ways: pointers to left child, right child and parent, left child/right sibling style and so on. Independent of representation, i would like the basic implementation to stay the same. For example, i would like not to implement two different Siftdown methods, depending on the representation. I was thinking about giving a node type and an iterator type as parameters to the heap. Then, Siftdown, say, could use the given iterator to do it's job. Im wondering if it's good style to use iterators in actual implementation code? Also, i am looking into known design patterns that might be useful to me. The Bridge and Strategy patterns seem interesting.
So, my question is twofold:
- Is it good practice to use iterators in implementation code?
- Any thoughts on design patterns that would fit my purpose?
Thanks.