1996-02-13 02:35:45 +00:00
|
|
|
/* NSHashTable interface for GNUStep.
|
2002-01-30 13:05:35 +00:00
|
|
|
* Copyright (C) 1994, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
|
1996-02-13 02:35:45 +00:00
|
|
|
*
|
|
|
|
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
|
|
|
|
* Created: Mon Dec 12 23:56:03 EST 1994
|
1996-03-22 00:36:13 +00:00
|
|
|
* Updated: Thu Mar 21 15:13:46 EST 1996
|
|
|
|
* Serial: 96.03.21.06
|
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, 02111 USA.
|
2002-01-30 13:05:35 +00:00
|
|
|
*/
|
1996-02-13 02:35:45 +00:00
|
|
|
|
1996-04-17 19:36:35 +00:00
|
|
|
#ifndef __NSHashTable_h_GNUSTEP_BASE_INCLUDE
|
|
|
|
#define __NSHashTable_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
|
|
|
/**
|
|
|
|
* Hash table type ... an opaque pointer to a data structure.
|
|
|
|
*/
|
|
|
|
typedef void* NSHashTable;
|
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; } NSHashEnumerator;
|
1996-02-13 02:35:45 +00:00
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
/** Callback functions for an NSHashTable. See NSCreateHashTable() . <br />*/
|
2002-02-04 20:20:07 +00:00
|
|
|
typedef struct _NSHashTableCallBacks
|
1996-02-13 02:35:45 +00:00
|
|
|
{
|
2004-06-22 22:27:39 +00:00
|
|
|
/** <code>unsigned int (*hash)(NSHashTable *, const void *)</code> ...
|
|
|
|
* Hashing function. NOTE: Elements with equal values must have equal hash
|
|
|
|
* function values. The default if NULL uses the pointer addresses
|
|
|
|
* directly. <br/>*/
|
1996-03-22 00:36:13 +00:00
|
|
|
unsigned int (*hash)(NSHashTable *, const void *);
|
1996-02-13 02:35:45 +00:00
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
/** <code>BOOL (*isEqual)(NSHashTable *, const void *, const void *)</code>
|
|
|
|
* ... Comparison function. The default if NULL uses '<code>==</code>'.
|
|
|
|
* <br/>*/
|
1996-03-22 00:36:13 +00:00
|
|
|
BOOL (*isEqual)(NSHashTable *, const void *, const void *);
|
1996-02-13 02:35:45 +00:00
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
/** <code>void (*retain)(NSHashTable *, const void *)</code> ...
|
|
|
|
* Retaining function called when adding elements to the table.
|
|
|
|
* The default if NULL is a no-op (no reference counting). <br/> */
|
1996-03-22 00:36:13 +00:00
|
|
|
void (*retain)(NSHashTable *, const void *);
|
1996-02-13 02:35:45 +00:00
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
/** <code>void (*release)(NSHashTable *, void *)</code> ... Releasing
|
|
|
|
* function called when a data element is removed from the table.
|
|
|
|
* The default if NULL is a no-op (no reference counting).<br/>*/
|
2002-12-31 10:09:54 +00:00
|
|
|
void (*release)(NSHashTable *, void *);
|
1996-02-13 02:35:45 +00:00
|
|
|
|
2004-06-22 22:27:39 +00:00
|
|
|
/** <code>NSString *(*describe)(NSHashTable *, const void *)</code> ...
|
|
|
|
* Description function. The default if NULL prints boilerplate. <br /> */
|
1996-03-22 00:36:13 +00:00
|
|
|
NSString *(*describe)(NSHashTable *, const void *);
|
2002-02-04 20:20:07 +00:00
|
|
|
} NSHashTableCallBacks;
|
1996-02-13 02:35:45 +00:00
|
|
|
|
2000-06-14 04:03:56 +00:00
|
|
|
GS_EXPORT const NSHashTableCallBacks NSIntHashCallBacks;
|
|
|
|
GS_EXPORT const NSHashTableCallBacks NSNonOwnedPointerHashCallBacks;
|
|
|
|
GS_EXPORT const NSHashTableCallBacks NSNonRetainedObjectHashCallBacks;
|
|
|
|
GS_EXPORT const NSHashTableCallBacks NSObjectHashCallBacks;
|
|
|
|
GS_EXPORT const NSHashTableCallBacks NSOwnedPointerHashCallBacks;
|
|
|
|
GS_EXPORT const NSHashTableCallBacks NSPointerToStructHashCallBacks;
|
1996-02-13 02:35:45 +00:00
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT NSHashTable *
|
1996-03-22 00:36:13 +00:00
|
|
|
NSCreateHashTable(NSHashTableCallBacks callBacks,
|
|
|
|
unsigned int capacity);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT NSHashTable *
|
1996-03-22 00:36:13 +00:00
|
|
|
NSCreateHashTableWithZone(NSHashTableCallBacks callBacks,
|
|
|
|
unsigned int capacity,
|
|
|
|
NSZone *zone);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT NSHashTable *
|
1996-03-22 00:36:13 +00:00
|
|
|
NSCopyHashTableWithZone(NSHashTable *table, NSZone *zone);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT void
|
1996-03-22 00:36:13 +00:00
|
|
|
NSFreeHashTable(NSHashTable *table);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT void
|
1996-03-22 00:36:13 +00:00
|
|
|
NSResetHashTable(NSHashTable *table);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT BOOL
|
1996-03-22 00:36:13 +00:00
|
|
|
NSCompareHashTables(NSHashTable *table1, NSHashTable *table2);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT unsigned int
|
1996-03-22 00:36:13 +00:00
|
|
|
NSCountHashTable(NSHashTable *table);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT void *
|
2002-01-30 13:05:35 +00:00
|
|
|
NSHashGet(NSHashTable *table, const void *element);
|
1996-03-22 00:36:13 +00:00
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT NSArray *
|
1996-03-22 00:36:13 +00:00
|
|
|
NSAllHashTableObjects(NSHashTable *table);
|
|
|
|
|
2002-01-30 13:05:35 +00:00
|
|
|
GS_EXPORT void
|
|
|
|
NSEndHashTableEnumeration(NSHashEnumerator *enumerator);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT NSHashEnumerator
|
1996-03-22 00:36:13 +00:00
|
|
|
NSEnumerateHashTable(NSHashTable *table);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT void *
|
1996-03-22 00:36:13 +00:00
|
|
|
NSNextHashEnumeratorItem(NSHashEnumerator *enumerator);
|
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT void
|
2002-01-30 13:05:35 +00:00
|
|
|
NSHashInsert(NSHashTable *table, const void *element);
|
1996-03-22 00:36:13 +00:00
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT void
|
2002-01-30 13:05:35 +00:00
|
|
|
NSHashInsertKnownAbsent(NSHashTable *table, const void *element);
|
1996-03-22 00:36:13 +00:00
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT void *
|
2002-01-30 13:05:35 +00:00
|
|
|
NSHashInsertIfAbsent(NSHashTable *table, const void *element);
|
1996-03-22 00:36:13 +00:00
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT void
|
2002-01-30 13:05:35 +00:00
|
|
|
NSHashRemove(NSHashTable *table, const void *element);
|
1996-03-22 00:36:13 +00:00
|
|
|
|
2000-06-30 22:42:48 +00:00
|
|
|
GS_EXPORT NSString *
|
1996-03-22 00:36:13 +00:00
|
|
|
NSStringFromHashTable(NSHashTable *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 /* __NSHashTable_h_GNUSTEP_BASE_INCLUDE */
|