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