Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the Java equivalent of C++'s STL Queue?

I was browsing through the Java docs to look for the Java equivalent for C++'s STL Queue, but all I found was an interface called Queue and a bunch of implementations I can't make heads or tails of.

Does Java have an implementation for Queue that's just a FIFO data structure without the added bells and whistles? I only need the enqueue, dequeue and front operations and the data structure should allow duplicates.

like image 647
Pieter Avatar asked Nov 13 '10 13:11

Pieter


1 Answers

Queue will work. Use any implementation you like. LinkedList or ConcurrentLinkedQueue for example.

enqueue = offer(..)
dequeue = poll()
front = peek()

like image 191
Bozho Avatar answered Sep 19 '22 20:09

Bozho