• 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

Accessing collections

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I was going thro the Collection Frame Work and looks like except the legacy Stack class(which is a subclass of Vector),other implementations such as TreeSet and TreeMap support FIFO(First In First Out).Correct me if am wrong.
Thanks,
Ramnath

Feed an Opportunity.Starve a Problem

 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ramnath,
Maybe you're confusing some terms. Many containers are ordered in the sense that their contents are organized in some manner. A TreeSet for instance can be ordered based on the results of "equals" being invoked on each of the items in itself. That doesn't mean that it's FIFO or FILO; it simply means that the contents are ordered a particular way. With the exception of stacks and queues and possibly dequeues, most containers will focus on ordering its contents in some algorithmically efficient manner.
The Stack class for example just provides an interface to the ArrayList class to make it act like you would expect. You can still pull any element out if that you want, thereby breaking its "stackness".
Remember that java.util has alot of different interfaces. Some of them are aimed at different ordering semantics. Set doesn't really order anything. Neither does map. List however, which Stack implements indirectly), does maintain an order from element 1 to n, where n is the size of the container -- and that is all that allows the Stack to operate like a Stack.
I'm getting wordy, so I'll leave it at that.
 
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic