Question on layer/peeling

Ali Ebrahimi ali.ebrahimi1781 at gmail.com
Wed Jan 7 14:14:28 UTC 2015


You already have to implement Set<Map.Entry<K,V>> entrySet()

On Wed, Jan 7, 2015 at 5:14 PM, Vitaly Davidovich <vitalyd at gmail.com> wrote:

> Not sure that's ideal as the implementation may not be using entry objects
> to store things (e.g. open addressed version with parallel arrays for keys
> and values); this would cause the get method to allocate an entry for each
> get operation.  If the entry impl is a value type it'll be boxed since it's
> assigned to an interface.
>
> Sent from my phone
> On Jan 7, 2015 3:03 AM, "Ali Ebrahimi" <ali.ebrahimi1781 at gmail.com> wrote:
>
>> Or add method
>> Map.Entry<K,V> getEntry(key)
>>
>> On Wed, Jan 7, 2015 at 2:15 AM, Brian Goetz <brian.goetz at oracle.com>
>> wrote:
>>
>>> By the way, C# solves this by having TryGet type of methods that return a
>>>> boolean indicating success (I.e. found mapping) and set an out
>>>> parameter to
>>>> the value found.  You'd need a lightweight tuple or multi return to do
>>>> the
>>>> same in java,  I think.
>>>>
>>>
>>> Right, there's two ways to fix get():
>>>  - Using the getOrDefault(key, sentinel) // added in Java 8
>>>  - Using some sort of optional-like return type
>>>
>>> Not quite at that part of the road yet.
>>>
>>>
>>
>>
>> --
>>
>> Best Regards,
>> Ali Ebrahimi
>>
>


-- 

Best Regards,
Ali Ebrahimi


More information about the valhalla-dev mailing list