>Is there a reason why you want to map integer values that I can only
>assume represent queue positions to the elements of the queue?
Correct.
>If your queue doesn't get elements removed from it midpoint, you should
>be able to use a standard queue mechanism of push and pop.
Push, pop, peek and drop.
>This mechanism is of course already implemented in Queue implementations
>(add and remove methods).
Queue is an Interface, and it was that which was part of my original
problem. I dropped the interface when I moved to extending
AbstractQueue, which already implements Queue. No need to include it
twice.
>If you need to dictate the order of the
>queue upon addition of elements, PriorityQueue gives you that
>functionality out of the box. Just wondering about your design...
I want a plain FIFO Queue and it seems stupid to use a Priority Queue
with the priority effectively turned off. All the heap overhead for
no purpose. What I have is a HashMap with head and tail indexes.
>Also, when declaring variables and class fields, try to use as generic
>a type as possible, interfaces being preferred. From your example
>above:
> private m_Data HashMap<Integer, E>;
>won't compile until it's
My compiler said the same thing. :) Blame it on my first
professional language being Algol 60.
> private HashMap<Integer, E> m_Data;
>but should really be
> private Map<Integer, E> m_Data;
Good suggestion, which I have implemented.
>And if you do need to remove things from the middle of the queue, you
>can still achieve that with a List object, which preserves any order
>you give it.
I do not actually need to remove elements from the middle. If I did
it wouldn't be a queue.
Thanks for your comments.
rossum
Lew - 28 Aug 2007 00:08 GMT
Alexey wrote:
>> private HashMap<Integer, E> m_Data;
>> but should really be
>> private Map<Integer, E> m_Data;
> Good suggestion, which I have implemented.
According to Sun's code conventions, which nearly everyone follows,
non-constant fields should be named without underscores.

Signature
Lew