Results 1 to 2 of 2
Thread: HashSet/arraylist
- 11-13-2011, 11:58 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 5
- Rep Power
- 0
HashSet/arraylist
Hi!
I programmed a 'collection' ADT. For the implementation of my collection I used a HashSet (with an iterator) because the kind of collection I
programmed, has no structure in ordening. My teammate is convinced that a collection better can be implemented with an arraylist. And my question is: In this case, is there anything I missed with the implemention of a collection with a hashset?
I hope a more advanced programmer, then myself, can review this problem...
Thanks,
Jjitss
-
Re: HashSet/arraylist
I'm not advanced in this regard, but I believe that if your collection will not allow duplicates, and the items held in the collection have well defined and behaved hashCode and equals methods, then a HashSet is fine. An ArrayList is good if you want a collection that allows duplicates and where you want code that is optimized to obtain items in a random access way and by an index.
Similar Threads
-
ArrayList copy some of the element from one arraylist tnto another arraylist
By ralf in forum New To JavaReplies: 12Last Post: 07-07-2011, 08:49 PM -
error in HashSet
By pooja123 in forum New To JavaReplies: 3Last Post: 04-04-2011, 03:39 PM -
HashSet
By Dayanand in forum New To JavaReplies: 7Last Post: 03-12-2011, 09:37 AM -
Getting value for key in HashSet
By Venny in forum New To JavaReplies: 12Last Post: 02-02-2011, 08:42 AM -
:( anyone here plz help on HashSet
By waklo99 in forum New To JavaReplies: 8Last Post: 09-20-2010, 03:02 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks