home *** CD-ROM | disk | FTP | other *** search
- //
- // MiscList.m -- a List subclass with a cursor
- // Written by Doug McClure (c) 1994 by Doug McClure.
- // Version 1.0. All rights reserved.
- //
- // This notice may not be removed from this source code.
- //
- // This object is included in the MiscKit by permission from the author
- // and its use is governed by the MiscKit license, found in the file
- // "LICENSE.rtf" in the MiscKit distribution. Please refer to that file
- // for a list of all applicable permissions and restrictions.
- //
-
- /*
- * $RCSfile$
- *
- * $Author$
- *
- * $Revision$
- *
- * $Date$
- *
- */
-
- #import <misckit/MiscList.h>
-
- #define MiscListVersion 100
-
- @implementation MiscList
-
- - (unsigned int)currentPosition
- {
- return cursor;
- }
-
-
- - setFirstObject
- {
- if ( [self count] )
- {
- cursor = 0;
- return [self objectAt:cursor];
- }
-
- return nil;
- }
-
-
- - setLastObject
- {
- if ( [self count] )
- {
- cursor = [self count] - 1;
- return [self objectAt:cursor];
- }
-
- return nil;
- }
-
-
- - setNextObject
- {
- if ( (cursor+1) < [self count] )
- {
- return [self objectAt:(++cursor)];
- }
-
- return nil;
- }
-
-
- - setPreviousObject
- {
- if ( cursor != 0 )
- {
- return [self objectAt:(--cursor)];
- }
-
- return nil;
- }
-
-
- - setTo:(unsigned int)aPosition
- {
- if ( aPosition < [self count] )
- {
- cursor = aPosition;
- return [self objectAt:cursor];
- }
-
- return nil;
- }
-
- @end
-