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 _st_iter_iter(hash_table_t *table, hash_entry_t *ent, void *extra)
35 struct _st_iter_s *si;
39 /* call the user iteration function--with appropriate translation */
40 return (*si->si_iter)(si->si_table, he_value(ent), si->si_extra);
43 /** \ingroup dbprim_smat
44 * \brief Iterate over each entry in a sparse matrix.
46 * This function iterates over every entry in a sparse matrix (in an
47 * unspecified order), executing the given \p iter_func on each entry.
49 * \param table A pointer to a #smat_table_t.
51 * A pointer to a callback function used to perform
52 * user-specified actions on an entry in a sparse
53 * matrix. \c NULL is an invalid value. See the
54 * documentation for #smat_iter_t for more information.
55 * \param extra A \c void pointer that will be passed to \p
58 * \retval DB_ERR_BADARGS An argument was invalid.
59 * \retval DB_ERR_FROZEN The sparse matrix is frozen.
62 st_iter(smat_table_t *table, smat_iter_t iter_func, void *extra)
66 initialize_dbpr_error_table(); /* initialize error table */
68 if (!st_verify(table) || !iter_func) /* verify arguments */
69 return DB_ERR_BADARGS;
71 /* initialize extra data... */
73 si.si_iter = iter_func;
76 /* call into linked list library to iterate over the list */
77 return ht_iter(&table->st_table, _st_iter_iter, &si);