fix typos in mathl
[gnulib.git] / lib / gl_list.c
index 546cb75..9eca9e4 100644 (file)
@@ -1,11 +1,11 @@
 /* Abstract sequential list data type.
-   Copyright (C) 2006 Free Software Foundation, Inc.
+   Copyright (C) 2006-2008 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2006.
 
-   This program is free software; you can redistribute it and/or modify
+   This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -13,8 +13,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software Foundation,
-   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 
@@ -31,21 +30,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
@@ -62,6 +63,13 @@ gl_list_node_value (gl_list_t list, gl_list_node_t node)
         ->node_value (list, node);
 }
 
+void
+gl_list_node_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);
+}
+
 gl_list_node_t
 gl_list_next_node (gl_list_t list, gl_list_node_t node)
 {
@@ -93,15 +101,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 (list, elt);
+        ->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_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
@@ -200,6 +240,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)
 {
@@ -207,6 +255,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)
 {