hi forum,
i am using an arraylist for storing a list of objects.i dont want the objects in the list to be ordered but the list should be duplicate free.how can i achieve this.plz help quickly.provide source code if possible.thanks in advance.
Dark Master 0 Newbie Poster
Recommended Answers
Jump to PostHashset is an excellent idea, but if you want to just use arraylists then the contain method hook mentioned is the way to go.
Jump to PostUsing contains would indeed work, but if the List gets large it gets ever more expensive to do the check (it's an O(n) operations, iterating over the entire dataset until either the end is reached or a match is found).
Using a container that prohibits duplicates is indeed a more …
Jump to PosthascCode is used in concert with equals to determine whether (and where) in a HashSet (or other hash based collection) an object exists.
You need to have these methods in working order (and thus overridden from the defaults in Object) in order for the algorithms to work correctly.There's …
All 9 Replies
chrisbliss18 26 Posting Shark
Kate Albany 0 Junior Poster in Training
hooknc 1 Posting Whiz in Training
server_crash 64 Postaholic
jwenting 1,905 duckman Team Colleague
Dark Master 0 Newbie Poster
jwenting 1,905 duckman Team Colleague
pnr.nagi@gmail. -2 Newbie Poster
jwenting commented: thread hijacking zombie master -2
jwenting 1,905 duckman Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.