ObjectiveLib
1.0.0
|
00001 00002 // $Id: Set.h,v 1.30 2007/03/06 20:42:20 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(SET_OL_GUARD) 00044 #define SET_OL_GUARD 00045 00046 #include <ObjectiveLib/Iterator.h> 00047 #include <ObjectiveLib/Pair.h> 00048 #include <ObjectiveLib/Functional.h> 00049 00053 @class OLTree; 00054 00069 @interface OLSet : 00070 #if defined(OL_NO_OPENSTEP) 00071 Object <OLInserter, OLStreamable> 00072 #else 00073 NSObject <OLInserter, OLStreamable, NSCopying, NSCoding> 00074 #endif 00075 { 00076 @protected 00080 OLTree* tree; 00081 } 00082 00092 + (id) set; 00093 00106 + (id) setFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last; 00107 00118 + (id) setWithCompare: (OLStreamableFunctor<OLBoolBinaryFunction>*)comp; 00119 00130 + (id) setWithOLSet: (OLSet*)right; 00131 00135 /* @{ */ 00141 - (id) init; 00142 00153 - (id) initFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last; 00154 00166 - (id) initFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last compare: (OLStreamableFunctor<OLBoolBinaryFunction>*)comp; 00167 00168 #if !defined(OL_NO_OPENSTEP) 00169 00179 - (id) initWithCoder: (NSCoder*)decoder; 00180 #endif 00181 00189 - (id) initWithCompare: (OLStreamableFunctor<OLBoolBinaryFunction>*)comp; 00190 00191 - (id) initWithObjectInStream: (OLObjectInStream*)stream; 00192 00200 - (id) initWithOLSet: (OLSet*)set; 00201 00205 #if defined(OL_NO_OPENSTEP) 00206 - (id) free; 00207 #else 00208 - (void) dealloc; 00209 #endif 00210 /* @} */ 00211 00220 - (OLAssociativeIterator*) begin; 00221 00225 - (void) clear; 00226 00236 - (int) compare: (id)other; 00237 00238 #if defined(OL_NO_OPENSTEP) 00239 00244 - (id) copy; 00245 #else 00246 00252 - (id) copyWithZone: (NSZone*)zone; 00253 #endif 00254 00261 - (unsigned) count: (id)key; 00262 00268 - (BOOL) empty; 00269 00270 #if !defined(OL_NO_OPENSTEP) 00271 00277 - (void) encodeWithCoder: (NSCoder*)encoder; 00278 #endif 00279 00288 - (OLAssociativeIterator*) end; 00289 00301 - (OLPair*) equalRange: (id)key; 00302 00310 - (void) erase: (OLAssociativeIterator*)where; 00311 00321 - (void) eraseFrom: (OLAssociativeIterator*)first to: (OLAssociativeIterator*)last; 00322 00330 - (unsigned) eraseKey: (id)key; 00331 00344 - (OLAssociativeIterator*) find: (id)key; 00345 00361 - (id) insert: (id)object; 00362 00377 - (OLAssociativeIterator*) insertAt: (OLAssociativeIterator*)where value: (id)object; 00378 00388 - (void) insertFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last; 00389 00398 - (BOOL) isEqual: (id)object; 00399 00405 - (OLStreamableFunctor<OLBoolBinaryFunction>*) keyComp; 00406 00418 - (OLAssociativeIterator*) lowerBound: (id)key; 00419 00428 - (unsigned) maxSize; 00429 00440 - (OLReverseBidiIterator*) rbegin; 00441 00452 - (OLReverseBidiIterator*) rend; 00453 00459 - (unsigned) size; 00460 00467 - (void) swap: (OLSet*)right; 00468 00480 - (OLAssociativeIterator*) upperBound: (id)key; 00481 00488 - (OLStreamableFunctor<OLBoolBinaryFunction>*) valueComp; 00489 00490 - (void) writeSelfToStream: (OLObjectOutStream*)stream; 00491 00492 @end 00493 00504 @interface OLMultiSet : OLSet 00505 { 00506 } 00507 00517 + (id) multiSet; 00518 00531 + (id) multiSetFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last; 00532 00543 + (id) multiSetWithCompare: (OLStreamableFunctor<OLBoolBinaryFunction>*)comp; 00544 00557 + (id) multiSetWithOLSet: (OLSet*)right; 00558 00570 - (id) insert: (id)object; 00571 - (OLAssociativeIterator*) insertAt: (OLAssociativeIterator*)where value: (id)object; 00572 - (void) insertFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last; 00573 - (BOOL) isEqual: (id)object; 00574 00575 @end 00576 00577 #endif
|