Holder.m
上传用户:shenzhenrh
上传日期:2013-05-12
资源大小:2904k
文件大小:1k
源码类别:

信息检索与抽取

开发平台:

Unix_Linux

  1. /*
  2. Name:         Holder.m
  3. Description:  Functionality for storing objects, used through mix-in 
  4.               inheritance
  5. Library:      activity
  6. */ 
  7. /* Mix-in inheritance of a Holder class that holds a list of objects.
  8.    Used for for subclassing from activity library classes (ActionGroup, 
  9.    ConcurrentGroup, Schedule etc.).
  10. */
  11. #ifdef CLASS_NAME
  12. #ifdef MIXIN_CREATE
  13. + createBegin: aZone numberOfObjects: (int)num
  14. {
  15.   CLASS_NAME *obj = [super createBegin: aZone];
  16.   obj->numberOfObjects = num;
  17.   obj->objects = [aZone alloc: num * sizeof (id)];
  18.   obj->counter = 0;
  19.   return obj;
  20. }
  21. - addObject: obj
  22. {
  23.   if (counter < numberOfObjects)
  24.     *(objects + counter++) = obj;
  25.   return self;
  26. }
  27. #else
  28. - getObjectAt: (int)offset
  29. {
  30.   if (offset < counter)
  31.     return *(objects + offset);
  32.   else
  33.     return NULL;
  34. }
  35. #endif
  36. #endif