This is NSHashTable.h in view mode; [Download] [Up]
/*
Copyright (C) 1996
Ovidiu Predescu <ovidiu@bx.logicnet.ro>
Mircea Oancea <mircea@jupiter.elcom.pub.ro>
Author: Ovidiu Predescu <ovidiu@bx.logicnet.ro>
This file is part of the FoundationExtensions library.
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; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __NSHashTable_h__
#define __NSHashTable_h__
#include <Foundation/NSObject.h>
@class NSArray;
struct _NSHashTable;
typedef struct _NSHashTableCallBacks {
unsigned (*hash)(struct _NSHashTable *table, const void *anObject);
BOOL (*isEqual)(struct _NSHashTable *table,
const void *anObject1, const void *anObject2);
void (*retain)(struct _NSHashTable *table, const void *anObject);
void (*release)(struct _NSHashTable *table, void *anObject);
NSString *(*describe)(struct _NSHashTable *table, const void *anObject);
} NSHashTableCallBacks;
struct _NSHashNode {
void *key;
struct _NSHashNode *next;
};
typedef struct _NSHashTable {
struct _NSHashNode **nodes;
unsigned int hashSize;
unsigned int itemsCount;
NSHashTableCallBacks callbacks;
NSZone* zone;
} NSHashTable;
typedef struct _NSHashEnumerator {
struct _NSHashTable *table;
struct _NSHashNode *node;
int bucket;
} NSHashEnumerator;
/* Predefined callback sets */
extern const NSHashTableCallBacks NSIntHashCallBacks;
extern const NSHashTableCallBacks NSNonOwnedPointerHashCallBacks;
extern const NSHashTableCallBacks NSNonRetainedObjectHashCallBacks;
extern const NSHashTableCallBacks NSObjectHashCallBacks;
extern const NSHashTableCallBacks NSOwnedPointerHashCallBacks;
extern const NSHashTableCallBacks NSPointerToStructHashCallBacks;
/* Hash Table Functions */
/* Create a Table */
NSHashTable *NSCreateHashTable(NSHashTableCallBacks callBacks,
unsigned capacity);
NSHashTable *NSCreateHashTableWithZone(NSHashTableCallBacks callBacks,
unsigned capacity, NSZone *zone);
NSHashTable *NSCopyHashTableWithZone(NSHashTable *table,
NSZone *zone);
/* Free a Table */
void NSFreeHashTable(NSHashTable *table);
void NSResetHashTable(NSHashTable *table);
/* Compare Two Tables */
BOOL NSCompareHashTables(NSHashTable *table1, NSHashTable *table2);
/* Get the Number of Items */
unsigned NSCountHashTable(NSHashTable *table);
/* Retrieve Items */
void *NSHashGet(NSHashTable *table, const void *pointer);
NSArray *NSAllHashTableObjects(NSHashTable *table);
NSHashEnumerator NSEnumerateHashTable(NSHashTable *table);
void *NSNextHashEnumeratorItem(NSHashEnumerator *enumerator);
/* Add or Remove an Item */
void NSHashInsert(NSHashTable *table, const void *pointer);
void NSHashInsertKnownAbsent(NSHashTable *table, const void *pointer);
void *NSHashInsertIfAbsent(NSHashTable *table, const void *pointer);
void NSHashRemove(NSHashTable *table, const void *pointer);
/* Get a String Representation */
NSString *NSStringFromHashTable(NSHashTable *table);
#endif /* __NSHashTable_h__ */
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.