HashMap.h

00001 //
00002 // $Id: HashMap.h,v 1.24 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(HASHMAP_OL_GUARD)
00044 #define HASHMAP_OL_GUARD
00045 
00046 #include <ObjectiveLib/Iterator.h>
00047 #include <ObjectiveLib/Functional.h>
00048 
00052 @class OLHashTableMap;
00053 
00080 @interface OLHashMap :
00081 #if defined(OL_NO_OPENSTEP)
00082     Object <OLStreamable>
00083 #else
00084     NSObject <OLStreamable, NSCopying, NSCoding>
00085 #endif
00086 {
00087 @protected
00091     OLHashTableMap* table;
00092 }
00093 
00102 + (id) hashMap;
00103 
00119 + (id) hashMapFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last;
00120 
00131 + (id) hashMapWithHashMap: (OLHashMap*)right;
00132 
00136 /* @{ */
00142 - (id) init;
00143 
00157 - (id) initFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last;
00158 
00176 - (id) initFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last tableSize: (unsigned)size;
00177 
00196 #if defined(OL_NO_OPENSTEP)
00197 - (id) initFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last tableSize: (unsigned)size keyEqual: (Object<OLBoolBinaryFunction>*)eq;
00198 #else
00199 - (id) initFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last tableSize: (unsigned)size keyEqual: (NSObject<OLBoolBinaryFunction>*)eq;
00200 #endif
00201 
00202 #if !defined(OL_NO_OPENSTEP)
00203 
00213 - (id) initWithCoder: (NSCoder*)decoder;
00214 #endif
00215 
00223 - (id) initWithHashMap: (OLHashMap*)right;
00224 
00225 - (id) initWithObjectInStream: (OLObjectInStream*)stream;
00226 
00237 - (id) initWithTableSize: (unsigned)size;
00238 
00250 #if defined(OL_NO_OPENSTEP)
00251 - (id) initWithTableSize: (unsigned)size keyEqual: (Object<OLBoolBinaryFunction>*)eq;
00252 #else
00253 - (id) initWithTableSize: (unsigned)size keyEqual: (NSObject<OLBoolBinaryFunction>*)eq;
00254 #endif
00255 
00259 #if defined(OL_NO_OPENSTEP)
00260 - (id) free;
00261 #else
00262 - (void) dealloc;
00263 #endif
00264 /* @} */
00265 
00276 - (void) assignKey: (id)key value: (id)value;
00277 
00288 - (OLHashIterator*) begin;
00289 
00293 - (void) clear;
00294 
00304 - (int) compare: (id)other;
00305 
00306 #if defined(OL_NO_OPENSTEP)
00307 
00312 - (id) copy;
00313 #else
00314 
00320 - (id) copyWithZone: (NSZone*)zone;
00321 #endif
00322 
00331 - (unsigned) count: (id)key;
00332 
00338 - (BOOL) empty;
00339 
00340 #if !defined(OL_NO_OPENSTEP)
00341 
00347 - (void) encodeWithCoder: (NSCoder*)encoder;
00348 #endif
00349 
00360 - (OLHashIterator*) end;
00361 
00377 - (OLPair*) equalRange: (id)key;
00378 
00386 - (void) erase: (OLHashIterator*)where;
00387 
00397 - (void) eraseFrom: (OLHashIterator*)first to: (OLHashIterator*)last;
00398 
00408 - (unsigned) eraseKey: (id)key;
00409 
00427 - (OLHashIterator*) find: (id)key;
00428 
00447 - (id) insert: (OLPair*)keyValue;
00448 
00462 - (void) insertFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last;
00463 
00481 - (id) insertKey: (id)key value: (id)val;
00482 
00493 - (BOOL) isEqual: (id)object;
00494 
00501 #if defined(OL_NO_OPENSTEP)
00502 - (Object<OLBoolBinaryFunction>*) keyEqual;
00503 #else
00504 - (NSObject<OLBoolBinaryFunction>*) keyEqual;
00505 #endif
00506 
00515 - (unsigned) maxSize;
00516 
00522 - (unsigned) size;
00523 
00530 - (void) swap: (OLHashMap*)right;
00531 
00541 - (id) valueForKey: (id)key;
00542 
00543 - (void) writeSelfToStream: (OLObjectOutStream*)stream;
00544 
00545 @end
00546 
00558 @interface OLHashMultiMap : OLHashMap
00559 {
00560 }
00561 
00570 + (id) hashMultiMap;
00571 
00588 + (id) hashMultiMapFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last;
00589 
00602 + (id) hashMultiMapWithHashMap: (OLHashMap*)right;
00603 
00613 - (void) assignKey: (id)key value: (id)value;
00614 
00631 - (id) insert: (OLPair*)keyValue;
00632 - (void) insertFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last;
00633 
00648 - (BOOL) isEqual: (id)object;
00649 
00658 - (id) valueForKey: (id)key;
00659 
00660 @end
00661 
00662 #endif

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