I've got a question about design. I have a class CodesTree that is building some sort of a binary tree according to data provided and the algorithm it's using needs a priority queue (nota bene also implemented using binary tree). There may be different implementations of a priority queue so I would like to allow the user of my class to choose the implementation he prefers. I designed the interface of the queue like this:
public interface IPriorityQueue<T>
{
T GetMax();
void Insert(T value);
int Count { get; }
}
The question is - how do I allow the user to choose the implementation? The only way I can think of is to make a public property of a type IPriorityQueue in my CodesTree class and let user set this property to an instance of a class he wants to use. But I don't think it is a good idea, because the user may specify the queue that for example already has a few elements or, having a reference to the queue, delete some elements (and he shouldn't). It just seems a bit not elegant. What is the best way?