java - How can we maintain unique object list without using set? -
suppose have 2 employee instances having common attributes id,name,address (all values same ).
i want unique objects list without implementing set.
please don’t explain logic primitive data type ,i want uniqueness object type.
simple: create "collection" class calls uses equals()
method of "incoming" objects compare them against stored objects.
if method gives false
- no duplicate, add collection. if true
- not unique. no adding.
in other words - re-invent wheel , create resembles java set. of course, implicit drawbacks - such repeating implementation bugs fixed in java set implementations 15 20 years ago.
Comments
Post a Comment