• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

OCP8 - Boyarsky/Selikoff book - Table 3.9 Choosing the right collection type

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Regarding table 3.9, i disagree with the LinkedList answer.

LinkedList implements Deque interface, so it is not the description of the FIFO.
PriorityQueue seems to be better.

Any suggestion about it?

Thanks for your help.
Vincent
 
Master Rancher
Posts: 3313
31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Deque (or LinkedList specifically) can be used for either FIFO or FILO.  It's not only FIFO or FILO, but it supports both equally well.

A PriorityQueue has nothing to do with FIFO or FILO.  Rather, the order (the priority) is determined by a Comparator (or the Comparable implementation).  So it's inappropriate to use a LinkedList or other Deque if you need a priority queue, and it's inappropriate to use a PriorityQueue if you need either FIFO or FILO.
 
vincent Lepore
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He llo Mike,

Thank you for your answer.

Vincent
 
Master Rancher
Posts: 172
7
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I understood is that for the Queue (and possibly the Deque?) abstract data structures we are supposed to know the ArrayDeque and LinkedList implementation classes.
As far as I know, the PriorityQueue class is not on the exam (although the more we know, the better of course).
 
Marshal
Posts: 65365
248
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest you have a little look at the Java™ Tutorials, particularly the first part of that section. Also find an introduction to data structures (book or tutorial).
The best type of collection depends mostly on how you are going to use the data in it.
 
a wee bit from the empire
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!