1996-02-13 02:35:45 +00:00
|
|
|
/* NSMapTable interface for GNUStep.
|
2002-01-30 13:05:35 +00:00
|
|
|
* Copyright (C) 1994, 1995, 1996, 2002 Free Software Foundation, Inc.
|
1996-02-13 02:35:45 +00:00
|
|
|
*
|
|
|
|
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
|
|
|
|
* Created: Tue Dec 13 00:05:02 EST 1994
|
1996-03-22 00:36:13 +00:00
|
|
|
* Updated: Thu Mar 21 15:12:42 EST 1996
|
|
|
|
* Serial: 96.03.21.05
|
2002-01-30 13:05:35 +00:00
|
|
|
* Modified by: Richard Frith-Macdonald <rfm@gnu.org>
|
1996-02-13 02:35:45 +00:00
|
|
|
*
|
1996-05-12 00:56:10 +00:00
|
|
|
* This file is part of the GNUstep Base Library.
|
1996-02-13 02:35:45 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2007-09-14 11:36:11 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1996-02-13 02:35:45 +00:00
|
|
|
* License as published by the Free Software Foundation; either
|
2008-06-08 10:38:33 +00:00
|
|
|
* version 2 of the License, or (at your option) any later version.
|
1996-02-13 02:35:45 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2007-09-14 11:36:11 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1996-02-13 02:35:45 +00:00
|
|
|
* License along with this library; if not, write to the Free
|
2006-10-31 07:05:46 +00:00
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02111 USA.
|
|
|
|
*/
|
1996-02-13 02:35:45 +00:00
|
|
|
|
1996-04-17 19:36:35 +00:00
|
|
|
#ifndef __NSMapTable_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
#define __NSMapTable_h_GNUSTEP_BASE_INCLUDE 1
|
2006-10-31 07:05:46 +00:00
|
|
|
#import <GNUstepBase/GSVersionMacros.h>
|
1996-02-13 02:35:45 +00:00
|
|
|
|
|
|
|
/**** Included Headers *******************************************************/
|
|
|
|
|
2006-10-31 07:05:46 +00:00
|
|
|
#import <Foundation/NSObject.h>
|
|
|
|
#import <Foundation/NSString.h>
|
|
|
|
#import <Foundation/NSArray.h>
|
1996-02-13 02:35:45 +00:00
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
1996-02-13 02:35:45 +00:00
|
|
|
/**** Type, Constant, and Macro Definitions **********************************/
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
/**
|
|
|
|
* Map table type ... an opaque pointer to a data structure.
|
|
|
|
*/
|
|
|
|
typedef void *NSMapTable;
|
1996-03-22 00:36:13 +00:00
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
/**
|
2002-12-31 10:09:54 +00:00
|
|
|
* Type for enumerating.<br />
|
|
|
|
* NB. Implementation detail ... in GNUstep the layout <strong>must</strong>
|
|
|
|
* correspond to that used by the GSIMap macros.
|
2002-01-30 13:05:35 +00:00
|
|
|
*/
|
2002-05-28 05:23:36 +00:00
|
|
|
typedef struct { void *map; void *node; size_t bucket; } NSMapEnumerator;
|
1996-02-13 02:35:45 +00:00
|
|
|
|
2002-12-31 10:09:54 +00:00
|
|
|
/**
|
|
|
|
* Callback functions for a key.
|
|
|
|
*/
|
2002-02-04 20:20:07 +00:00
|
|
|
typedef struct _NSMapTableKeyCallBacks
|
1996-02-13 02:35:45 +00:00
|
|
|
{
|
2002-12-31 10:09:54 +00:00
|
|
|
/*
|
|
|
|
* Hashing function. Must not modify the key.<br />
|
|
|
|
* NOTE: Elements with equal values must
|
|
|
|
* have equal hash function values.
|
|
|
|
*/
|
1996-03-22 00:36:13 +00:00
|
|
|
unsigned (*hash)(NSMapTable *, const void *);
|
|
|
|
|
2002-12-31 10:09:54 +00:00
|
|
|
/**
|
|
|
|
* Comparison function. Must not modify either key.
|
|
|
|
*/
|
1996-03-22 00:36:13 +00:00
|
|
|
BOOL (*isEqual)(NSMapTable *, const void *, const void *);
|
|
|
|
|
2002-12-31 10:09:54 +00:00
|
|
|
/**
|
|
|
|
* Retaining function called when adding elements to table.<br />
|
|
|
|
* Notionally this must not modify the key (the key may not
|
|
|
|
* actually have a retain count, or the retain count may be stored
|
|
|
|
* externally to the key, but in practice this often actually
|
|
|
|
* changes a counter within the key).
|
|
|
|
*/
|
1996-03-22 00:36:13 +00:00
|
|
|
void (*retain)(NSMapTable *, const void *);
|
|
|
|
|
2002-12-31 10:09:54 +00:00
|
|
|
/**
|
|
|
|
* Releasing function called when a data element is
|
|
|
|
* removed from the table. This may decrease a retain count or may
|
|
|
|
* actually destroy the key.
|
|
|
|
*/
|
|
|
|
void (*release)(NSMapTable *, void *);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Description function. Generates a string describing the key
|
2004-06-22 22:27:39 +00:00
|
|
|
* and does not modify the key itself.
|
2002-12-31 10:09:54 +00:00
|
|
|
*/
|
1996-03-22 00:36:13 +00:00
|
|
|
NSString *(*describe)(NSMapTable *, const void *);
|
|
|
|
|
2002-12-31 10:09:54 +00:00
|
|
|
/**
|
|
|
|
* Quantity that is not a key to the map table.
|
|
|
|
*/
|
1996-02-13 02:35:45 +00:00
|
|
|
const void *notAKeyMarker;
|
2002-02-04 20:20:07 +00:00
|
|
|
} NSMapTableKeyCallBacks;
|
1996-02-13 02:35:45 +00:00
|
|
|
|
2002-12-31 10:09:54 +00:00
|
|
|
/**
|
|
|
|
* Callback functions for a value.
|
|
|
|
*/
|
1996-03-22 00:36:13 +00:00
|
|
|
typedef struct _NSMapTableValueCallBacks NSMapTableValueCallBacks;
|
1996-02-13 02:35:45 +00:00
|
|
|
struct _NSMapTableValueCallBacks
|
|
|
|
{
|
2002-12-31 10:09:54 +00:00
|
|
|
/**
|
|
|
|
* Retaining function called when adding elements to table.<br />
|
|
|
|
* Notionally this must not modify the element (the element may not
|
|
|
|
* actually have a retain count, or the retain count may be stored
|
|
|
|
* externally to the element, but in practice this often actually
|
|
|
|
* changes a counter within the element).
|
|
|
|
*/
|
1996-03-22 00:36:13 +00:00
|
|
|
void (*retain)(NSMapTable *, const void *);
|
|
|
|
|
2002-12-31 10:09:54 +00:00
|
|
|
/**
|
|
|
|
* Releasing function called when a data element is
|
|
|
|
* removed from the table. This may decrease a retain count or may
|
|
|
|
* actually destroy the element.
|
|
|
|
*/
|
|
|
|
void (*release)(NSMapTable *, void *);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Description function. Generates a string describing the element
|
2004-06-22 22:27:39 +00:00
|
|
|
* and does not modify the element itself.
|
2002-12-31 10:09:54 +00:00
|
|
|
*/
|
1996-03-22 00:36:13 +00:00
|
|
|
NSString *(*describe)(NSMapTable *, const void *);
|
1996-02-13 02:35:45 +00:00
|
|
|
};
|
|
|
|
|
1996-03-22 00:36:13 +00:00
|
|
|
/* Quantities that are never map keys. */
|
2002-01-30 13:05:35 +00:00
|
|
|
#define NSNotAnIntMapKey ((const void *)0x80000000)
|
|
|
|
#define NSNotAPointerMapKey ((const void *)0xffffffff)
|
1996-02-13 02:35:45 +00:00
|
|
|
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT const NSMapTableKeyCallBacks NSIntMapKeyCallBacks;
|
|
|
|
GS_EXPORT const NSMapTableKeyCallBacks NSNonOwnedPointerMapKeyCallBacks;
|
|
|
|
GS_EXPORT const NSMapTableKeyCallBacks NSNonOwnedPointerOrNullMapKeyCallBacks;
|
|
|
|
GS_EXPORT const NSMapTableKeyCallBacks NSNonRetainedObjectMapKeyCallBacks;
|
|
|
|
GS_EXPORT const NSMapTableKeyCallBacks NSObjectMapKeyCallBacks;
|
|
|
|
GS_EXPORT const NSMapTableKeyCallBacks NSOwnedPointerMapKeyCallBacks;
|
|
|
|
GS_EXPORT const NSMapTableValueCallBacks NSIntMapValueCallBacks;
|
|
|
|
GS_EXPORT const NSMapTableValueCallBacks NSNonOwnedPointerMapValueCallBacks;
|
|
|
|
GS_EXPORT const NSMapTableValueCallBacks NSNonRetainedObjectMapValueCallBacks;
|
|
|
|
GS_EXPORT const NSMapTableValueCallBacks NSObjectMapValueCallBacks;
|
|
|
|
GS_EXPORT const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks;
|
1996-02-13 02:35:45 +00:00
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT NSMapTable *
|
1996-03-22 00:36:13 +00:00
|
|
|
NSCreateMapTable(NSMapTableKeyCallBacks keyCallBacks,
|
|
|
|
NSMapTableValueCallBacks valueCallBacks,
|
|
|
|
unsigned int capacity);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT NSMapTable *
|
1996-03-22 00:36:13 +00:00
|
|
|
NSCreateMapTableWithZone(NSMapTableKeyCallBacks keyCallBacks,
|
2002-02-13 22:25:38 +00:00
|
|
|
NSMapTableValueCallBacks valueCallBacks,
|
1996-03-22 00:36:13 +00:00
|
|
|
unsigned int capacity,
|
|
|
|
NSZone *zone);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT NSMapTable *
|
1996-03-22 00:36:13 +00:00
|
|
|
NSCopyMapTableWithZone(NSMapTable *table, NSZone *zone);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT void
|
1996-03-22 00:36:13 +00:00
|
|
|
NSFreeMapTable(NSMapTable *table);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT void
|
1996-03-22 00:36:13 +00:00
|
|
|
NSResetMapTable(NSMapTable *table);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT BOOL
|
1996-03-22 00:36:13 +00:00
|
|
|
NSCompareMapTables(NSMapTable *table1, NSMapTable *table2);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT unsigned int
|
1996-03-22 00:36:13 +00:00
|
|
|
NSCountMapTable(NSMapTable *table);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT BOOL
|
1996-03-22 00:36:13 +00:00
|
|
|
NSMapMember(NSMapTable *table,
|
|
|
|
const void *key,
|
|
|
|
void **originalKey,
|
|
|
|
void **value);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT void *
|
1996-03-22 00:36:13 +00:00
|
|
|
NSMapGet(NSMapTable *table, const void *key);
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
GS_EXPORT void
|
|
|
|
NSEndMapTableEnumeration(NSMapEnumerator *enumerator);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT NSMapEnumerator
|
1996-03-22 00:36:13 +00:00
|
|
|
NSEnumerateMapTable(NSMapTable *table);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT BOOL
|
1996-03-22 00:36:13 +00:00
|
|
|
NSNextMapEnumeratorPair(NSMapEnumerator *enumerator,
|
|
|
|
void **key,
|
|
|
|
void **value);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT NSArray *
|
1996-03-22 00:36:13 +00:00
|
|
|
NSAllMapTableKeys(NSMapTable *table);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT NSArray *
|
1996-03-22 00:36:13 +00:00
|
|
|
NSAllMapTableValues(NSMapTable *table);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT void
|
1996-03-22 00:36:13 +00:00
|
|
|
NSMapInsert(NSMapTable *table, const void *key, const void *value);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT void *
|
1996-03-22 00:36:13 +00:00
|
|
|
NSMapInsertIfAbsent(NSMapTable *table, const void *key, const void *value);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT void
|
1996-03-22 00:36:13 +00:00
|
|
|
NSMapInsertKnownAbsent(NSMapTable *table,
|
|
|
|
const void *key,
|
|
|
|
const void *value);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT void
|
1996-03-22 00:36:13 +00:00
|
|
|
NSMapRemove(NSMapTable *table, const void *key);
|
1996-02-13 02:35:45 +00:00
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT NSString *NSStringFromMapTable (NSMapTable *table);
|
1996-02-13 02:35:45 +00:00
|
|
|
|
2006-09-13 10:20:49 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1996-04-17 19:36:35 +00:00
|
|
|
#endif /* __NSMapTable_h_GNUSTEP_BASE_INCLUDE */
|