Queue.h

00001 //
00002 // $Id: Queue.h,v 1.22 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(QUEUE_OL_GUARD)
00044 #define QUEUE_OL_GUARD
00045 
00046 #include <ObjectiveLib/Functional.h>
00047 #include <ObjectiveLib/Iterator.h>
00048 
00049 @class OLDeque;
00050 @class OLVector;
00051 
00068 @interface OLQueue :
00069 #if defined(OL_NO_OPENSTEP)
00070     Object <OLStreamable>
00071 #else
00072     NSObject <OLStreamable, NSCopying, NSCoding>
00073 #endif
00074 {
00075 @protected
00079     OLDeque* deque;
00080 }
00081 
00090 + (id) queue;
00091 
00102 + (id) queueWithQueue: (OLQueue*)right;
00103 
00107 /* @{ */
00113 - (id) init;
00114 
00115 #if !defined(OL_NO_OPENSTEP)
00116 
00126 - (id) initWithCoder: (NSCoder*)decoder;
00127 #endif
00128 
00129 - (id) initWithObjectInStream: (OLObjectInStream*)stream;
00130 
00138 - (id) initWithQueue: (OLQueue*)queue;
00139 
00143 #if defined(OL_NO_OPENSTEP)
00144 - (id) free;
00145 #else
00146 - (void) dealloc;
00147 #endif
00148 /* @} */
00149 
00157 - (id) back;
00158 
00168 - (int) compare: (id)other;
00169 
00170 #if defined(OL_NO_OPENSTEP)
00171 
00176 - (id) copy;
00177 #else
00178 
00184 - (id) copyWithZone: (NSZone*)zone;
00185 #endif
00186 
00192 - (BOOL) empty;
00193 
00194 #if !defined(OL_NO_OPENSTEP)
00195 
00201 - (void) encodeWithCoder: (NSCoder*)encoder;
00202 #endif
00203 
00212 - (id) front;
00213 
00222 - (BOOL) isEqual: (id)object;
00223 
00230 - (void) pop;
00231 
00238 - (void) push: (id)object;
00239 
00245 - (unsigned) size;
00246 
00247 - (void) writeSelfToStream: (OLObjectOutStream*)stream;
00248 
00249 @end
00250 
00276 @interface OLPriorityQueue :
00277 #if defined(OL_NO_OPENSTEP)
00278     Object <OLStreamable>
00279 #else
00280     NSObject <OLStreamable, NSCopying, NSCoding>
00281 #endif
00282 {
00283 @protected
00287     OLVector*                                   vector;
00288 
00292     OLStreamableFunctor<OLBoolBinaryFunction>*  predicate;
00293 }
00294 
00304 + (id) priorityQueue;
00305 
00318 + (id) priorityQueueFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last;
00319 
00333 + (id) priorityQueueFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last predicate: (OLStreamableFunctor<OLBoolBinaryFunction>*)pred;
00334 
00345 + (id) priorityQueueWithPredicate: (OLStreamableFunctor<OLBoolBinaryFunction>*)pred;
00346 
00357 + (id) priorityQueueWithPriorityQueue: (OLPriorityQueue*)right;
00358 
00362 /* @{ */
00368 - (id) init;
00369 
00379 - (id) initFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last;
00380 
00397 - (id) initFrom: (OLForwardIterator*)first to: (OLForwardIterator*)last predicate: (OLStreamableFunctor<OLBoolBinaryFunction>*)pred;
00398 
00399 #if !defined(OL_NO_OPENSTEP)
00400 
00410 - (id) initWithCoder: (NSCoder*)decoder;
00411 #endif
00412 
00413 - (id) initWithObjectInStream: (OLObjectInStream*)stream;
00414 
00422 - (id) initWithPredicate: (OLStreamableFunctor<OLBoolBinaryFunction>*)pred;
00423 
00431 - (id) initWithPriorityQueue: (OLPriorityQueue*)right;
00432 
00436 #if defined(OL_NO_OPENSTEP)
00437 - (id) free;
00438 #else
00439 - (void) dealloc;
00440 #endif
00441 /* @} */
00442 
00452 - (int) compare: (id)other;
00453 
00454 #if defined(OL_NO_OPENSTEP)
00455 
00460 - (id) copy;
00461 #else
00462 
00468 - (id) copyWithZone: (NSZone*)zone;
00469 #endif
00470 
00476 - (BOOL) empty;
00477 
00478 #if !defined(OL_NO_OPENSTEP)
00479 
00485 - (void) encodeWithCoder: (NSCoder*)encoder;
00486 #endif
00487 
00496 - (BOOL) isEqual: (id)object;
00497 
00504 - (void) pop;
00505 
00512 - (void) push: (id)object;
00513 
00519 - (unsigned) size;
00520 
00527 - (id) top;
00528 
00529 - (void) writeSelfToStream: (OLObjectOutStream*)stream;
00530 
00531 @end
00532 
00533 #endif

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