directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ayyagarikiran <>
Subject Re: [ApacheDS][AvlTreeMap] insert() fails to replace old value
Date Thu, 02 Apr 2009 08:13:59 GMT

David Jencks wrote:
> On Apr 1, 2009, at 10:28 PM, Kiran Ayyagari wrote:
>> This can easily lead to CCE without some extra checks.
> I don't quite see your point of view.  I figured that "put" methods only 
> return a value when they replace a previous value.  If duplicates are 
> allowed, then put will never replace a value and always return null.  If 
> duplicates are not allowed, then there will be 0 (null) or 1 (V) objects 
> to return.
ah, right, I was mixing both the value passed and the actual 'value' present in node.

> I don't see how a return from this can be useful unless something like 
> remove(K, null) removes all the values associated with K.  In that case 
> returning AvlTree<V> might be more appropriate.  On the other hand my 
> naive expectations would be that remove(K, null) would only remove 
> something is insert(K, null) had been called.  If I wanted to remove all 
> the values associated with a K I'd want a method remove(K) and having 
> this return an AvlTree(V) seems more appropriate (this could be a 
> singleton if there is only one value).

the current impl removes the all the values associated with a key if remove(K,null) is called
assuming that we don't allow null to be inserted by checking at a higher level (ex. the XXXTable

But, yes this is certainly possible to have null values, provided the comparators handle them

Returning a singleton AvlTree<V> would be a overhead, but if this is something really
required will add it

thanks David.

Kiran Ayyagari

View raw message