Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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: 3537
39
  • 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
 
Rancher
Posts: 260
12
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: 69420
276
  • 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.
 
Would you turn that thing down? I'm controlling a mind here! Look ... look at the tiny ad ...
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic