list.h


    1 /*
    2  * list.h: lists interfaces
    3  *
    4  * Copyright (C) 2000 Gary Pennington and Daniel Veillard.
    5  *
    6  * Permission to use, copy, modify, and distribute this software for any
    7  * purpose with or without fee is hereby granted, provided that the above
    8  * copyright notice and this permission notice appear in all copies.
    9  *
    10  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
    11  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
    12  * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
    13  * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
    14  *
    15  * Author: Gary.Pennington@uk.sun.com
    16  */
    17 
    18 #ifndef __XML_LINK_INCLUDE__
    19 #define __XML_LINK_INCLUDE__
    20 
    21 #ifdef __cplusplus
    22 extern "C" {
    23 #endif
    24 
    25 typedef struct _xmlLink xmlLink;  <typedef:xmlLink>
    26 typedef xmlLink *xmlLinkPtr;  <typedef:xmlLinkPtr>
    27 
    28 typedef struct _xmlList xmlList;  <typedef:xmlList>
    29 typedef xmlList *xmlListPtr;  <typedef:xmlListPtr>
    30 
    31 /**
    32  * xmlListDeallocator:
    33  * @lk:  the data to deallocate
    34  *
    35  * Callback function used to free data from a list.
    36  */
    37 typedef void (*xmlListDeallocator) (xmlLinkPtr lk);  <typedef:xmlListDeallocator>
    38 /**
    39  * xmlListDataCompare:
    40  * @data0: the first data
    41  * @data1: the second data
    42  *
    43  * Callback function used to compare 2 data.
    44  *
    45  * Returns 0 is equality, -1 or 1 otherwise depending on the ordering.
    46  */
    47 typedef int  (*xmlListDataCompare) (const void *data0, const void *data1);  <typedef:xmlListDataCompare>
    48 /**
    49  * xmlListWalker:
    50  * @data: the data found in the list
    51  * @user: extra user provided data to the walker
    52  *
    53  * Callback function used when walking a list with xmlListWalk().
    54  *
    55  * Returns 0 to stop walking the list, 1 otherwise.
    56  */
    57 typedef int (*xmlListWalker) (const void *data, const void *user);  <typedef:xmlListWalker>
    58 
    59 /* Creation/Deletion */
    60 xmlListPtr	xmlListCreate		(xmlListDeallocator deallocator,
    61 	                                 xmlListDataCompare compare);
    62 void		xmlListDelete		(xmlListPtr l);
    63 
    64 /* Basic Operators */
    65 void *		xmlListSearch		(xmlListPtr l,
    66 					 void *data);
    67 void *		xmlListReverseSearch	(xmlListPtr l,
    68 					 void *data);
    69 int		xmlListInsert		(xmlListPtr l,
    70 					 void *data) ;
    71 int		xmlListAppend		(xmlListPtr l,
    72 					 void *data) ;
    73 int		xmlListRemoveFirst	(xmlListPtr l,
    74 					 void *data);
    75 int		xmlListRemoveLast	(xmlListPtr l,
    76 					 void *data);
    77 int		xmlListRemoveAll	(xmlListPtr l,
    78 					 void *data);
    79 void		xmlListClear		(xmlListPtr l);
    80 int		xmlListEmpty		(xmlListPtr l);
    81 xmlLinkPtr	xmlListFront		(xmlListPtr l);
    82 xmlLinkPtr	xmlListEnd		(xmlListPtr l);
    83 int		xmlListSize		(xmlListPtr l);
    84 
    85 void		xmlListPopFront		(xmlListPtr l);
    86 void		xmlListPopBack		(xmlListPtr l);
    87 int		xmlListPushFront	(xmlListPtr l,
    88 					 void *data);
    89 int		xmlListPushBack		(xmlListPtr l,
    90 					 void *data);
    91 
    92 /* Advanced Operators */
    93 void		xmlListReverse		(xmlListPtr l);
    94 void		xmlListSort		(xmlListPtr l);
    95 void		xmlListWalk		(xmlListPtr l,
    96 					 xmlListWalker walker,
    97 					 const void *user);
    98 void		xmlListReverseWalk	(xmlListPtr l,
    99 					 xmlListWalker walker,
    100 					 const void *user);
    101 void		xmlListMerge		(xmlListPtr l1,
    102 					 xmlListPtr l2);
    103 xmlListPtr	xmlListDup		(const xmlListPtr old);
    104 int		xmlListCopy		(xmlListPtr cur,
    105 					 const xmlListPtr old);
    106 /* Link operators */
    107 void *          xmlLinkGetData          (xmlLinkPtr lk);
    108 
    109 /* xmlListUnique() */
    110 /* xmlListSwap */
    111 
    112 #ifdef __cplusplus
    113 }
    114 #endif
    115 
    116 #endif /* __XML_LINK_INCLUDE__ */