HashSet.h

00001 //
00002 // $Id: HashSet.h,v 1.23 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(HASHSET_OL_GUARD)
00044 #define HASHSET_OL_GUARD
00045 
00046 #include <ObjectiveLib/Iterator.h>
00047 #include <ObjectiveLib/Functional.h>
00048 
00053 @class OLHashTable;
00054 
00081 @interface OLHashSet :
00082 #if defined(OL_NO_OPENSTEP)
00083     Object <OLStreamable>
00084 #else
00085     NSObject <OLStreamable, NSCopying, NSCoding>
00086 #endif
00087 {
00088 @protected
00092     OLHashTable* table;
00093 }
00094 
00103 + (id) hashSet;
00104 
00118 + (id) hashSetFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last;
00119 
00130 + (id) hashSetWithHashSet: (OLHashSet*)right;
00131 
00135 /* @{ */
00141 - (id) init;
00142 
00154 - (id) initFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last;
00155 
00171 - (id) initFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last tableSize: (unsigned)size;
00172 
00189 #if defined(OL_NO_OPENSTEP)
00190 - (id) initFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last tableSize: (unsigned)size keyEqual: (Object<OLBoolBinaryFunction>*)eq;
00191 #else
00192 - (id) initFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last tableSize: (unsigned)size keyEqual: (NSObject<OLBoolBinaryFunction>*)eq;
00193 #endif
00194 
00195 #if !defined(OL_NO_OPENSTEP)
00196 
00206 - (id) initWithCoder: (NSCoder*)decoder;
00207 #endif
00208 
00216 - (id) initWithHashSet: (OLHashSet*)right;
00217 
00218 - (id) initWithObjectInStream: (OLObjectInStream*)stream;
00219 
00230 - (id) initWithTableSize: (unsigned)size;
00231 
00243 #if defined(OL_NO_OPENSTEP)
00244 - (id) initWithTableSize: (unsigned)size keyEqual: (Object<OLBoolBinaryFunction>*)eq;
00245 #else
00246 - (id) initWithTableSize: (unsigned)size keyEqual: (NSObject<OLBoolBinaryFunction>*)eq;
00247 #endif
00248 
00252 #if defined(OL_NO_OPENSTEP)
00253 - (id) free;
00254 #else
00255 - (void) dealloc;
00256 #endif
00257 /* @} */
00258 
00267 - (OLHashIterator*) begin;
00268 
00272 - (void) clear;
00273 
00283 - (int) compare: (id)other;
00284 
00285 #if defined(OL_NO_OPENSTEP)
00286 
00291 - (id) copy;
00292 #else
00293 
00299 - (id) copyWithZone: (NSZone*)zone;
00300 #endif
00301 
00310 - (unsigned) count: (id)value;
00311 
00317 - (BOOL) empty;
00318 
00319 #if !defined(OL_NO_OPENSTEP)
00320 
00326 - (void) encodeWithCoder: (NSCoder*)encoder;
00327 #endif
00328 
00337 - (OLHashIterator*) end;
00338 
00352 - (OLPair*) equalRange: (id)value;
00353 
00361 - (void) erase: (OLHashIterator*)where;
00362 
00372 - (void) eraseFrom: (OLHashIterator*)first to: (OLHashIterator*)last;
00373 
00383 - (unsigned) eraseValue: (id)value;
00384 
00399 - (OLHashIterator*) find: (id)object;
00400 
00418 - (id) insert: (id)object;
00419 
00431 - (void) insertFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last;
00432 
00441 - (BOOL) isEqual: (id)object;
00442 
00448 #if defined(OL_NO_OPENSTEP)
00449 - (Object<OLBoolBinaryFunction>*) keyEqual;
00450 #else
00451 - (NSObject<OLBoolBinaryFunction>*) keyEqual;
00452 #endif
00453 
00462 - (unsigned) maxSize;
00463 
00469 - (unsigned) size;
00470 
00477 - (void) swap: (OLHashSet*)right;
00478 
00479 - (void) writeSelfToStream: (OLObjectOutStream*)stream;
00480 
00481 @end
00482 
00493 @interface OLHashMultiSet : OLHashSet
00494 {
00495 }
00496 
00505 + (id) hashMultiSet;
00506 
00520 + (id) hashMultiSetFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last;
00521 
00534 + (id) hashMultiSetWithHashSet: (OLHashSet*)right;
00535 
00549 - (id) insert: (id)object;
00550 - (void) insertFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last;
00551 
00552 - (BOOL) isEqual: (id)object;
00553 
00554 @end
00555 
00556 #endif

ObjectiveLibGenerated Sun Apr 22 15:17:58 2007, © 2004-2007 Will Mason
SourceForge.net Logo