• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 4806
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
He llo Mike,

Thank you for your answer.

Vincent
 
Rancher
Posts: 261
12
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rototillers convert rich soil into dirt. Please note that this tiny ad is not a rototiller:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic