Java Data Structure
Posted
by
Joe
on Stack Overflow
See other posts from Stack Overflow
or by Joe
Published on 2010-12-21T11:38:39Z
Indexed on
2010/12/21
11:53 UTC
Read the original article
Hit count: 255
java
|data-structures
Hi there,
I'm looking for a data structure that will act like a Queue so that I can hava First In First Out behaviour, but ideally I would also be able to see if an element exists in that Queue in constant time as you can do with a HashMap, rather than the linear time that you get with a LinkedList.
I thought a LinkedHashMap might do the job, but although I could make an iterator and just take and then remove the first element of the iteration to produce a sort of poll() method, I'm wondering if there is a better way.
Many thanks in advance
© Stack Overflow or respective owner