Annotation of libwww/Library/src/HTList.html, revision 2.7
2.6 timbl 1: <HTML>
2: <HEAD>
3: <TITLE>List object for libwww</TITLE>
4: <NEXTID N="z3">
5: </HEAD>
6: <BODY>
2.7 ! frystyk 7:
! 8: <H1>List object</H1>
! 9:
! 10: <PRE>
! 11: /*
! 12: ** (c) COPYRIGHT CERN 1994.
! 13: ** Please first read the full copyright statement in the file COPYRIGH.
! 14: */
! 15: </PRE>
! 16:
! 17: The list object is a generic container for storing collections of
! 18: things in order. In principle it could be implemented in many ways,
! 19: but in practice knowing that it is a linked list is important for
! 20: speed. See also the <A NAME="z2" HREF="#z1">traverse macro</A> for
! 21: example. <P>
! 22:
! 23: This module is implemented by <A HREF="HTList.c">HTList.c</A>, and it
! 24: is a part of the <A
! 25: HREF="http://info.cern.ch/hypertext/WWW/Library/User/Guide/Guide.html">
! 26: Library of Common Code</A>.
! 27:
2.1 timbl 28: <PRE>
29: #ifndef HTLIST_H
30: #define HTLIST_H
31:
32: #include "HTUtils.h" /* for BOOL type and PARAMS and ARGS*/
33:
34: typedef struct _HTList HTList;
35:
36: struct _HTList {
37: void * object;
38: HTList * next;
39: };
40:
41: #ifdef SHORT_NAMES
42: #define HTList_new HTLiNew
43: #define HTList_delete HTLiDele
44: #define HTList_addObject HTLiAdOb
45: #define HTList_removeObject HTLiReOb
46: #define HTList_removeLastObject HTLiReLa
47: #define HTList_removeFirstObject HTLiReFi
48: #define HTList_count HTLiCoun
49: #define HTList_indexOf HTLiInOf
50: #define HTList_objectAt HTLiObAt
51: #endif
52:
53: extern HTList * HTList_new NOPARAMS;
2.2 timbl 54: extern void HTList_delete PARAMS((HTList *me));
2.1 timbl 55:
2.6 timbl 56: </PRE>
57: <H3>Add object to START of list</H3>
58: <PRE>
2.2 timbl 59: extern void HTList_addObject PARAMS((HTList *me, void *newObject));
2.1 timbl 60:
61:
2.2 timbl 62: extern BOOL HTList_removeObject PARAMS((HTList *me, void *oldObject));
63: extern void * HTList_removeLastObject PARAMS((HTList *me));
64: extern void * HTList_removeFirstObject PARAMS((HTList *me));
65: #define HTList_isEmpty(me) (me ? me->next == NULL : YES)
66: extern int HTList_count PARAMS((HTList *me));
67: extern int HTList_indexOf PARAMS((HTList *me, void *object));
68: #define HTList_lastObject(me) \
2.6 timbl 69: (me && me->next ? me->next->object : NULL)
2.2 timbl 70: extern void * HTList_objectAt PARAMS((HTList *me, int position));
2.1 timbl 71:
2.6 timbl 72: </PRE>
73: <H3><A
74: NAME="z1">Traverse list</A></H3>Fast macro to traverse the list.
75: Call it first with copy of list header
76: : it returns the first object and
77: increments the passed list pointer.
78: Call it with the same variable until
79: it returns NULL.
80: <PRE>#define HTList_nextObject(me) \
81: (me && (me = me->next) ? me->object : NULL)
82:
83: </PRE>
84: <H3>Free list</H3>
85: <PRE>#define HTList_free(x) free(x)
2.1 timbl 86:
87: #endif /* HTLIST_H */
2.6 timbl 88:
89: </PRE>end</A></BODY>
90: </HTML>
Webmaster