32
32
/**** Included Headers *******************************************************/
34
#import <Foundation/NSObject.h>
34
#import <Foundation/NSEnumerator.h>
35
#import <Foundation/NSPointerFunctions.h>
35
36
#import <Foundation/NSString.h>
36
#import <Foundation/NSArray.h>
38
38
#if defined(__cplusplus)
43
@class NSArray, NSSet, NSHashTable;
42
45
/**** Type, Constant, and Macro Definitions **********************************/
45
* Hash table type ... an opaque pointer to a data structure.
47
typedef void* NSHashTable;
48
NSHashTableStrongMemory
49
= NSPointerFunctionsStrongMemory,
50
NSHashTableZeroingWeakMemory
51
= NSPointerFunctionsZeroingWeakMemory,
53
= NSPointerFunctionsCopyIn,
54
NSHashTableObjectPointerPersonality
55
= NSPointerFunctionsObjectPointerPersonality,
58
typedef NSUInteger NSHashTableOptions;
60
@interface NSHashTable : NSObject <NSCopying, NSCoding, NSFastEnumeration>
62
+ (id) hashTableWithOptions: (NSPointerFunctionsOptions)options;
64
+ (id) hashTableWithWeakObjects;
66
- (id) initWithOptions: (NSPointerFunctionsOptions)options
67
capacity: (NSUInteger)initialCapacity;
69
- (id) initWithPointerFunctions: (NSPointerFunctions*)functions
70
capacity: (NSUInteger)initialCapacity;
72
/** Adds the object to the receiver.
74
- (void) addObject: (id)object;
76
/** Returns an array containing all objects in the receiver.
78
- (NSArray*) allObjects;
80
/** Returns any objct from the receiver, or nil if the receiver contains no
85
/** Returns YES if the receiver contains an item equal to anObject, or NO
88
- (BOOL) containsObject: (id)anObject;
90
/** Return the number of items atored in the receiver.
94
/** Removes from the receiver any items which are not also present in 'other'.
96
- (void) intersectHashTable: (NSHashTable*)other;
98
/** Returns YES if the receiver and 'other' contain any items in common.
100
- (BOOL) intersectsHashTable: (NSHashTable*)other;
102
/** Returns YES if the receiver and 'other' contain equal sets of items.
104
- (BOOL) isEqualToHashTable: (NSHashTable*)other;
106
/** Returns YES fi all the items in the receiver are also present in 'other'
108
- (BOOL) isSubsetOfHashTable: (NSHashTable*)other;
110
/** Returns an item stored in the receiver which is equal to the supplied
111
* object argument, or nil if no matchi is found.
113
- (id) member: (id)object;
115
/** Removes from the receivr all those items which are prsent in both
116
* the receiver and in 'other'.
118
- (void) minusHashTable: (NSHashTable*)other;
120
/** Return an enumerator for the receiver.
122
- (NSEnumerator*) objectEnumerator;
124
/** Return an NSPointerFunctions value describing the functions used by the
125
* receiver to handle its contents.
127
- (NSPointerFunctions*) pointerFunctions;
129
/** Removes all objects.
131
- (void) removeAllObjects;
133
/** Remove the object (or any equal object) from the receiver.
135
- (void) removeObject: (id)object;
137
/** Returns a set containing all the objects in the receiver.
139
- (NSSet*) setRepresentation;
141
/** Adds to the receiver thse items present in 'other' which were
142
* not present in the receiver.
144
- (void) unionHashTable: (NSHashTable*)other;
50
151
* Type for enumerating.<br />
56
157
/** Callback functions for an NSHashTable. See NSCreateHashTable() . <br />*/
57
158
typedef struct _NSHashTableCallBacks
59
/** <code>unsigned int (*hash)(NSHashTable *, const void *)</code> ...
160
/** <code>NSUInteger (*hash)(NSHashTable *, const void *)</code> ...
60
161
* Hashing function. NOTE: Elements with equal values must have equal hash
61
162
* function values. The default if NULL uses the pointer addresses
62
163
* directly. <br/>*/
63
unsigned int (*hash)(NSHashTable *, const void *);
164
NSUInteger (*hash)(NSHashTable *, const void *);
65
166
/** <code>BOOL (*isEqual)(NSHashTable *, const void *, const void *)</code>
66
167
* ... Comparison function. The default if NULL uses '<code>==</code>'.