Apache Collections -- BoundedFifoBuffer

J

Jerry

I am using BoundedFifoBuffer from Apache Collection to enqueue and
dequeue Minute object (I defined this object). I find there is no
contructor in BoundedFifoBuffer that I can pass a Comparator object.

If I don't pass a Comparator object, "contains" method in
BoundedFifoBuffer won't work. It doesn't know if a Minute object is in
the queue.

Anyone knows how to solve this problem?

Thanks a lot!
 
G

Greg

Jerry napisal(a):
I am using BoundedFifoBuffer from Apache Collection to enqueue and
dequeue Minute object (I defined this object). I find there is no
contructor in BoundedFifoBuffer that I can pass a Comparator object.

If I don't pass a Comparator object, "contains" method in
BoundedFifoBuffer won't work. It doesn't know if a Minute object is in
the queue.

Anyone knows how to solve this problem?

Thanks a lot!

First of all you have to implement "equals" rather than use Comparator
because BoundedFifoBuffer implementation of "contains" is based on
"equals".
Moreover there is no need to use Comparator in this context.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top