Home Segments Index Top Previous Next

439: Mainline

The following decision tree will help you to choose the appropriate collection class from the alternatives:

Access by integer index only? 
  |          | 
  |          | Yes 
  | No       *------------* 
  v                       v 
Accessible from ends?   Use Array 
  |               | 
  |               | Yes 
  | No            *-----------------* 
  v                                 v 
Duplicates counted separately?    Keep sorted? 
  |              |                  |      | 
  |              |                  |      | Yes 
  | No           | Yes              | No   *----------------* 
  v              v                  v                       | 
Use Bag         Use Set           Use OrderedCollection     | 
                                                            v 
                                           Use SortedCollection