00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #if !defined(MAP_OL_GUARD)
00044 #define MAP_OL_GUARD
00045
00046 #include <ObjectiveLib/Iterator.h>
00047 #include <ObjectiveLib/Functional.h>
00048
00052 @class OLTreeMap;
00053
00072 @interface OLMap :
00073 #if defined(OL_NO_OPENSTEP)
00074 Object <OLInserter, OLStreamable>
00075 #else
00076 NSObject <OLInserter, OLStreamable, NSCopying, NSCoding>
00077 #endif
00078 {
00079 @protected
00083 OLTreeMap* tree;
00084 }
00085
00095 + (id) map;
00096
00113 + (id) mapFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last;
00114
00125 + (id) mapWithCompare: (OLStreamableFunctor<OLBoolBinaryFunction>*)comp;
00126
00137 + (id) mapWithMap: (OLMap*)right;
00138
00142
00148 - (id) init;
00149
00164 - (id) initFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last;
00165
00179 - (id) initFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last compare: (OLStreamableFunctor<OLBoolBinaryFunction>*)comp;
00180
00181 #if !defined(OL_NO_OPENSTEP)
00182
00192 - (id) initWithCoder: (NSCoder*)decoder;
00193 #endif
00194
00202 - (id) initWithCompare: (OLStreamableFunctor<OLBoolBinaryFunction>*)comp;
00203
00211 - (id) initWithMap: (OLMap*)right;
00212
00213 - (id) initWithObjectInStream: (OLObjectInStream*)stream;
00214
00218 #if defined(OL_NO_OPENSTEP)
00219 - (id) free;
00220 #else
00221 - (void) dealloc;
00222 #endif
00223
00224
00233 - (void) assignKey: (id)key value: (id)value;
00234
00245 - (OLAssociativeIterator*) begin;
00246
00250 - (void) clear;
00251
00261 - (int) compare: (id)other;
00262 #if defined(OL_NO_OPENSTEP)
00263
00268 - (id) copy;
00269 #else
00270
00276 - (id) copyWithZone: (NSZone*)zone;
00277 #endif
00278
00285 - (unsigned) count: (id)key;
00286
00292 - (BOOL) empty;
00293
00294 #if !defined(OL_NO_OPENSTEP)
00295
00301 - (void) encodeWithCoder: (NSCoder*)encoder;
00302 #endif
00303
00314 - (OLAssociativeIterator*) end;
00315
00329 - (OLPair*) equalRange: (id)key;
00330
00338 - (void) erase: (OLAssociativeIterator*)where;
00339
00349 - (void) eraseFrom: (OLAssociativeIterator*)first to: (OLAssociativeIterator*)last;
00350
00358 - (unsigned) eraseKey: (id)key;
00359
00375 - (OLAssociativeIterator*) find: (id)key;
00376
00395 - (id) insert: (OLPair*)keyValue;
00396
00413 - (OLAssociativeIterator*) insertAt: (OLAssociativeIterator*)where value: (OLPair*)keyVal;
00414
00428 - (void) insertFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last;
00429
00445 - (id) insertKey: (id)key value: (id)val;
00446
00455 - (BOOL) isEqual: (id)object;
00456
00463 - (OLStreamableFunctor<OLBoolBinaryFunction>*) keyComp;
00464
00478 - (OLAssociativeIterator*) lowerBound: (id)key;
00479
00488 - (unsigned) maxSize;
00489
00502 - (OLReverseBidiIterator*) rbegin;
00503
00516 - (OLReverseBidiIterator*) rend;
00517
00523 - (unsigned) size;
00524
00531 - (void) swap: (OLMap*)right;
00532
00546 - (OLAssociativeIterator*) upperBound: (id)key;
00547
00554 - (OLStreamableFunctor<OLBoolBinaryFunction>*) valueComp;
00555
00563 - (id) valueForKey: (id)key;
00564
00565 - (void) writeSelfToStream: (OLObjectOutStream*)stream;
00566
00567 @end
00568
00579 @interface OLMultiMap : OLMap
00580 {
00581 }
00582
00583
00593 + (id) multiMap;
00594
00611 + (id) multiMapFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last;
00612
00623 + (id) multiMapWithCompare: (OLStreamableFunctor<OLBoolBinaryFunction>*)comp;
00624
00638 + (id) multiMapWithMap: (OLMap*)right;
00639
00647 - (void) assignKey: (id)key value: (id)value;
00648
00662 - (id) insert: (OLPair*)keyValue;
00663 - (OLAssociativeIterator*) insertAt: (OLAssociativeIterator*)where value: (OLPair*)keyVal;
00664 - (void) insertFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last;
00665
00678 - (BOOL) isEqual: (id)object;
00679
00688 - (id) valueForKey: (id)key;
00689
00690 @end
00691
00692 #endif