2 ** Copyright (C) 2002 by Kevin L. Mitchell <klmitch@mit.edu>
4 ** This library is free software; you can redistribute it and/or
5 ** modify it under the terms of the GNU Library General Public
6 ** License as published by the Free Software Foundation; either
7 ** version 2 of the License, or (at your option) any later version.
9 ** This library is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ** Library General Public License for more details.
14 ** You should have received a copy of the GNU Library General Public
15 ** License along with this library; if not, write to the Free
16 ** Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 #include "dbprim_int.h"
27 smat_table_t *si_table; /* pointer to the smat table */
28 smat_iter_t si_iter; /* iter function */
29 void *si_extra; /* extra data */
33 _sh_iter_iter(link_head_t *head, link_elem_t *elem, void *extra)
35 struct _sh_iter_s *si;
39 /* call the user iteration function--with appropriate translation */
40 return (*si->si_iter)(si->si_table, le_object(elem), si->si_extra);
43 /** \ingroup dbprim_smat
44 * \brief Iterate over each entry in a row or column of a sparse
47 * This function iterates over a row or column of a sparse matrix,
48 * executing the given \p iter_func for each entry.
50 * \param head A pointer to a #smat_head_t.
52 * A pointer to a callback function used to perform
53 * user-specified actions on an entry in a row or column
54 * of a sparse matrix. \c NULL is an invalid value. See
55 * the documentation for #smat_iter_t for more
57 * \param extra A \c void pointer that will be passed to \p
60 * \retval DB_ERR_BADARGS An argument was invalid.
63 sh_iter(smat_head_t *head, smat_iter_t iter_func, void *extra)
67 initialize_dbpr_error_table(); /* initialize error table */
69 if (!sh_verify(head) || !iter_func) /* verify arguments */
70 return DB_ERR_BADARGS;
72 /* initialize extra data... */
73 si.si_table = head->sh_table;
74 si.si_iter = iter_func;
77 /* call into linked list library to iterate over the list */
78 return ll_iter(&head->sh_head, _sh_iter_iter, &si);