X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fgl_list.c;h=80a1bbe3b02d2a10f002d7db545a3665d4b63eda;hb=7a3608f2dd5e42abfe6325869258d645f375e691;hp=17c2fd9541b994e9d26d47213812fc02a787eca6;hpb=c2f1b9b91eace2249cc9bb9df6c308341310a9b4;p=gnulib.git diff --git a/lib/gl_list.c b/lib/gl_list.c index 17c2fd954..80a1bbe3b 100644 --- a/lib/gl_list.c +++ b/lib/gl_list.c @@ -1,5 +1,5 @@ /* Abstract sequential list data type. - Copyright (C) 2006 Free Software Foundation, Inc. + Copyright (C) 2006-2007 Free Software Foundation, Inc. Written by Bruno Haible , 2006. This program is free software; you can redistribute it and/or modify @@ -16,9 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifdef HAVE_CONFIG_H -# include -#endif +#include /* Specification. */ #include "gl_list.h" @@ -33,21 +31,23 @@ 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) { return implementation->create_empty (implementation, equals_fn, hashcode_fn, - allow_duplicates); + dispose_fn, allow_duplicates); } 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) { return implementation->create (implementation, equals_fn, hashcode_fn, - allow_duplicates, count, contents); + dispose_fn, allow_duplicates, count, contents); } size_t @@ -95,15 +95,47 @@ gl_list_set_at (gl_list_t list, size_t position, const void *elt) gl_list_node_t gl_list_search (gl_list_t list, const void *elt) { + size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list); + return ((const struct gl_list_impl_base *) list)->vtable + ->search_from_to (list, 0, size, elt); +} + +gl_list_node_t +gl_list_search_from (gl_list_t list, size_t start_index, const void *elt) +{ + size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list); + return ((const struct gl_list_impl_base *) list)->vtable + ->search_from_to (list, start_index, size, elt); +} + +gl_list_node_t +gl_list_search_from_to (gl_list_t list, size_t start_index, size_t end_index, const void *elt) +{ return ((const struct gl_list_impl_base *) list)->vtable - ->search (list, elt); + ->search_from_to (list, start_index, end_index, elt); } size_t gl_list_indexof (gl_list_t list, const void *elt) { + size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list); + return ((const struct gl_list_impl_base *) list)->vtable + ->indexof_from_to (list, 0, size, elt); +} + +size_t +gl_list_indexof_from (gl_list_t list, size_t start_index, const void *elt) +{ + size_t size = ((const struct gl_list_impl_base *) list)->vtable->size (list); return ((const struct gl_list_impl_base *) list)->vtable - ->indexof (list, elt); + ->indexof_from_to (list, start_index, size, elt); +} + +size_t +gl_list_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index, const void *elt) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->indexof_from_to (list, start_index, end_index, elt); } gl_list_node_t @@ -202,6 +234,14 @@ gl_sortedlist_search (gl_list_t list, gl_listelement_compar_fn compar, const voi ->sortedlist_search (list, compar, elt); } +gl_list_node_t +gl_sortedlist_search_from_to (gl_list_t list, gl_listelement_compar_fn compar, size_t start_index, size_t end_index, const void *elt) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->sortedlist_search_from_to (list, compar, start_index, end_index, + elt); +} + size_t gl_sortedlist_indexof (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) { @@ -209,6 +249,14 @@ gl_sortedlist_indexof (gl_list_t list, gl_listelement_compar_fn compar, const vo ->sortedlist_indexof (list, compar, elt); } +size_t +gl_sortedlist_indexof_from_to (gl_list_t list, gl_listelement_compar_fn compar, size_t start_index, size_t end_index, const void *elt) +{ + return ((const struct gl_list_impl_base *) list)->vtable + ->sortedlist_indexof_from_to (list, compar, start_index, end_index, + elt); +} + gl_list_node_t gl_sortedlist_add (gl_list_t list, gl_listelement_compar_fn compar, const void *elt) {