gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exception when using GSDictionary in corebase


From: Dr. H. Nikolaus Schaller
Subject: Re: Exception when using GSDictionary in corebase
Date: Fri, 20 May 2011 19:57:10 +0200

Am 20.05.2011 um 19:45 schrieb David Chisnall:

> On 20 May 2011, at 18:44, Dr. H. Nikolaus Schaller wrote:
> 
>> b) and just checking if a new value is already stored to avoid duplicates.
> 
> 
> So, just to be clear, you're advocating implementing a O(n) algorithm, 
> instead of using an existing O(log(n)) algorithm?

No, I am not talking about efficiency of any implementation
at all and the API doesn't specify that IMHO.

Checking if a given object is already in the NSArray
can be O(log(n)) or even better, depending in how well hash
values are used and if the array has an internal index file...

The original question of Stefan was that he apparently
wants to use the set of keys of an NSDictionary to emulate NSSet.

And runs into problems because the objects are copied.

My proposal is to check if an object is already member of
an array. And if not, add it to the array.

This simply works like a NSSet... 

All this is sort of a temporary solution to solve his GSDictionary
problem. Nothing else promised. Nothing advocated. 
Just problem solved. Or not. He can and should decide since
we don't know all the requirements.

The best solution of course would be to implement CFSet using
some O(1) algorithm :)

BR,
Nikolaus

-- Send from my alter ego




reply via email to

[Prev in Thread] Current Thread [Next in Thread]