ObjectiveLib
1.0.0
|
00001 // 00002 // $Id: Map.h,v 1.25 2007/03/06 20:42:19 will_mason Exp $ 00003 // 00004 // vi: set ft=objc: 00005 00006 /* 00007 * ObjectiveLib - a library of containers and algorithms for Objective-C 00008 * 00009 * Copyright (c) 2004-2007 00010 * Will Mason 00011 * 00012 * Portions: 00013 * 00014 * Copyright (c) 1994 00015 * Hewlett-Packard Company 00016 * 00017 * Copyright (c) 1996,1997 00018 * Silicon Graphics Computer Systems, Inc. 00019 * 00020 * Copyright (c) 1997 00021 * Moscow Center for SPARC Technology 00022 * 00023 * Copyright (c) 1999 00024 * Boris Fomitchev 00025 * 00026 * This library is free software; you can redistribute it and/or 00027 * modify it under the terms of the GNU Lesser General Public 00028 * License as published by the Free Software Foundation; either 00029 * version 2.1 of the License, or (at your option) any later version. 00030 * 00031 * This library is distributed in the hope that it will be useful, 00032 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00033 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00034 * Lesser General Public License for more details. 00035 * 00036 * You should have received a copy of the GNU Lesser General Public 00037 * License along with this library; if not, write to the Free Software 00038 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00039 * 00040 * You may contact the author at will_mason@users.sourceforge.net. 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
|