This whole thing could use a rewrite but whatever
[ITFoundation.git] / ArrayQueue.h
1 /************************
2 A Cocoa DataStructuresFramework
3 Copyright (C) 2002  Phillip Morelock in the United States
4 http://www.phillipmorelock.com
5 Other copyrights for this specific file as acknowledged herein.
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20 *******************************/
21 /*
22  *  ArrayQueue.h
23  *  Data Structures Framework
24 /////SEE LICENSE FILE FOR LICENSE INFORMATION///////
25  *
26  */
27
28 //////////
29 //A fairly basic queue implementation that puts its data in an NSMutableArray
30 //See the protocol definition for Queue to understand the contract.
31 /////////
32
33 #import <Foundation/Foundation.h>
34 #import "Queue.h"
35
36 @interface ArrayQueue : NSObject <Queue>
37 {
38     NSMutableArray *theQ;
39     
40     int backIndex; //where to place the next element
41     int frontIndex; //the current front of the queue
42     unsigned int qSize;  //the current size
43     unsigned int arrsz;
44     
45     id niller; //the marker for dead spots in the queue
46 }
47
48 - init;
49 - initWithCapacity:(unsigned)capacity;
50
51 //returns the size of the queue currently
52 -(unsigned int) count;
53
54 /**
55  * see protocol declaration for Queue
56  */
57 +(ArrayQueue *)queueWithArray:(NSArray *)array
58                         ofOrder:(BOOL)direction;
59 @end