2001-12-17 14:31:42 +00:00
|
|
|
|
/** NSMapTable implementation for GNUStep.
|
2002-01-30 13:05:35 +00:00
|
|
|
|
* Copyright (C) 1994, 1995, 1996, 2002 Free Software Foundation, Inc.
|
1996-02-13 02:31:48 +00:00
|
|
|
|
*
|
|
|
|
|
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
|
|
|
|
|
* Created: Mon Dec 12 23:59:57 EST 1994
|
1996-03-22 00:36:13 +00:00
|
|
|
|
* Updated: Sun Mar 17 18:37:12 EST 1996
|
|
|
|
|
* Serial: 96.03.17.31
|
2002-01-30 13:05:35 +00:00
|
|
|
|
* Rewrite by: Richard Frith-Macdonald <rfm@gnu.org>
|
1996-02-13 02:31:48 +00:00
|
|
|
|
*
|
1996-05-12 00:56:10 +00:00
|
|
|
|
* This file is part of the GNUstep Base Library.
|
1996-02-13 02:31:48 +00:00
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Library General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
|
* License along with this library; if not, write to the Free
|
2001-12-18 16:54:15 +00:00
|
|
|
|
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
2002-01-30 13:05:35 +00:00
|
|
|
|
*
|
|
|
|
|
* <title>NSMapTable class reference</title>
|
|
|
|
|
* $Date$ $Revision$
|
2001-12-18 16:54:15 +00:00
|
|
|
|
*/
|
1996-02-13 02:31:48 +00:00
|
|
|
|
|
|
|
|
|
/**** Included Headers *******************************************************/
|
|
|
|
|
|
2003-06-07 01:24:41 +00:00
|
|
|
|
#include "config.h"
|
|
|
|
|
#include "Foundation/NSObject.h"
|
|
|
|
|
#include "Foundation/NSString.h"
|
|
|
|
|
#include "Foundation/NSArray.h"
|
|
|
|
|
#include "Foundation/NSException.h"
|
|
|
|
|
#include "Foundation/NSZone.h"
|
|
|
|
|
#include "Foundation/NSMapTable.h"
|
|
|
|
|
#include "Foundation/NSDebug.h"
|
1996-03-22 00:36:13 +00:00
|
|
|
|
#include "NSCallBacks.h"
|
1996-02-13 02:31:48 +00:00
|
|
|
|
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
typedef struct {
|
|
|
|
|
NSMapTableKeyCallBacks k;
|
|
|
|
|
NSMapTableValueCallBacks v;
|
|
|
|
|
} extraData;
|
1996-02-13 02:31:48 +00:00
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/*
|
|
|
|
|
* The 'Fastmap' stuff provides an inline implementation of a mapping
|
|
|
|
|
* table - for maximum performance.
|
|
|
|
|
*/
|
|
|
|
|
#define GSI_MAP_EXTRA extraData
|
|
|
|
|
#define GSI_MAP_KTYPES GSUNION_PTR
|
|
|
|
|
#define GSI_MAP_VTYPES GSUNION_PTR
|
|
|
|
|
#define GSI_MAP_HASH(M, X)\
|
|
|
|
|
(M->extra.k.hash)((NSMapTable*)M, X.ptr)
|
|
|
|
|
#define GSI_MAP_EQUAL(M, X, Y)\
|
|
|
|
|
(M->extra.k.isEqual)((NSMapTable*)M, X.ptr, Y.ptr)
|
|
|
|
|
#define GSI_MAP_RELEASE_KEY(M, X)\
|
|
|
|
|
(M->extra.k.release)((NSMapTable*)M, X.ptr)
|
|
|
|
|
#define GSI_MAP_RETAIN_KEY(M, X)\
|
|
|
|
|
(M->extra.k.retain)((NSMapTable*)M, X.ptr)
|
|
|
|
|
#define GSI_MAP_RELEASE_VAL(M, X)\
|
|
|
|
|
(M->extra.v.release)((NSMapTable*)M, X.ptr)
|
|
|
|
|
#define GSI_MAP_RETAIN_VAL(M, X)\
|
|
|
|
|
(M->extra.v.retain)((NSMapTable*)M, X.ptr)
|
|
|
|
|
#define GSI_MAP_ENUMERATOR NSMapEnumerator
|
|
|
|
|
|
2003-07-31 23:49:32 +00:00
|
|
|
|
#include "GNUstepBase/GSIMap.h"
|
1996-02-13 02:31:48 +00:00
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/**** Function Implementations ****/
|
1996-02-13 02:31:48 +00:00
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* Returns an array of all the keys in the table.
|
|
|
|
|
* NB. The table <em>must</em> contain objects for its keys.
|
|
|
|
|
*/
|
|
|
|
|
NSArray *
|
|
|
|
|
NSAllMapTableKeys(NSMapTable *table)
|
1996-03-22 00:36:13 +00:00
|
|
|
|
{
|
2002-01-30 13:05:35 +00:00
|
|
|
|
NSMutableArray *keyArray;
|
|
|
|
|
NSMapEnumerator enumerator;
|
|
|
|
|
id key = nil;
|
2002-02-02 07:40:35 +00:00
|
|
|
|
void *dummy;
|
1996-03-22 00:36:13 +00:00
|
|
|
|
|
2002-01-31 19:15:21 +00:00
|
|
|
|
if (table == 0)
|
|
|
|
|
{
|
2002-02-02 07:40:35 +00:00
|
|
|
|
NSWarnFLog(@"Nul table argument supplied");
|
2002-01-31 19:15:21 +00:00
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/* Create our mutable key array. */
|
|
|
|
|
keyArray = [NSMutableArray arrayWithCapacity: NSCountMapTable(table)];
|
1996-02-13 02:31:48 +00:00
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/* Get an enumerator for TABLE. */
|
|
|
|
|
enumerator = NSEnumerateMapTable(table);
|
1996-02-13 02:31:48 +00:00
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/* Step through TABLE... */
|
2002-02-02 07:40:35 +00:00
|
|
|
|
while (NSNextMapEnumeratorPair(&enumerator, (void **)(&key), &dummy))
|
2002-01-30 13:05:35 +00:00
|
|
|
|
{
|
|
|
|
|
[keyArray addObject: key];
|
|
|
|
|
}
|
2002-05-28 05:23:36 +00:00
|
|
|
|
NSEndMapTableEnumeration(&enumerator);
|
2002-01-30 13:05:35 +00:00
|
|
|
|
return keyArray;
|
1996-02-13 02:31:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* Returns an array of all the values in the table.
|
|
|
|
|
* NB. The table <em>must</em> contain objects for its values.
|
|
|
|
|
*/
|
|
|
|
|
NSArray *
|
|
|
|
|
NSAllMapTableValues(NSMapTable *table)
|
1996-02-13 02:31:48 +00:00
|
|
|
|
{
|
2002-01-30 13:05:35 +00:00
|
|
|
|
NSMapEnumerator enumerator;
|
|
|
|
|
NSMutableArray *valueArray;
|
|
|
|
|
id value = nil;
|
2002-02-02 07:40:35 +00:00
|
|
|
|
void *dummy;
|
1996-02-13 02:31:48 +00:00
|
|
|
|
|
2002-01-31 19:15:21 +00:00
|
|
|
|
if (table == 0)
|
|
|
|
|
{
|
2002-02-02 07:40:35 +00:00
|
|
|
|
NSWarnFLog(@"Nul table argument supplied");
|
2002-01-31 19:15:21 +00:00
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/* Create our mutable value array. */
|
|
|
|
|
valueArray = [NSMutableArray arrayWithCapacity: NSCountMapTable(table)];
|
1996-02-13 02:31:48 +00:00
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/* Get an enumerator for TABLE. */
|
|
|
|
|
enumerator = NSEnumerateMapTable(table);
|
1996-02-13 02:31:48 +00:00
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/* Step through TABLE... */
|
2002-02-02 07:40:35 +00:00
|
|
|
|
while (NSNextMapEnumeratorPair(&enumerator, &dummy, (void **)(&value)))
|
2002-01-30 13:05:35 +00:00
|
|
|
|
{
|
|
|
|
|
[valueArray addObject: value];
|
|
|
|
|
}
|
2002-05-28 05:23:36 +00:00
|
|
|
|
NSEndMapTableEnumeration(&enumerator);
|
2002-01-30 13:05:35 +00:00
|
|
|
|
return valueArray;
|
1996-02-13 02:31:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* Compares the two map tables for equality.
|
|
|
|
|
* If the tables are different sizes, returns NO.
|
|
|
|
|
* Otherwise, compares the keys <em>(not the values)</em>
|
|
|
|
|
* in the two map tables and returns NO if they differ.<br />
|
|
|
|
|
* The GNUstep implementation enumerates the keys in table1
|
|
|
|
|
* and uses the hash and isEqual functions of table2 for comparison.
|
|
|
|
|
*/
|
|
|
|
|
BOOL
|
|
|
|
|
NSCompareMapTables(NSMapTable *table1, NSMapTable *table2)
|
1996-02-13 02:31:48 +00:00
|
|
|
|
{
|
2002-01-30 13:05:35 +00:00
|
|
|
|
GSIMapTable t1 = (GSIMapTable)table1;
|
|
|
|
|
GSIMapTable t2 = (GSIMapTable)table2;
|
1996-02-13 02:31:48 +00:00
|
|
|
|
|
2002-01-31 19:15:21 +00:00
|
|
|
|
if (t1 == t2)
|
|
|
|
|
{
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
if (t1 == 0)
|
|
|
|
|
{
|
2002-02-02 07:40:35 +00:00
|
|
|
|
NSWarnFLog(@"Nul first argument supplied");
|
2002-01-31 19:15:21 +00:00
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
if (t2 == 0)
|
|
|
|
|
{
|
2002-02-02 07:40:35 +00:00
|
|
|
|
NSWarnFLog(@"Nul second argument supplied");
|
2002-01-31 19:15:21 +00:00
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
if (t1->nodeCount != t2->nodeCount)
|
|
|
|
|
{
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-05-28 05:23:36 +00:00
|
|
|
|
NSMapEnumerator enumerator = GSIMapEnumeratorForMap((GSIMapTable)t1);
|
|
|
|
|
GSIMapNode n;
|
2002-05-28 11:30:15 +00:00
|
|
|
|
|
2002-05-28 05:23:36 +00:00
|
|
|
|
while ((n = GSIMapEnumeratorNextNode(&enumerator)) != 0)
|
|
|
|
|
{
|
|
|
|
|
if (GSIMapNodeForKey(t2, n->key) == 0)
|
|
|
|
|
{
|
2002-05-28 11:30:15 +00:00
|
|
|
|
GSIMapEndEnumerator((GSIMapEnumerator)&enumerator);
|
2002-05-28 05:23:36 +00:00
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-05-28 11:30:15 +00:00
|
|
|
|
GSIMapEndEnumerator((GSIMapEnumerator)&enumerator);
|
2002-01-30 13:05:35 +00:00
|
|
|
|
return YES;
|
|
|
|
|
}
|
1996-02-13 02:31:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/**
|
2002-12-31 10:09:54 +00:00
|
|
|
|
* Copy the supplied map table.<br />
|
|
|
|
|
* Returns a map table, space for which is allocated in zone, which
|
|
|
|
|
* has (newly retained) copies of table's keys and values. As always,
|
|
|
|
|
* if zone is 0, then NSDefaultMallocZone() is used.
|
2002-01-30 13:05:35 +00:00
|
|
|
|
*/
|
|
|
|
|
NSMapTable *
|
|
|
|
|
NSCopyMapTableWithZone(NSMapTable *table, NSZone *zone)
|
1996-03-22 00:36:13 +00:00
|
|
|
|
{
|
2002-01-30 13:05:35 +00:00
|
|
|
|
GSIMapTable t;
|
|
|
|
|
GSIMapNode n;
|
2002-05-28 05:23:36 +00:00
|
|
|
|
NSMapEnumerator enumerator;
|
|
|
|
|
|
2002-01-31 19:15:21 +00:00
|
|
|
|
if (table == 0)
|
|
|
|
|
{
|
2002-02-02 07:40:35 +00:00
|
|
|
|
NSWarnFLog(@"Nul table argument supplied");
|
2002-01-31 19:15:21 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
t = (GSIMapTable)NSZoneMalloc(zone, sizeof(GSIMapTable_t));
|
|
|
|
|
GSIMapInitWithZoneAndCapacity(t, zone, ((GSIMapTable)table)->nodeCount);
|
|
|
|
|
t->extra.k = ((GSIMapTable)table)->extra.k;
|
|
|
|
|
t->extra.v = ((GSIMapTable)table)->extra.v;
|
2002-05-28 05:23:36 +00:00
|
|
|
|
enumerator = GSIMapEnumeratorForMap((GSIMapTable)table);
|
|
|
|
|
while ((n = GSIMapEnumeratorNextNode(&enumerator)) != 0)
|
2002-01-30 13:05:35 +00:00
|
|
|
|
{
|
|
|
|
|
GSIMapAddPair(t, n->key, n->value);
|
|
|
|
|
}
|
2002-05-28 11:30:15 +00:00
|
|
|
|
GSIMapEndEnumerator((GSIMapEnumerator)&enumerator);
|
2002-01-30 13:05:35 +00:00
|
|
|
|
|
|
|
|
|
return (NSMapTable*)t;
|
1996-03-22 00:36:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/**
|
2002-12-31 10:09:54 +00:00
|
|
|
|
* Returns the number of key/value pairs in the table.
|
2002-01-30 13:05:35 +00:00
|
|
|
|
*/
|
|
|
|
|
unsigned int
|
|
|
|
|
NSCountMapTable(NSMapTable *table)
|
1996-02-13 02:31:48 +00:00
|
|
|
|
{
|
2002-01-31 19:15:21 +00:00
|
|
|
|
if (table == 0)
|
|
|
|
|
{
|
2002-02-02 07:40:35 +00:00
|
|
|
|
NSWarnFLog(@"Nul table argument supplied");
|
2002-01-31 19:15:21 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
2002-01-30 13:05:35 +00:00
|
|
|
|
return ((GSIMapTable)table)->nodeCount;
|
1996-02-13 02:31:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* Create a new map table by calling NSCreateMapTableWithZone() using
|
2002-12-31 10:09:54 +00:00
|
|
|
|
* NSDefaultMallocZone().<br />
|
|
|
|
|
* Returns a (pointer to) an NSMapTable space for which is allocated
|
|
|
|
|
* in the default zone. If capacity is small or 0, then the returned
|
|
|
|
|
* table has a reasonable capacity.
|
2002-01-30 13:05:35 +00:00
|
|
|
|
*/
|
1996-02-13 02:31:48 +00:00
|
|
|
|
NSMapTable *
|
2002-01-30 13:05:35 +00:00
|
|
|
|
NSCreateMapTable(
|
|
|
|
|
NSMapTableKeyCallBacks keyCallBacks,
|
|
|
|
|
NSMapTableValueCallBacks valueCallBacks,
|
|
|
|
|
unsigned int capacity)
|
1996-02-13 02:31:48 +00:00
|
|
|
|
{
|
1996-02-22 15:25:44 +00:00
|
|
|
|
return NSCreateMapTableWithZone(keyCallBacks, valueCallBacks,
|
2002-01-30 13:05:35 +00:00
|
|
|
|
capacity, NSDefaultMallocZone());
|
1996-02-13 02:31:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* Create a new map table using the supplied callbacks structures.
|
|
|
|
|
* If any functions in the callback structures are null the default
|
2002-12-31 10:09:54 +00:00
|
|
|
|
* values are used ... as for non-owned pointers.<br />
|
|
|
|
|
* Of course, if you send 0 for zone, then the map table will be
|
|
|
|
|
* created in NSDefaultMallocZone().<br />
|
2002-01-30 13:05:35 +00:00
|
|
|
|
* The table will be created with the specified capacity ... ie ready
|
2002-12-31 10:09:54 +00:00
|
|
|
|
* to hold at least that many items.
|
2002-01-30 13:05:35 +00:00
|
|
|
|
*/
|
1996-02-13 02:31:48 +00:00
|
|
|
|
NSMapTable *
|
2002-01-30 13:05:35 +00:00
|
|
|
|
NSCreateMapTableWithZone(
|
|
|
|
|
NSMapTableKeyCallBacks keyCallBacks,
|
|
|
|
|
NSMapTableValueCallBacks valueCallBacks,
|
2002-02-13 22:25:38 +00:00
|
|
|
|
unsigned int capacity,
|
2002-01-30 13:05:35 +00:00
|
|
|
|
NSZone *zone)
|
|
|
|
|
{
|
|
|
|
|
GSIMapTable table;
|
|
|
|
|
|
|
|
|
|
table = (GSIMapTable)NSZoneMalloc(zone, sizeof(GSIMapTable_t));
|
|
|
|
|
GSIMapInitWithZoneAndCapacity(table, zone, capacity);
|
|
|
|
|
table->extra.k = keyCallBacks;
|
|
|
|
|
table->extra.v = valueCallBacks;
|
|
|
|
|
|
|
|
|
|
if (table->extra.k.hash == 0)
|
|
|
|
|
table->extra.k.hash = NSNonOwnedPointerMapKeyCallBacks.hash;
|
|
|
|
|
if (table->extra.k.isEqual == 0)
|
|
|
|
|
table->extra.k.isEqual = NSNonOwnedPointerMapKeyCallBacks.isEqual;
|
|
|
|
|
if (table->extra.k.retain == 0)
|
|
|
|
|
table->extra.k.retain = NSNonOwnedPointerMapKeyCallBacks.retain;
|
|
|
|
|
if (table->extra.k.release == 0)
|
|
|
|
|
table->extra.k.release = NSNonOwnedPointerMapKeyCallBacks.release;
|
|
|
|
|
if (table->extra.k.describe == 0)
|
|
|
|
|
table->extra.k.describe = NSNonOwnedPointerMapKeyCallBacks.describe;
|
|
|
|
|
|
|
|
|
|
if (table->extra.v.retain == 0)
|
|
|
|
|
table->extra.v.retain = NSNonOwnedPointerMapValueCallBacks.retain;
|
|
|
|
|
if (table->extra.v.release == 0)
|
|
|
|
|
table->extra.v.release = NSNonOwnedPointerMapValueCallBacks.release;
|
|
|
|
|
if (table->extra.v.describe == 0)
|
|
|
|
|
table->extra.v.describe = NSNonOwnedPointerMapValueCallBacks.describe;
|
|
|
|
|
|
|
|
|
|
return (NSMapTable*)table;
|
1996-02-13 02:31:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* Function to be called when finished with the enumerator.
|
2002-05-28 05:23:36 +00:00
|
|
|
|
* This permits memory used by the enumerator to be released!
|
2002-01-30 13:05:35 +00:00
|
|
|
|
*/
|
1996-02-13 02:31:48 +00:00
|
|
|
|
void
|
2002-01-30 13:05:35 +00:00
|
|
|
|
NSEndMapTableEnumeration(NSMapEnumerator *enumerator)
|
1996-02-13 02:31:48 +00:00
|
|
|
|
{
|
2002-01-31 19:15:21 +00:00
|
|
|
|
if (enumerator == 0)
|
|
|
|
|
{
|
2002-02-02 07:40:35 +00:00
|
|
|
|
NSWarnFLog(@"Nul enumerator argument supplied");
|
2002-05-28 05:23:36 +00:00
|
|
|
|
return;
|
2002-01-31 19:15:21 +00:00
|
|
|
|
}
|
2002-05-28 11:30:15 +00:00
|
|
|
|
GSIMapEndEnumerator((GSIMapEnumerator)enumerator);
|
1996-02-13 02:31:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* Return an enumerator for stepping through a map table using the
|
|
|
|
|
* NSNextMapEnumeratorPair() function.
|
|
|
|
|
*/
|
1996-02-13 02:31:48 +00:00
|
|
|
|
NSMapEnumerator
|
|
|
|
|
NSEnumerateMapTable(NSMapTable *table)
|
|
|
|
|
{
|
2002-01-31 19:15:21 +00:00
|
|
|
|
if (table == 0)
|
|
|
|
|
{
|
|
|
|
|
NSMapEnumerator v = {0, 0};
|
|
|
|
|
|
2002-02-02 07:40:35 +00:00
|
|
|
|
NSWarnFLog(@"Nul table argument supplied");
|
2002-01-31 19:15:21 +00:00
|
|
|
|
return v;
|
|
|
|
|
}
|
2002-01-30 13:05:35 +00:00
|
|
|
|
return GSIMapEnumeratorForMap((GSIMapTable)table);
|
1996-02-13 02:31:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/**
|
2002-12-31 10:09:54 +00:00
|
|
|
|
* Destroy the map table and relase its contents.<br />
|
|
|
|
|
* Releases all the keys and values of table (using the key and
|
|
|
|
|
* value callbacks specified at the time of table's creation),
|
|
|
|
|
* and then proceeds to deallocate the space allocated for table itself.
|
2002-01-30 13:05:35 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
NSFreeMapTable(NSMapTable *table)
|
1996-02-13 02:31:48 +00:00
|
|
|
|
{
|
2002-01-31 19:15:21 +00:00
|
|
|
|
if (table == 0)
|
|
|
|
|
{
|
2002-02-02 07:40:35 +00:00
|
|
|
|
NSWarnFLog(@"Nul table argument supplied");
|
2002-01-31 19:15:21 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSZone *z = ((GSIMapTable)table)->zone;
|
1996-02-13 02:31:48 +00:00
|
|
|
|
|
2002-01-31 19:15:21 +00:00
|
|
|
|
GSIMapEmptyMap((GSIMapTable)table);
|
|
|
|
|
NSZoneFree(z, table);
|
|
|
|
|
}
|
1996-02-13 02:31:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/**
|
2002-08-20 15:07:58 +00:00
|
|
|
|
* Returns the value for the specified key, or a null pointer if the
|
2002-01-30 13:05:35 +00:00
|
|
|
|
* key is not found in the table.
|
|
|
|
|
*/
|
|
|
|
|
void *
|
|
|
|
|
NSMapGet(NSMapTable *table, const void *key)
|
1996-02-13 02:31:48 +00:00
|
|
|
|
{
|
2002-05-06 07:15:01 +00:00
|
|
|
|
GSIMapNode n;
|
1996-02-13 02:31:48 +00:00
|
|
|
|
|
2002-01-31 19:15:21 +00:00
|
|
|
|
if (table == 0)
|
|
|
|
|
{
|
2002-02-02 07:40:35 +00:00
|
|
|
|
NSWarnFLog(@"Nul table argument supplied");
|
2002-01-31 19:15:21 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
n = GSIMapNodeForKey((GSIMapTable)table, (GSIMapKey)key);
|
2002-01-30 13:05:35 +00:00
|
|
|
|
if (n == 0)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return n->value.ptr;
|
|
|
|
|
}
|
1996-02-13 02:31:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* Adds the key and value to table.<br />
|
|
|
|
|
* If an equal key is already in table, replaces its mapped value
|
|
|
|
|
* with the new one, without changing the key itsself.<br />
|
2002-12-31 10:09:54 +00:00
|
|
|
|
* If key is equal to the notAKeyMarker field of the table's
|
2002-01-30 13:05:35 +00:00
|
|
|
|
* NSMapTableKeyCallBacks, raises an NSInvalidArgumentException.
|
|
|
|
|
*/
|
1996-02-13 02:31:48 +00:00
|
|
|
|
void
|
|
|
|
|
NSMapInsert(NSMapTable *table, const void *key, const void *value)
|
|
|
|
|
{
|
2002-01-30 13:05:35 +00:00
|
|
|
|
GSIMapTable t = (GSIMapTable)table;
|
2002-03-08 07:11:10 +00:00
|
|
|
|
GSIMapNode n;
|
1996-02-13 02:31:48 +00:00
|
|
|
|
|
2002-01-31 19:15:21 +00:00
|
|
|
|
if (table == 0)
|
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
2002-08-20 15:07:58 +00:00
|
|
|
|
format: @"Attempt to place key-value in null table"];
|
2002-01-31 19:15:21 +00:00
|
|
|
|
}
|
2002-01-30 13:05:35 +00:00
|
|
|
|
if (key == t->extra.k.notAKeyMarker)
|
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
|
format: @"Attempt to place notAKeyMarker in map table"];
|
|
|
|
|
}
|
2002-03-08 07:11:10 +00:00
|
|
|
|
n = GSIMapNodeForKey(t, (GSIMapKey)key);
|
|
|
|
|
if (n == 0)
|
|
|
|
|
{
|
|
|
|
|
GSIMapAddPair(t, (GSIMapKey)key, (GSIMapVal)value);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GSIMapVal tmp = n->value;
|
|
|
|
|
|
|
|
|
|
n->value = (GSIMapVal)value;
|
|
|
|
|
GSI_MAP_RETAIN_VAL(t, n->value);
|
|
|
|
|
GSI_MAP_RELEASE_VAL(t, tmp);
|
|
|
|
|
}
|
1996-02-13 02:31:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* Adds the key and value to table and returns nul.<br />
|
|
|
|
|
* If an equal key is already in table, returns the old key
|
|
|
|
|
* instead of adding the new key-value pair.<br />
|
2002-12-31 10:09:54 +00:00
|
|
|
|
* If key is equal to the notAKeyMarker field of the table's
|
2002-01-30 13:05:35 +00:00
|
|
|
|
* NSMapTableKeyCallBacks, raises an NSInvalidArgumentException.
|
|
|
|
|
*/
|
1996-02-13 02:31:48 +00:00
|
|
|
|
void *
|
|
|
|
|
NSMapInsertIfAbsent(NSMapTable *table, const void *key, const void *value)
|
|
|
|
|
{
|
2002-01-30 13:05:35 +00:00
|
|
|
|
GSIMapTable t = (GSIMapTable)table;
|
|
|
|
|
GSIMapNode n;
|
|
|
|
|
|
2002-01-31 19:15:21 +00:00
|
|
|
|
if (table == 0)
|
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
2002-08-20 15:07:58 +00:00
|
|
|
|
format: @"Attempt to place key-value in null table"];
|
2002-01-31 19:15:21 +00:00
|
|
|
|
}
|
2002-01-30 13:05:35 +00:00
|
|
|
|
if (key == t->extra.k.notAKeyMarker)
|
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
|
format: @"Attempt to place notAKeyMarker in map table"];
|
|
|
|
|
}
|
|
|
|
|
n = GSIMapNodeForKey(t, (GSIMapKey)key);
|
|
|
|
|
if (n == 0)
|
|
|
|
|
{
|
|
|
|
|
GSIMapAddPair(t, (GSIMapKey)key, (GSIMapVal)value);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
1996-02-22 15:25:44 +00:00
|
|
|
|
else
|
2002-01-30 13:05:35 +00:00
|
|
|
|
{
|
|
|
|
|
return n->key.ptr;
|
|
|
|
|
}
|
1996-02-13 02:31:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* Adds the key and value to table and returns nul.<br />
|
|
|
|
|
* If an equal key is already in table, raises an NSInvalidArgumentException.
|
2002-12-31 10:09:54 +00:00
|
|
|
|
* <br />If key is equal to the notAKeyMarker field of the table's
|
2002-01-30 13:05:35 +00:00
|
|
|
|
* NSMapTableKeyCallBacks, raises an NSInvalidArgumentException.
|
|
|
|
|
*/
|
1996-02-13 02:31:48 +00:00
|
|
|
|
void
|
|
|
|
|
NSMapInsertKnownAbsent(NSMapTable *table, const void *key, const void *value)
|
|
|
|
|
{
|
2002-01-30 13:05:35 +00:00
|
|
|
|
GSIMapTable t = (GSIMapTable)table;
|
|
|
|
|
GSIMapNode n;
|
|
|
|
|
|
2002-01-31 19:15:21 +00:00
|
|
|
|
if (table == 0)
|
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
2002-08-20 15:07:58 +00:00
|
|
|
|
format: @"Attempt to place key-value in null table"];
|
2002-01-31 19:15:21 +00:00
|
|
|
|
}
|
2002-01-30 13:05:35 +00:00
|
|
|
|
if (key == t->extra.k.notAKeyMarker)
|
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
|
format: @"Attempt to place notAKeyMarker in map table"];
|
|
|
|
|
}
|
|
|
|
|
n = GSIMapNodeForKey(t, (GSIMapKey)key);
|
|
|
|
|
if (n == 0)
|
|
|
|
|
{
|
|
|
|
|
GSIMapAddPair(t, (GSIMapKey)key, (GSIMapVal)value);
|
|
|
|
|
}
|
1996-02-13 02:31:48 +00:00
|
|
|
|
else
|
2002-01-30 13:05:35 +00:00
|
|
|
|
{
|
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
|
format: @"NSMapInsertKnownAbsent ... key not absent"];
|
|
|
|
|
}
|
1996-02-13 02:31:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* Returns a flag to say whether the table contains the specified key.
|
|
|
|
|
* Returns the original key and the value it maps to.<br />
|
|
|
|
|
* The GNUstep implementation checks originalKey and value to see if
|
2002-08-20 15:07:58 +00:00
|
|
|
|
* they are null pointers, and only updates them if non-null.
|
2002-01-30 13:05:35 +00:00
|
|
|
|
*/
|
|
|
|
|
BOOL
|
|
|
|
|
NSMapMember(NSMapTable *table, const void *key,
|
|
|
|
|
void **originalKey, void **value)
|
|
|
|
|
{
|
2002-01-31 19:15:21 +00:00
|
|
|
|
GSIMapNode n;
|
2002-01-30 13:05:35 +00:00
|
|
|
|
|
2002-01-31 19:15:21 +00:00
|
|
|
|
if (table == 0)
|
|
|
|
|
{
|
2002-02-02 07:40:35 +00:00
|
|
|
|
NSWarnFLog(@"Nul table argument supplied");
|
2002-01-31 19:15:21 +00:00
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
n = GSIMapNodeForKey((GSIMapTable)table, (GSIMapKey)key);
|
2002-01-30 13:05:35 +00:00
|
|
|
|
if (n == 0)
|
|
|
|
|
{
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (originalKey != 0)
|
|
|
|
|
{
|
|
|
|
|
*originalKey = n->key.ptr;
|
|
|
|
|
}
|
|
|
|
|
if (value != 0)
|
|
|
|
|
{
|
|
|
|
|
*value = n->value.ptr;
|
|
|
|
|
}
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
}
|
1996-02-13 02:31:48 +00:00
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/**
|
2002-12-31 10:09:54 +00:00
|
|
|
|
* Remove the specified key from the table (if present).<br />
|
|
|
|
|
* Causes the key and its associated value to be released.
|
2002-01-30 13:05:35 +00:00
|
|
|
|
*/
|
1996-02-13 02:31:48 +00:00
|
|
|
|
void
|
|
|
|
|
NSMapRemove(NSMapTable *table, const void *key)
|
|
|
|
|
{
|
2002-01-31 19:15:21 +00:00
|
|
|
|
if (table == 0)
|
|
|
|
|
{
|
2002-02-02 07:40:35 +00:00
|
|
|
|
NSWarnFLog(@"Nul table argument supplied");
|
2002-01-31 19:15:21 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2002-01-30 13:05:35 +00:00
|
|
|
|
GSIMapRemoveKey((GSIMapTable)table, (GSIMapKey)key);
|
1996-02-13 02:31:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/**
|
|
|
|
|
* Step through the map table ... return the next key-value pair and
|
|
|
|
|
* return YES, or hit the end of the table and return NO.<br />
|
2002-12-31 10:09:54 +00:00
|
|
|
|
* The enumerator parameter is a value supplied by NSEnumerateMapTable()
|
|
|
|
|
* and must be destroyed using NSEndMapTableEnumeration().<br />
|
2002-01-30 13:05:35 +00:00
|
|
|
|
* The GNUstep implementation permits either key or value to be a
|
2002-08-20 15:07:58 +00:00
|
|
|
|
* null pointer, and refrains from attempting to return the appropriate
|
2002-01-30 13:05:35 +00:00
|
|
|
|
* result in that case.
|
|
|
|
|
*/
|
|
|
|
|
BOOL
|
|
|
|
|
NSNextMapEnumeratorPair(NSMapEnumerator *enumerator,
|
|
|
|
|
void **key, void **value)
|
|
|
|
|
{
|
2002-01-31 19:15:21 +00:00
|
|
|
|
GSIMapNode n;
|
2002-01-30 13:05:35 +00:00
|
|
|
|
|
2002-01-31 19:15:21 +00:00
|
|
|
|
if (enumerator == 0)
|
|
|
|
|
{
|
2002-02-02 07:40:35 +00:00
|
|
|
|
NSWarnFLog(@"Nul enumerator argument supplied");
|
2002-01-31 19:15:21 +00:00
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
n = GSIMapEnumeratorNextNode((GSIMapEnumerator)enumerator);
|
2002-01-30 13:05:35 +00:00
|
|
|
|
if (n == 0)
|
|
|
|
|
{
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (key != 0)
|
|
|
|
|
{
|
|
|
|
|
*key = n->key.ptr;
|
|
|
|
|
}
|
2002-02-02 07:40:35 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSWarnFLog(@"Nul key return address");
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
if (value != 0)
|
|
|
|
|
{
|
|
|
|
|
*value = n->value.ptr;
|
|
|
|
|
}
|
2002-02-02 07:40:35 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSWarnFLog(@"Nul value return address");
|
|
|
|
|
}
|
2002-01-30 13:05:35 +00:00
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
}
|
1996-02-13 02:31:48 +00:00
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/**
|
2002-12-31 10:09:54 +00:00
|
|
|
|
* Empty the map table (releasing every key and value),
|
|
|
|
|
* but preserve its capacity.
|
2002-01-30 13:05:35 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
NSResetMapTable(NSMapTable *table)
|
|
|
|
|
{
|
2002-01-31 19:15:21 +00:00
|
|
|
|
if (table == 0)
|
|
|
|
|
{
|
2002-02-02 07:40:35 +00:00
|
|
|
|
NSWarnFLog(@"Nul table argument supplied");
|
2002-01-31 19:15:21 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GSIMapCleanMap((GSIMapTable)table);
|
|
|
|
|
}
|
2002-01-30 13:05:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns a string describing the table contents.<br />
|
|
|
|
|
* For each key-value pair, a string of the form "key = value;\n"
|
|
|
|
|
* is appended. The appropriate describe functions are used to generate
|
|
|
|
|
* the strings for each key and value.
|
|
|
|
|
*/
|
1996-02-13 02:31:48 +00:00
|
|
|
|
NSString *
|
|
|
|
|
NSStringFromMapTable(NSMapTable *table)
|
|
|
|
|
{
|
2002-01-30 13:05:35 +00:00
|
|
|
|
GSIMapTable t = (GSIMapTable)table;
|
|
|
|
|
NSMutableString *string;
|
|
|
|
|
NSMapEnumerator enumerator;
|
|
|
|
|
void *key;
|
|
|
|
|
void *value;
|
1996-02-13 02:31:48 +00:00
|
|
|
|
|
2002-01-31 19:15:21 +00:00
|
|
|
|
if (table == 0)
|
|
|
|
|
{
|
2002-02-02 07:40:35 +00:00
|
|
|
|
NSWarnFLog(@"Nul table argument supplied");
|
2002-01-31 19:15:21 +00:00
|
|
|
|
return nil;
|
|
|
|
|
}
|
2002-01-30 13:05:35 +00:00
|
|
|
|
string = [NSMutableString stringWithCapacity: 0];
|
1996-02-13 02:31:48 +00:00
|
|
|
|
enumerator = NSEnumerateMapTable(table);
|
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
|
/*
|
|
|
|
|
* Now, just step through the elements of the table, and add their
|
|
|
|
|
* descriptions to the string.
|
|
|
|
|
*/
|
|
|
|
|
while (NSNextMapEnumeratorPair(&enumerator, &key, &value) == YES)
|
|
|
|
|
{
|
|
|
|
|
[string appendFormat: @"%@ = %@;\n",
|
|
|
|
|
(t->extra.k.describe)(table, key),
|
|
|
|
|
(t->extra.v.describe)(table, value)];
|
|
|
|
|
}
|
2002-05-28 05:23:36 +00:00
|
|
|
|
NSEndMapTableEnumeration(&enumerator);
|
1996-03-22 00:36:13 +00:00
|
|
|
|
return string;
|
1996-02-13 02:31:48 +00:00
|
|
|
|
}
|
2002-01-30 13:05:35 +00:00
|
|
|
|
|
2002-12-31 10:09:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* These are to increase readabilty locally. */
|
|
|
|
|
typedef unsigned int (*NSMT_hash_func_t)(NSMapTable *, const void *);
|
|
|
|
|
typedef BOOL (*NSMT_is_equal_func_t)(NSMapTable *, const void *, const void *);
|
|
|
|
|
typedef void (*NSMT_retain_func_t)(NSMapTable *, const void *);
|
|
|
|
|
typedef void (*NSMT_release_func_t)(NSMapTable *, void *);
|
|
|
|
|
typedef NSString *(*NSMT_describe_func_t)(NSMapTable *, const void *);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** For keys that are pointer-sized or smaller quantities. */
|
|
|
|
|
const NSMapTableKeyCallBacks NSIntMapKeyCallBacks =
|
|
|
|
|
{
|
|
|
|
|
(NSMT_hash_func_t) _NS_int_hash,
|
|
|
|
|
(NSMT_is_equal_func_t) _NS_int_is_equal,
|
|
|
|
|
(NSMT_retain_func_t) _NS_int_retain,
|
|
|
|
|
(NSMT_release_func_t) _NS_int_release,
|
|
|
|
|
(NSMT_describe_func_t) _NS_int_describe,
|
|
|
|
|
NSNotAnIntMapKey
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** For keys that are pointers not freed. */
|
|
|
|
|
const NSMapTableKeyCallBacks NSNonOwnedPointerMapKeyCallBacks =
|
|
|
|
|
{
|
|
|
|
|
(NSMT_hash_func_t) _NS_non_owned_void_p_hash,
|
|
|
|
|
(NSMT_is_equal_func_t) _NS_non_owned_void_p_is_equal,
|
|
|
|
|
(NSMT_retain_func_t) _NS_non_owned_void_p_retain,
|
|
|
|
|
(NSMT_release_func_t) _NS_non_owned_void_p_release,
|
|
|
|
|
(NSMT_describe_func_t) _NS_non_owned_void_p_describe,
|
|
|
|
|
NSNotAPointerMapKey
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** For keys that are pointers not freed, or 0. */
|
|
|
|
|
const NSMapTableKeyCallBacks NSNonOwnedPointerOrNullMapKeyCallBacks =
|
|
|
|
|
{
|
|
|
|
|
(NSMT_hash_func_t) _NS_non_owned_void_p_hash,
|
|
|
|
|
(NSMT_is_equal_func_t) _NS_non_owned_void_p_is_equal,
|
|
|
|
|
(NSMT_retain_func_t) _NS_non_owned_void_p_retain,
|
|
|
|
|
(NSMT_release_func_t) _NS_non_owned_void_p_release,
|
|
|
|
|
(NSMT_describe_func_t) _NS_non_owned_void_p_describe,
|
|
|
|
|
NSNotAPointerMapKey
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** For sets of objects without retaining and releasing. */
|
|
|
|
|
const NSMapTableKeyCallBacks NSNonRetainedObjectMapKeyCallBacks =
|
|
|
|
|
{
|
|
|
|
|
(NSMT_hash_func_t) _NS_non_retained_id_hash,
|
|
|
|
|
(NSMT_is_equal_func_t) _NS_non_retained_id_is_equal,
|
|
|
|
|
(NSMT_retain_func_t) _NS_non_retained_id_retain,
|
|
|
|
|
(NSMT_release_func_t) _NS_non_retained_id_release,
|
|
|
|
|
(NSMT_describe_func_t) _NS_non_retained_id_describe,
|
|
|
|
|
NSNotAPointerMapKey
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** For keys that are objects. */
|
|
|
|
|
const NSMapTableKeyCallBacks NSObjectMapKeyCallBacks =
|
|
|
|
|
{
|
|
|
|
|
(NSMT_hash_func_t) _NS_id_hash,
|
|
|
|
|
(NSMT_is_equal_func_t) _NS_id_is_equal,
|
|
|
|
|
(NSMT_retain_func_t) _NS_id_retain,
|
|
|
|
|
(NSMT_release_func_t) _NS_id_release,
|
|
|
|
|
(NSMT_describe_func_t) _NS_id_describe,
|
|
|
|
|
NSNotAPointerMapKey
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** For keys that are pointers with transfer of ownership upon insertion. */
|
|
|
|
|
const NSMapTableKeyCallBacks NSOwnedPointerMapKeyCallBacks =
|
|
|
|
|
{
|
|
|
|
|
(NSMT_hash_func_t) _NS_owned_void_p_hash,
|
|
|
|
|
(NSMT_is_equal_func_t) _NS_owned_void_p_is_equal,
|
|
|
|
|
(NSMT_retain_func_t) _NS_owned_void_p_retain,
|
|
|
|
|
(NSMT_release_func_t) _NS_owned_void_p_release,
|
|
|
|
|
(NSMT_describe_func_t) _NS_owned_void_p_describe,
|
|
|
|
|
NSNotAPointerMapKey
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** For values that are pointer-sized integer quantities. */
|
|
|
|
|
const NSMapTableValueCallBacks NSIntMapValueCallBacks =
|
|
|
|
|
{
|
|
|
|
|
(NSMT_retain_func_t) _NS_int_retain,
|
|
|
|
|
(NSMT_release_func_t) _NS_int_release,
|
|
|
|
|
(NSMT_describe_func_t) _NS_int_describe
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** For values that are pointers not freed. */
|
|
|
|
|
const NSMapTableValueCallBacks NSNonOwnedPointerMapValueCallBacks =
|
|
|
|
|
{
|
|
|
|
|
(NSMT_retain_func_t) _NS_non_owned_void_p_retain,
|
|
|
|
|
(NSMT_release_func_t) _NS_non_owned_void_p_release,
|
|
|
|
|
(NSMT_describe_func_t) _NS_non_owned_void_p_describe
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** For sets of objects without retaining and releasing. */
|
|
|
|
|
const NSMapTableValueCallBacks NSNonRetainedObjectMapValueCallBacks =
|
|
|
|
|
{
|
|
|
|
|
(NSMT_retain_func_t) _NS_non_retained_id_retain,
|
|
|
|
|
(NSMT_release_func_t) _NS_non_retained_id_release,
|
|
|
|
|
(NSMT_describe_func_t) _NS_non_retained_id_describe
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** For values that are objects. */
|
|
|
|
|
const NSMapTableValueCallBacks NSObjectMapValueCallBacks =
|
|
|
|
|
{
|
|
|
|
|
(NSMT_retain_func_t) _NS_id_retain,
|
|
|
|
|
(NSMT_release_func_t) _NS_id_release,
|
|
|
|
|
(NSMT_describe_func_t) _NS_id_describe
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** For values that are pointers with transfer of ownership upon insertion. */
|
|
|
|
|
const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks =
|
|
|
|
|
{
|
|
|
|
|
(NSMT_retain_func_t) _NS_owned_void_p_retain,
|
|
|
|
|
(NSMT_release_func_t) _NS_owned_void_p_release,
|
|
|
|
|
(NSMT_describe_func_t) _NS_owned_void_p_describe
|
|
|
|
|
};
|
2002-01-30 13:05:35 +00:00
|
|
|
|
|