Annotation of libwww/Library/src/HTList.html, revision 2.11

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
2.10      frystyk    25: HREF="http://www.w3.org/hypertext/WWW/Library/User/Guide/Guide.html">
2.7       frystyk    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: extern HTList *        HTList_new NOPARAMS;
2.2       timbl      41: extern void    HTList_delete PARAMS((HTList *me));
2.1       timbl      42: 
2.6       timbl      43: </PRE>
                     44: <H3>Add object to START of list</H3>
                     45: <PRE>
2.11    ! frystyk    46: extern BOOL    HTList_addObject PARAMS((HTList *me, void *newObject));
2.1       timbl      47: 
                     48: 
2.2       timbl      49: extern BOOL    HTList_removeObject PARAMS((HTList *me, void *oldObject));
                     50: extern void *  HTList_removeLastObject PARAMS((HTList *me));
                     51: extern void *  HTList_removeFirstObject PARAMS((HTList *me));
                     52: #define        HTList_isEmpty(me) (me ? me->next == NULL : YES)
                     53: extern int     HTList_count PARAMS((HTList *me));
                     54: extern int     HTList_indexOf PARAMS((HTList *me, void *object));
                     55: #define        HTList_lastObject(me) \
2.6       timbl      56:   (me &amp;&amp; me->next ? me->next->object : NULL)
2.2       timbl      57: extern void *  HTList_objectAt PARAMS((HTList *me, int position));
2.1       timbl      58: 
2.6       timbl      59: </PRE>
                     60: <H3><A
                     61: NAME="z1">Traverse list</A></H3>Fast macro to traverse the list.
                     62: Call it first with copy of list header
                     63: :  it returns the first object and
                     64: increments the passed list pointer.
                     65: Call it with the same variable until
                     66: it returns NULL.
                     67: <PRE>#define HTList_nextObject(me) \
                     68:   (me &amp;&amp; (me = me->next) ? me->object : NULL)
                     69: 
                     70: </PRE>
                     71: <H3>Free list</H3>
                     72: <PRE>#define HTList_free(x)  free(x)
2.1       timbl      73: 
                     74: #endif /* HTLIST_H */
2.6       timbl      75: 
                     76: </PRE>end</A></BODY>
                     77: </HTML>

Webmaster