/* Abstract sequential list data type.
- Copyright (C) 2006-2009 Free Software Foundation, Inc.
+ Copyright (C) 2006-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2006.
This program is free software: you can redistribute it and/or modify
DISPOSE_FN is an element disposal function or NULL.
ALLOW_DUPLICATES is false if duplicate elements shall not be allowed in
the list. The implementation may verify this at runtime. */
+#if 0 /* declared in gl_xlist.h */
extern gl_list_t gl_list_create_empty (gl_list_implementation_t implementation,
gl_listelement_equals_fn equals_fn,
gl_listelement_hashcode_fn hashcode_fn,
gl_listelement_dispose_fn dispose_fn,
bool allow_duplicates);
+#endif
+/* Likewise. Return NULL upon out-of-memory. */
+extern gl_list_t gl_list_nx_create_empty (gl_list_implementation_t implementation,
+ gl_listelement_equals_fn equals_fn,
+ gl_listelement_hashcode_fn hashcode_fn,
+ gl_listelement_dispose_fn dispose_fn,
+ bool allow_duplicates);
/* Create a list with given contents.
IMPLEMENTATION is one of GL_ARRAY_LIST, GL_CARRAY_LIST, GL_LINKED_LIST,
the list. The implementation may verify this at runtime.
COUNT is the number of initial elements.
CONTENTS[0..COUNT-1] is the initial contents. */
+#if 0 /* declared in gl_xlist.h */
extern gl_list_t gl_list_create (gl_list_implementation_t implementation,
gl_listelement_equals_fn equals_fn,
gl_listelement_hashcode_fn hashcode_fn,
gl_listelement_dispose_fn dispose_fn,
bool allow_duplicates,
size_t count, const void **contents);
+#endif
+/* Likewise. Return NULL upon out-of-memory. */
+extern gl_list_t gl_list_nx_create (gl_list_implementation_t implementation,
+ gl_listelement_equals_fn equals_fn,
+ gl_listelement_hashcode_fn hashcode_fn,
+ gl_listelement_dispose_fn dispose_fn,
+ bool allow_duplicates,
+ size_t count, const void **contents);
/* Return the current number of elements in a list. */
extern size_t gl_list_size (gl_list_t list);
extern const void * gl_list_node_value (gl_list_t list, gl_list_node_t node);
/* Replace the element value represented by a list node. */
+#if 0 /* declared in gl_xlist.h */
extern void gl_list_node_set_value (gl_list_t list, gl_list_node_t node,
const void *elt);
+#endif
+/* Likewise. Return 0 upon success, -1 upon out-of-memory. */
+extern int gl_list_node_nx_set_value (gl_list_t list, gl_list_node_t node,
+ const void *elt)
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+ ;
/* Return the node immediately after the given node in the list, or NULL
if the given node is the last (rightmost) one in the list. */
/* Replace the element at a given position in the list.
POSITION must be >= 0 and < gl_list_size (list).
Return its node. */
+#if 0 /* declared in gl_xlist.h */
extern gl_list_node_t gl_list_set_at (gl_list_t list, size_t position,
const void *elt);
+#endif
+/* Likewise. Return NULL upon out-of-memory. */
+extern gl_list_node_t gl_list_nx_set_at (gl_list_t list, size_t position,
+ const void *elt)
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+ ;
/* Search whether an element is already in the list.
Return its node if found, or NULL if not present in the list. */
/* Add an element as the first element of the list.
Return its node. */
+#if 0 /* declared in gl_xlist.h */
extern gl_list_node_t gl_list_add_first (gl_list_t list, const void *elt);
+#endif
+/* Likewise. Return NULL upon out-of-memory. */
+extern gl_list_node_t gl_list_nx_add_first (gl_list_t list, const void *elt)
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+ ;
/* Add an element as the last element of the list.
Return its node. */
+#if 0 /* declared in gl_xlist.h */
extern gl_list_node_t gl_list_add_last (gl_list_t list, const void *elt);
+#endif
+/* Likewise. Return NULL upon out-of-memory. */
+extern gl_list_node_t gl_list_nx_add_last (gl_list_t list, const void *elt)
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+ ;
/* Add an element before a given element node of the list.
Return its node. */
+#if 0 /* declared in gl_xlist.h */
extern gl_list_node_t gl_list_add_before (gl_list_t list, gl_list_node_t node,
const void *elt);
+#endif
+/* Likewise. Return NULL upon out-of-memory. */
+extern gl_list_node_t gl_list_nx_add_before (gl_list_t list,
+ gl_list_node_t node,
+ const void *elt)
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+ ;
/* Add an element after a given element node of the list.
Return its node. */
+#if 0 /* declared in gl_xlist.h */
extern gl_list_node_t gl_list_add_after (gl_list_t list, gl_list_node_t node,
const void *elt);
+#endif
+/* Likewise. Return NULL upon out-of-memory. */
+extern gl_list_node_t gl_list_nx_add_after (gl_list_t list, gl_list_node_t node,
+ const void *elt)
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+ ;
-/* Add an element add a given position in the list.
+/* Add an element at a given position in the list.
POSITION must be >= 0 and <= gl_list_size (list). */
+#if 0 /* declared in gl_xlist.h */
extern gl_list_node_t gl_list_add_at (gl_list_t list, size_t position,
const void *elt);
+#endif
+/* Likewise. Return NULL upon out-of-memory. */
+extern gl_list_node_t gl_list_nx_add_at (gl_list_t list, size_t position,
+ const void *elt)
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+ ;
/* Remove an element from the list.
Return true. */
/* Add an element at the appropriate position in the list.
The list is assumed to be sorted with COMPAR.
Return its node. */
+#if 0 /* declared in gl_xlist.h */
extern gl_list_node_t gl_sortedlist_add (gl_list_t list,
gl_listelement_compar_fn compar,
const void *elt);
+#endif
+/* Likewise. Return NULL upon out-of-memory. */
+extern gl_list_node_t gl_sortedlist_nx_add (gl_list_t list,
+ gl_listelement_compar_fn compar,
+ const void *elt)
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ __attribute__ ((__warn_unused_result__))
+#endif
+ ;
/* Search and remove an element from the list.
The list is assumed to be sorted with COMPAR.
struct gl_list_implementation
{
/* gl_list_t functions. */
- gl_list_t (*create_empty) (gl_list_implementation_t implementation,
- gl_listelement_equals_fn equals_fn,
- gl_listelement_hashcode_fn hashcode_fn,
- gl_listelement_dispose_fn dispose_fn,
- bool allow_duplicates);
- gl_list_t (*create) (gl_list_implementation_t implementation,
- gl_listelement_equals_fn equals_fn,
- gl_listelement_hashcode_fn hashcode_fn,
- gl_listelement_dispose_fn dispose_fn,
- bool allow_duplicates,
- size_t count, const void **contents);
+ gl_list_t (*nx_create_empty) (gl_list_implementation_t implementation,
+ gl_listelement_equals_fn equals_fn,
+ gl_listelement_hashcode_fn hashcode_fn,
+ gl_listelement_dispose_fn dispose_fn,
+ bool allow_duplicates);
+ gl_list_t (*nx_create) (gl_list_implementation_t implementation,
+ gl_listelement_equals_fn equals_fn,
+ gl_listelement_hashcode_fn hashcode_fn,
+ gl_listelement_dispose_fn dispose_fn,
+ bool allow_duplicates,
+ size_t count, const void **contents);
size_t (*size) (gl_list_t list);
const void * (*node_value) (gl_list_t list, gl_list_node_t node);
- void (*node_set_value) (gl_list_t list, gl_list_node_t node, const void *elt);
+ int (*node_nx_set_value) (gl_list_t list, gl_list_node_t node,
+ const void *elt);
gl_list_node_t (*next_node) (gl_list_t list, gl_list_node_t node);
gl_list_node_t (*previous_node) (gl_list_t list, gl_list_node_t node);
const void * (*get_at) (gl_list_t list, size_t position);
- gl_list_node_t (*set_at) (gl_list_t list, size_t position, const void *elt);
+ gl_list_node_t (*nx_set_at) (gl_list_t list, size_t position,
+ const void *elt);
gl_list_node_t (*search_from_to) (gl_list_t list, size_t start_index,
size_t end_index, const void *elt);
size_t (*indexof_from_to) (gl_list_t list, size_t start_index,
size_t end_index, const void *elt);
- gl_list_node_t (*add_first) (gl_list_t list, const void *elt);
- gl_list_node_t (*add_last) (gl_list_t list, const void *elt);
- gl_list_node_t (*add_before) (gl_list_t list, gl_list_node_t node,
- const void *elt);
- gl_list_node_t (*add_after) (gl_list_t list, gl_list_node_t node,
+ gl_list_node_t (*nx_add_first) (gl_list_t list, const void *elt);
+ gl_list_node_t (*nx_add_last) (gl_list_t list, const void *elt);
+ gl_list_node_t (*nx_add_before) (gl_list_t list, gl_list_node_t node,
+ const void *elt);
+ gl_list_node_t (*nx_add_after) (gl_list_t list, gl_list_node_t node,
+ const void *elt);
+ gl_list_node_t (*nx_add_at) (gl_list_t list, size_t position,
const void *elt);
- gl_list_node_t (*add_at) (gl_list_t list, size_t position,
- const void *elt);
bool (*remove_node) (gl_list_t list, gl_list_node_t node);
bool (*remove_at) (gl_list_t list, size_t position);
bool (*remove_elt) (gl_list_t list, const void *elt);
gl_listelement_compar_fn compar,
size_t start_index, size_t end_index,
const void *elt);
- gl_list_node_t (*sortedlist_add) (gl_list_t list,
- gl_listelement_compar_fn compar,
+ gl_list_node_t (*sortedlist_nx_add) (gl_list_t list,
+ gl_listelement_compar_fn compar,
const void *elt);
bool (*sortedlist_remove) (gl_list_t list,
gl_listelement_compar_fn compar,
struct gl_list_implementation.
Use #define to avoid a warning because of extern vs. static. */
-# define gl_list_create_empty gl_list_create_empty_inline
+# define gl_list_nx_create_empty gl_list_nx_create_empty_inline
static inline gl_list_t
-gl_list_create_empty (gl_list_implementation_t implementation,
- gl_listelement_equals_fn equals_fn,
- gl_listelement_hashcode_fn hashcode_fn,
- gl_listelement_dispose_fn dispose_fn,
- bool allow_duplicates)
+gl_list_nx_create_empty (gl_list_implementation_t implementation,
+ gl_listelement_equals_fn equals_fn,
+ gl_listelement_hashcode_fn hashcode_fn,
+ gl_listelement_dispose_fn dispose_fn,
+ bool allow_duplicates)
{
- return implementation->create_empty (implementation, equals_fn, hashcode_fn,
- dispose_fn, allow_duplicates);
+ return implementation->nx_create_empty (implementation, equals_fn,
+ hashcode_fn, dispose_fn,
+ allow_duplicates);
}
-# define gl_list_create gl_list_create_inline
+# define gl_list_nx_create gl_list_nx_create_inline
static inline gl_list_t
-gl_list_create (gl_list_implementation_t implementation,
- gl_listelement_equals_fn equals_fn,
- gl_listelement_hashcode_fn hashcode_fn,
- gl_listelement_dispose_fn dispose_fn,
- bool allow_duplicates,
- size_t count, const void **contents)
+gl_list_nx_create (gl_list_implementation_t implementation,
+ gl_listelement_equals_fn equals_fn,
+ gl_listelement_hashcode_fn hashcode_fn,
+ gl_listelement_dispose_fn dispose_fn,
+ bool allow_duplicates,
+ size_t count, const void **contents)
{
- return implementation->create (implementation, equals_fn, hashcode_fn,
- dispose_fn, allow_duplicates, count, contents);
+ return implementation->nx_create (implementation, equals_fn, hashcode_fn,
+ dispose_fn, allow_duplicates, count,
+ contents);
}
# define gl_list_size gl_list_size_inline
->node_value (list, node);
}
-# define gl_list_node_set_value gl_list_node_set_value_inline
-static inline void
-gl_list_node_set_value (gl_list_t list, gl_list_node_t node, const void *elt)
+# define gl_list_node_nx_set_value gl_list_node_nx_set_value_inline
+static inline int
+gl_list_node_nx_set_value (gl_list_t list, gl_list_node_t node,
+ const void *elt)
{
- ((const struct gl_list_impl_base *) list)->vtable
- ->node_set_value (list, node, elt);
+ return ((const struct gl_list_impl_base *) list)->vtable
+ ->node_nx_set_value (list, node, elt);
}
# define gl_list_next_node gl_list_next_node_inline
->get_at (list, position);
}
-# define gl_list_set_at gl_list_set_at_inline
+# define gl_list_nx_set_at gl_list_nx_set_at_inline
static inline gl_list_node_t
-gl_list_set_at (gl_list_t list, size_t position, const void *elt)
+gl_list_nx_set_at (gl_list_t list, size_t position, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable
- ->set_at (list, position, elt);
+ ->nx_set_at (list, position, elt);
}
# define gl_list_search gl_list_search_inline
->indexof_from_to (list, start_index, end_index, elt);
}
-# define gl_list_add_first gl_list_add_first_inline
+# define gl_list_nx_add_first gl_list_nx_add_first_inline
static inline gl_list_node_t
-gl_list_add_first (gl_list_t list, const void *elt)
+gl_list_nx_add_first (gl_list_t list, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable
- ->add_first (list, elt);
+ ->nx_add_first (list, elt);
}
-# define gl_list_add_last gl_list_add_last_inline
+# define gl_list_nx_add_last gl_list_nx_add_last_inline
static inline gl_list_node_t
-gl_list_add_last (gl_list_t list, const void *elt)
+gl_list_nx_add_last (gl_list_t list, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable
- ->add_last (list, elt);
+ ->nx_add_last (list, elt);
}
-# define gl_list_add_before gl_list_add_before_inline
+# define gl_list_nx_add_before gl_list_nx_add_before_inline
static inline gl_list_node_t
-gl_list_add_before (gl_list_t list, gl_list_node_t node, const void *elt)
+gl_list_nx_add_before (gl_list_t list, gl_list_node_t node, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable
- ->add_before (list, node, elt);
+ ->nx_add_before (list, node, elt);
}
-# define gl_list_add_after gl_list_add_after_inline
+# define gl_list_nx_add_after gl_list_nx_add_after_inline
static inline gl_list_node_t
-gl_list_add_after (gl_list_t list, gl_list_node_t node, const void *elt)
+gl_list_nx_add_after (gl_list_t list, gl_list_node_t node, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable
- ->add_after (list, node, elt);
+ ->nx_add_after (list, node, elt);
}
-# define gl_list_add_at gl_list_add_at_inline
+# define gl_list_nx_add_at gl_list_nx_add_at_inline
static inline gl_list_node_t
-gl_list_add_at (gl_list_t list, size_t position, const void *elt)
+gl_list_nx_add_at (gl_list_t list, size_t position, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable
- ->add_at (list, position, elt);
+ ->nx_add_at (list, position, elt);
}
# define gl_list_remove_node gl_list_remove_node_inline
elt);
}
-# define gl_sortedlist_add gl_sortedlist_add_inline
+# define gl_sortedlist_nx_add gl_sortedlist_nx_add_inline
static inline gl_list_node_t
-gl_sortedlist_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
+gl_sortedlist_nx_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt)
{
return ((const struct gl_list_impl_base *) list)->vtable
- ->sortedlist_add (list, compar, elt);
+ ->sortedlist_nx_add (list, compar, elt);
}
# define gl_sortedlist_remove gl_sortedlist_remove_inline