Curious about NSHashTable
Curious about NSHashTable
- Subject: Curious about NSHashTable
- From: Luke Evans <email@hidden>
- Date: Fri, 8 Feb 2008 16:18:06 -0800
I'm playing with NSHashTable, attracted by what I see is the
possibility of overriding the hash and isEqual functions in order to
override those provided directly by the content objects.
Now, it *looks* like I should be able to achieve what I want by
requesting a regular NSHashTable (can be a strong ref one for now),
getting its pointer functions and then setting in pointers to my
custom hash and isEqual functions (which conform to the documented
prototype of course).
I have code like this:
NSHashTable *uniquesTable = [NSHashTable
hashTableWithOptions:NSHashTableStrongMemory];
NSPointerFunctions *pointFuncs = [uniquesTable pointerFunctions];
pointFuncs.hashFunction = contentHashFunction;
pointFuncs.isEqualFunction = contentEqualFunction;
The properties hashFunction and isEqualFunction are writeable, so it
appears that there should be some utility in setting them to the
functions you want. Yet, so far, I'm finding that I can add items to
the NSHashTable and neither of my custom functions appear to be called.
I'm going to play next with the underlying CFSet to see if I can get
this to do what I want (I'm wondering if the pointerFunctions can only
be meaningfully set at construction time of the set, and not
afterwards).
Meanwhile, does anyone have any experience of doing something along
these lines? Am I wandering from the straight and narrow, or simply
expecting too much of the current NSHashTable?
-- Lwe
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden