/*********************************************************************** * EqueueNode.h * * Interface file for a simple EqueueNode class. This class serves * the same function as the Node class from the C++ version, but is * equipped with a full set of accessor methods instead of leaving * variables public. * * Written by Paul Bonamy - 9 August 2010 ***********************************************************************/ #import /* * The NSObject type is akin to Java's Object. It is the topmost * class from which most (but not all) other classes inherit. * It provides the functionality to do initial memory allocation, * as well as some other message and object related things, so * Obj-C classes will generally inherit either from it directly, * or from something that in turn inherits from NSObject. */ @interface EqueueNode : NSObject { /* * Variables declared between these curly braces are instance * variables. Each object will have access to its own set of them. */ int value; EqueueNode * next; EqueueNode * prev; } /* * Class methods you want class users to know about go here, between * the closing curly brace and the @end. There is no requirement * that methods actually be listed here to be used, so this space * provides a way of telling your user about the interface they * should be using, rather than everything they could be using. */ /* * The @property keyword was introduced with Objective-C 2.0 (around * the time MacOS 10.5 came out.) Paired with @synthesis, it instructs * the compiler to create setter and getter methods for the named * variables as needed, so we don't need to. The getter will have the * same name as the variable, by default, and the setter will be named * setName, where Name is the name of the variable. * * Note that we have to specify what behavior to use for object pointers. * Options are: * (assign) - Do a straight copy of the pointer (this is default) * (retain) - Assign, and, additionally, retain the object * (copy) - Create a copy of the object * * Because the Equeue class is the only thing that's ever going to * mess with the EqueueNodes, it's sufficient for us to assign in the * setter, as we don't need to worry about someone else releasing the * nodes unexpectedly. */ @property int value; @property(assign) EqueueNode *next; @property(assign) EqueueNode *prev; /* * Method identifications start with either a - or a +. Things starting with * a - are instance methods, and are responded to by objects (like normal * class methods in C++). Methods starting with a + are known as class methods * and are akin to static methods in C++. They have no access to instance * variables, and get used for things like building a new object with * initializing data. These are called by sending a message to the class, * rather than an object of the same type as the class. */ /* * The id type returned by init is more or less equivalent to a void * or * java Object. It's used to indicate that an object of some sort will be * passed back. init should always pass back either itself or nil */ -(id)init; @end