Annotation of libwww/Library/src/HTList.html, revision 2.9
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:
33: typedef struct _HTList HTList;
34:
35: struct _HTList {
36: void * object;
37: HTList * next;
38: };
39:
40: #ifdef SHORT_NAMES
41: #define HTList_new HTLiNew
42: #define HTList_delete HTLiDele
43: #define HTList_addObject HTLiAdOb
44: #define HTList_removeObject HTLiReOb
45: #define HTList_removeLastObject HTLiReLa
46: #define HTList_removeFirstObject HTLiReFi
47: #define HTList_count HTLiCoun
48: #define HTList_indexOf HTLiInOf
49: #define HTList_objectAt HTLiObAt
50: #endif
51:
52: extern HTList * HTList_new NOPARAMS;
2.2 timbl 53: extern void HTList_delete PARAMS((HTList *me));
2.1 timbl 54:
2.6 timbl 55: </PRE>
56: <H3>Add object to START of list</H3>
57: <PRE>
2.2 timbl 58: extern void HTList_addObject PARAMS((HTList *me, void *newObject));
2.1 timbl 59:
60:
2.2 timbl 61: extern BOOL HTList_removeObject PARAMS((HTList *me, void *oldObject));
62: extern void * HTList_removeLastObject PARAMS((HTList *me));
63: extern void * HTList_removeFirstObject PARAMS((HTList *me));
64: #define HTList_isEmpty(me) (me ? me->next == NULL : YES)
65: extern int HTList_count PARAMS((HTList *me));
66: extern int HTList_indexOf PARAMS((HTList *me, void *object));
67: #define HTList_lastObject(me) \
2.6 timbl 68: (me && me->next ? me->next->object : NULL)
2.2 timbl 69: extern void * HTList_objectAt PARAMS((HTList *me, int position));
2.1 timbl 70:
2.6 timbl 71: </PRE>
72: <H3><A
73: NAME="z1">Traverse list</A></H3>Fast macro to traverse the list.
74: Call it first with copy of list header
75: : it returns the first object and
76: increments the passed list pointer.
77: Call it with the same variable until
78: it returns NULL.
79: <PRE>#define HTList_nextObject(me) \
80: (me && (me = me->next) ? me->object : NULL)
81:
82: </PRE>
83: <H3>Free list</H3>
84: <PRE>#define HTList_free(x) free(x)
2.1 timbl 85:
86: #endif /* HTLIST_H */
2.6 timbl 87:
88: </PRE>end</A></BODY>
89: </HTML>
Webmaster