PageRenderTime 38ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/libwww2/HTList.h

http://github.com/alandipert/ncsa-mosaic
C Header | 61 lines | 36 code | 11 blank | 14 comment | 3 complexity | ef5299b7bc11d9a46a55c8f5306d06aa MD5 | raw file
  1. /* */
  2. /* List object
  3. **
  4. ** The list object is a generic container for storing collections
  5. ** of things in order.
  6. */
  7. #ifndef HTLIST_H
  8. #define HTLIST_H
  9. #include "HTUtils.h" /* for BOOL type and PARAMS and ARGS*/
  10. typedef struct _HTList HTList;
  11. struct _HTList {
  12. void * object;
  13. HTList * next;
  14. HTList * last;
  15. };
  16. #ifdef SHORT_NAMES
  17. #define HTList_new HTLiNew
  18. #define HTList_delete HTLiDele
  19. #define HTList_addObject HTLiAdOb
  20. #define HTList_removeObject HTLiReOb
  21. #define HTList_removeLastObject HTLiReLa
  22. #define HTList_removeFirstObject HTLiReFi
  23. #define HTList_count HTLiCoun
  24. #define HTList_indexOf HTLiInOf
  25. #define HTList_objectAt HTLiObAt
  26. #endif
  27. extern HTList * HTList_new NOPARAMS;
  28. extern void HTList_delete PARAMS((HTList *me));
  29. /* Add object to START of list
  30. */
  31. extern void HTList_addObject PARAMS((HTList *me, void *newObject));
  32. extern void HTList_addObjectAtEnd PARAMS((HTList *me, void *newObject));
  33. extern BOOL HTList_removeObject PARAMS((HTList *me, void *oldObject));
  34. extern void * HTList_removeLastObject PARAMS((HTList *me));
  35. extern void * HTList_removeFirstObject PARAMS((HTList *me));
  36. #define HTList_isEmpty(me) (me ? me->next == NULL : YES)
  37. extern int HTList_count PARAMS((HTList *me));
  38. extern int HTList_indexOf PARAMS((HTList *me, void *object));
  39. #define HTList_lastObject(me) \
  40. (me && me->next ? me->next->object : NULL)
  41. extern void * HTList_objectAt PARAMS((HTList *me, int position));
  42. /* Fast macro to traverse the list. Call it first with copy of list header :
  43. it returns the first object and increments the passed list pointer.
  44. Call it with the same variable until it returns NULL. */
  45. #define HTList_nextObject(me) \
  46. (me && (me = me->next) ? me->object : NULL)
  47. #endif /* HTLIST_H */
  48. /*
  49. */