I'm making PriorityQueue<T>
classes, and right now I am using List<T>
as a backing store. The following are the errors that I have been getting:
Have Correct Suffix/ Do not have incorrect suffix
Do not expose List<T>
For the -Queue suffix I need to inherit Queue<T>
, but to sort a Queue<T>
, I would need to empty the queue, sort, and then refill the queue. Also, if I inherit from Queue<T>
, I would violate LSP because a priority queue is not a FIFO collection.
For one of the types of PriorityQueues that I am making is using an IComparer<T>
to compare the elements, but IComparer<T>
is only supported on arrays and List<T>
.
I did see this question, but it doesnt fully relate to my question.
So here are my questions:
Should I suppress these code analysis warnings?
Should I inherit from Queue<T>
and rewrite my classes to work off of it, even though it is less efficient?
If not, should I still swap out List<T>
for something else?
Edit: I don't know if this would make any difference, but the following is my setup of each of my classes:
PriorityQueue<T>
-- abstract base class (Sort() is abstract)PriorityQueue<T, TComparer>
-- subclass that uses a comparer to sortReflectionPriorityQueue<T>
-- subclass that uses reflection to sort, specifics not important to this question.