• 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

Abstract Data Type for a Queue

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is an ADT for a Queue and how would you write such a thing?
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ronald,
A Queue is a FIFO (First In, First Out) data type that can be visualized as a line, like at the checkout counter. (In fact, the word queue is another word for a line used in this context, though the word is not as common in popular US English.) Here is an illustration :

Hopefully this clearly explains how a queue behaves... as far as actual implementation you can use anything : an array, a vector, a tree, a hash table, etc. to actually implement. I would look into the Collections API. Since a queue is a type of Collection it would fit into this interface, and it will also give you an idea of the sorts of data types you can use to implement a queue.
HTH,
-Nate
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should probably use a LinkedList to make a Queue. Quote from "Thinking in Java"

</BLOCKQUOTE>

[This message has been edited by Randall Twede (edited January 26, 2001).]
reply
    Bookmark Topic Watch Topic
  • New Topic