This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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
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.