home *** CD-ROM | disk | FTP | other *** search
- //
- // MiscListIteration.h -- macros to iterate through List and HashTable objects
- // Originally written by Drew Davidson
- // Copyright (c) 1994 by Drew Davidson.
- // Modified by Don Yacktman for inclusion into the MiscKit.
- // 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.
- //
-
-
- // iterate over the elements in a List
- #define MISCforAllListObjectsTo(s,_i,toIndex) { \
- id _list = s; \
- int _slot=0; \
- id _i; \
- while( (_slot < toIndex) && ((_i = [_list objectAt:_slot++]) != nil) ) \
-
- #define MISCforAllListObjectsFrom(s,_i,fromIndex) { \
- id _list = s; \
- int _slot=fromIndex; \
- id _i; \
- while( (_i = [_list objectAt:_slot++]) != nil ) \
-
- #define MISCforAllListObjects(s,_i) { \
- id _list = s; \
- int _slot=0; \
- id _i; \
- while( (_i = [_list objectAt:_slot++]) != nil ) \
-
- #define MISCforAllListObjectsBackwards(s,_i) { \
- id _i; \
- id _list = s; \
- int _slot=[_list count]; \
- while( (_i = [_list objectAt:--_slot]) != nil ) \
-
-
- // to be used inside a MISCforAllListObjects()
- #define MISCRemoveCurrentObjectFromList(s) [s removeObjectAt:--_slot];
- #define MISCDecrementCurrentSlot (--_slot)
- #define MISCCurrentSlot (_slot-1)
- #define MISCCurrentSlotBackwards (_slot+1)
- #define MISCFirstSlot (0)
-
-
- // iterate over the elements in a HashTable
- // params: hashtable, key (returned), object (returned)
- #define MISCforAllHashTableObjects(s,_i, _key) { \
- id _table = s; \
- NXHashState _state = [_table initState]; \
- id _i; \
- void * _key; \
- while([_table nextState: &_state key: (void *)&_key value: (void *)&_i])
-
-
- // This goes at the end of any of the above iteration constructs.
- #define MISCendFor }
-