commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject Re: [Collections] What collection fits my problem?
Date Tue, 15 Mar 2005 22:51:59 GMT
You describe the correct behaviour of SortedBag, and collections in general. 
Most collections use .equals() comparisons.

You have two choices:
a) Write a sorted collection that uses == for comparison instead of .equals

b) Use a TreeSet, but wrap each of your objects in an inner class style 
wrapper, eg:
public class Wrapper {
  public Object realData;
}

Stephen

----- Original Message ----- 
From: "Mike Zatko" <mzatko@boscovs.com>
> FYI, I did try a sorted bag which appeared to be what I was looking for. 
> But, for some reason if you add 2 identical objects (deep copied) and add 
> them to the bag, it will merely overwrites the first objects reference 
> with the second objects reference. To me, this seems like it would be a 
> bug, but I could be wrong. Any thoughts?
>
>
> Mike Zatko wrote:
>
>> I need a sorted collection that also allows deep copied duplicate objects 
>> (exact same object, different memory addresses). Is there a collection 
>> that fits that requirement? I've been having difficulty finding one 
>> myself. Thanks for any help.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message