• 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

Collection classes

 
Ranch Hand
Posts: 528
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can someone please confirm my assumption:

List:

ArrayList = Fast iteration / slow if there will be alot of insertion and deletion (does this use FIFO (First In First Out) ?). Orderd (by index) but not sorted.

Vector = Thread saftey, therefor fast iteration but slower than ArrayList.
Orderd not sorted.

LinkedList = Fast insertion and deletion, slower iteration than ArrayList and Vector. Orderd by index.


Set:

HashSet = Unique, no orders. Fast iteration if the hashCode method is eficiently implemented. Slower insertion and deletion.

LinkedHashSet = Fast insertion and deletion if the hashCode method is eficiently implemented, slower iteration, uses FIFO, not orderd.

TreeSet = Slower iteration and deletion (uses tree structure), uniquenes and sorted by natural order (unless supplied a comparable implementation)

Map:

HashMap = Uses Key/Value pair, fast iteration if the hashCode method is eficiently implemented, slower insertion and deletion.

Hashtable = Practically the same as the HashMap but uses thread saftey methods and allows NO null keys nor values.

LinkedHashMap = FIFO, fast insertion and deletion, slower iteration.

TreeMap = Sorted by natural order of the Keys, duplicates allowed. Slower iteration and insertion and deletion.


Is there any rule of thumb here, i.e: Doubly Linked Lists (LinkedList, LinkeHashSet, LinkedHashMap) are all fast at insertion and deletion but slower at iteration?

Please help, my exam is on Thursday.
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

List:

ArrayList = Fast iteration / slow if there will be alot of insertion and deletion (does this use FIFO (First In First Out) ?). Orderd (by index) but not sorted.



Correct.But i dont think it'll use FIFO.It is ordered by index only.Given the index value it'll retrieve value using it.


Vector = Thread saftey, therefor fast iteration but slower than ArrayList.
Orderd not sorted.



Correct.

LinkedList = Fast insertion and deletion, slower iteration than ArrayList and Vector. Orderd by index.



Correct.

Set:

HashSet = Unique, no orders. Fast iteration if the hashCode method is eficiently implemented. Slower insertion and deletion.



Correct.

LinkedHashSet = Fast insertion and deletion if the hashCode method is eficiently implemented, slower iteration, uses FIFO, not orderd.



Wrong.It is ordered by insertion order or last access order.

TreeSet = Slower iteration and deletion (uses tree structure), uniquenes and sorted by natural order (unless supplied a comparable implementation)



Correct.

Map:

HashMap = Uses Key/Value pair, fast iteration if the hashCode method is eficiently implemented, slower insertion and deletion.



Correct.

LinkedHashMap = FIFO, fast insertion and deletion, slower iteration.



Correct.

TreeMap = Sorted by natural order of the Keys, duplicates allowed. Slower iteration and insertion and deletion.



Wrong.Duplicates are not allowed as keys in any type of Map.

Juz go thru K&B book and in collections chapter they wud have given a table stating all these types.That'll help you to do well in ur exam in collections.

All the best!!

Regards,
Priya.
 
Marcelo Ortega
Ranch Hand
Posts: 528
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Priya.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic