~ubuntu-branches/ubuntu/trusty/gnustep-base/trusty

« back to all changes in this revision

Viewing changes to Headers/Foundation/NSHashTable.h

Tags: upstream-1.20.0
ImportĀ upstreamĀ versionĀ 1.20.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
/**** Included Headers *******************************************************/
33
33
 
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>
37
37
 
38
38
#if     defined(__cplusplus)
39
39
extern "C" {
40
40
#endif
41
41
 
 
42
 
 
43
@class NSArray, NSSet, NSHashTable;
 
44
 
42
45
/**** Type, Constant, and Macro Definitions **********************************/
43
46
 
44
 
/**
45
 
 * Hash table type ... an opaque pointer to a data structure.
46
 
 */
47
 
typedef void* NSHashTable;
 
47
enum {
 
48
  NSHashTableStrongMemory
 
49
    = NSPointerFunctionsStrongMemory,
 
50
  NSHashTableZeroingWeakMemory
 
51
    = NSPointerFunctionsZeroingWeakMemory,
 
52
  NSHashTableCopyIn
 
53
    = NSPointerFunctionsCopyIn,
 
54
  NSHashTableObjectPointerPersonality
 
55
    = NSPointerFunctionsObjectPointerPersonality,
 
56
};
 
57
 
 
58
typedef NSUInteger NSHashTableOptions;
 
59
 
 
60
@interface NSHashTable : NSObject <NSCopying, NSCoding, NSFastEnumeration>
 
61
 
 
62
+ (id) hashTableWithOptions: (NSPointerFunctionsOptions)options;
 
63
 
 
64
+ (id) hashTableWithWeakObjects;
 
65
 
 
66
- (id) initWithOptions: (NSPointerFunctionsOptions)options
 
67
              capacity: (NSUInteger)initialCapacity;
 
68
 
 
69
- (id) initWithPointerFunctions: (NSPointerFunctions*)functions
 
70
                       capacity: (NSUInteger)initialCapacity;
 
71
 
 
72
/** Adds the object to the receiver.
 
73
 */
 
74
- (void) addObject: (id)object;
 
75
 
 
76
/** Returns an array containing all objects in the receiver.
 
77
 */
 
78
- (NSArray*) allObjects;
 
79
 
 
80
/** Returns any objct from the receiver, or nil if the receiver contains no
 
81
 * objects.
 
82
 */
 
83
- (id) anyObject;
 
84
 
 
85
/** Returns YES if the receiver contains an item equal to anObject, or NO
 
86
 * otherwise.
 
87
 */
 
88
- (BOOL) containsObject: (id)anObject;
 
89
 
 
90
/** Return the number of items atored in the receiver.
 
91
 */
 
92
- (NSUInteger) count;
 
93
 
 
94
/** Removes from the receiver any items which are not also present in 'other'.
 
95
 */
 
96
- (void) intersectHashTable: (NSHashTable*)other;
 
97
 
 
98
/** Returns YES if the receiver and 'other' contain any items in common.
 
99
 */
 
100
- (BOOL) intersectsHashTable: (NSHashTable*)other;
 
101
 
 
102
/** Returns YES if the receiver and 'other' contain equal sets of items.
 
103
 */
 
104
- (BOOL) isEqualToHashTable: (NSHashTable*)other;
 
105
 
 
106
/** Returns YES fi all the items in the receiver are also present in 'other'
 
107
 */
 
108
- (BOOL) isSubsetOfHashTable: (NSHashTable*)other;
 
109
 
 
110
/** Returns an item stored in the receiver which is equal to the supplied
 
111
 * object argument, or nil if no matchi is found.
 
112
 */
 
113
- (id) member: (id)object;
 
114
 
 
115
/** Removes from the receivr all those items which are prsent in both
 
116
 * the receiver and in 'other'.
 
117
 */
 
118
- (void) minusHashTable: (NSHashTable*)other;
 
119
 
 
120
/** Return an enumerator for the receiver.
 
121
 */
 
122
- (NSEnumerator*) objectEnumerator;
 
123
 
 
124
/** Return an NSPointerFunctions value describing the functions used by the
 
125
 * receiver to handle its contents.
 
126
 */
 
127
- (NSPointerFunctions*) pointerFunctions;
 
128
 
 
129
/** Removes all objects.
 
130
 */
 
131
- (void) removeAllObjects;
 
132
 
 
133
/** Remove the object (or any equal object) from the receiver.
 
134
 */
 
135
- (void) removeObject: (id)object;
 
136
 
 
137
/** Returns a set containing all the objects in the receiver.
 
138
 */
 
139
- (NSSet*) setRepresentation; 
 
140
 
 
141
/** Adds to the receiver thse items present in 'other' which were
 
142
 * not present in the receiver.
 
143
 */
 
144
- (void) unionHashTable: (NSHashTable*)other;
 
145
 
 
146
 
 
147
@end
 
148
 
48
149
 
49
150
/**
50
151
 * Type for enumerating.<br />
56
157
/** Callback functions for an NSHashTable.  See NSCreateHashTable() . <br />*/
57
158
typedef struct _NSHashTableCallBacks
58
159
{
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 *);
64
165
 
65
166
  /** <code>BOOL (*isEqual)(NSHashTable *, const void *, const void *)</code>
66
167
   *  ... Comparison function.  The default if NULL uses '<code>==</code>'.
91
192
 
92
193
GS_EXPORT NSHashTable *
93
194
NSCreateHashTable(NSHashTableCallBacks callBacks,
94
 
                  unsigned int capacity);
 
195
                  NSUInteger capacity);
95
196
 
96
197
GS_EXPORT NSHashTable *
97
198
NSCreateHashTableWithZone(NSHashTableCallBacks callBacks,
98
 
                          unsigned int capacity,
 
199
                          NSUInteger capacity,
99
200
                          NSZone *zone);
100
201
 
101
202
GS_EXPORT NSHashTable *
110
211
GS_EXPORT BOOL
111
212
NSCompareHashTables(NSHashTable *table1, NSHashTable *table2);
112
213
 
113
 
GS_EXPORT unsigned int
 
214
GS_EXPORT NSUInteger
114
215
NSCountHashTable(NSHashTable *table);
115
216
 
116
217
GS_EXPORT void *