mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Implement fast enumeration for insensitive dictionary
This commit is contained in:
parent
7dc4a8f532
commit
938f280b87
2 changed files with 26 additions and 1 deletions
|
@ -61,6 +61,7 @@
|
|||
{
|
||||
@public
|
||||
GSIMapTable_t map;
|
||||
NSUInteger _version;
|
||||
}
|
||||
@end
|
||||
|
||||
|
@ -349,6 +350,15 @@ static SEL objSel;
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state
|
||||
objects: (__unsafe_unretained id[])stackbuf
|
||||
count: (NSUInteger)len
|
||||
{
|
||||
state->mutationsPtr = (unsigned long *)self;
|
||||
return GSIMapCountByEnumeratingWithStateObjectsCount
|
||||
(&map, state, stackbuf, len);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation _GSMutableInsensitiveDictionary
|
||||
|
@ -396,6 +406,7 @@ static SEL objSel;
|
|||
{
|
||||
GSIMapNode node;
|
||||
|
||||
_version++;
|
||||
if (aKey == nil)
|
||||
{
|
||||
NSException *e;
|
||||
|
@ -425,11 +436,14 @@ static SEL objSel;
|
|||
{
|
||||
GSIMapAddPair(&map, (GSIMapKey)aKey, (GSIMapVal)anObject);
|
||||
}
|
||||
_version++;
|
||||
}
|
||||
|
||||
- (void) removeAllObjects
|
||||
{
|
||||
_version++;
|
||||
GSIMapCleanMap(&map);
|
||||
_version++;
|
||||
}
|
||||
|
||||
- (void) removeObjectForKey: (id)aKey
|
||||
|
@ -439,7 +453,18 @@ static SEL objSel;
|
|||
NSWarnMLog(@"attempt to remove nil key from dictionary %@", self);
|
||||
return;
|
||||
}
|
||||
_version++;
|
||||
GSIMapRemoveKey(&map, (GSIMapKey)aKey);
|
||||
_version++;
|
||||
}
|
||||
|
||||
- (NSUInteger) countByEnumeratingWithState: (NSFastEnumerationState*)state
|
||||
objects: (__unsafe_unretained id[])stackbuf
|
||||
count: (NSUInteger)len
|
||||
{
|
||||
state->mutationsPtr = (unsigned long *)&_version;
|
||||
return GSIMapCountByEnumeratingWithStateObjectsCount
|
||||
(&map, state, stackbuf, len);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -426,7 +426,6 @@ static SEL objSel;
|
|||
{
|
||||
GSIMapNode node;
|
||||
|
||||
_version++;
|
||||
if (aKey == nil)
|
||||
{
|
||||
NSException *e;
|
||||
|
@ -448,6 +447,7 @@ static SEL objSel;
|
|||
userInfo: self];
|
||||
[e raise];
|
||||
}
|
||||
_version++;
|
||||
node = GSIMapNodeForKey(&map, (GSIMapKey)aKey);
|
||||
if (node)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue