summaryrefslogtreecommitdiffstats
path: root/src/H5Spoint.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>1999-06-24 02:16:13 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>1999-06-24 02:16:13 (GMT)
commitc4c6318e6ab92d8204226923e8e9302e2779aaf4 (patch)
treeeb925287f4f0ac500619d9259ffbbe8fb9342acc /src/H5Spoint.c
parentace37763c377153217564e4dd08c2fcc385e83c4 (diff)
downloadhdf5-c4c6318e6ab92d8204226923e8e9302e2779aaf4.zip
hdf5-c4c6318e6ab92d8204226923e8e9302e2779aaf4.tar.gz
hdf5-c4c6318e6ab92d8204226923e8e9302e2779aaf4.tar.bz2
[svn-r1374] Added in code to support the H5Diterate function, which I've got to add tests
for now. Also, I revised some of the code for hyperslab I/O, which should provide a modest speedup in situations with lots of hyperslabs.
Diffstat (limited to 'src/H5Spoint.c')
-rw-r--r--src/H5Spoint.c77
1 files changed, 76 insertions, 1 deletions
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index ac3d3e1..583aab7 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -9,6 +9,7 @@
*/
#include <H5private.h>
#include <H5Eprivate.h>
+#include <H5Iprivate.h>
#include <H5MMprivate.h>
#include <H5Sprivate.h>
#include <H5Vprivate.h>
@@ -1107,4 +1108,78 @@ H5S_point_select_contiguous(const H5S_t *space)
ret_value=FALSE;
FUNC_LEAVE (ret_value);
-} /* H5S_select_contiguous() */
+} /* H5S_point_select_contiguous() */
+
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5S_point_select_iterate
+ PURPOSE
+ Iterate over a point selection, calling a user's function for each
+ element.
+ USAGE
+ herr_t H5S_point_select_iterate(buf, type_id, space, operator, operator_data)
+ void *buf; IN/OUT: Buffer containing elements to iterate over
+ hid_t type_id; IN: Datatype ID of BUF array.
+ H5S_t *space; IN: Dataspace object containing selection to iterate over
+ H5D_operator_t operator; IN: Function pointer to the routine to be
+ called for each element in BUF iterated over.
+ void *operator_data; IN/OUT: Pointer to any user-defined data
+ associated with the operation.
+ RETURNS
+ Returns the return value of the last operator if it was non-zero, or zero
+ if all elements were processed. Otherwise returns a negative value.
+ DESCRIPTION
+ Iterates over the selected elements in a memory buffer, calling the user's
+ callback function for each element. The selection in the dataspace is
+ modified so that any elements already iterated over are removed from the
+ selection if the iteration is interrupted (by the H5D_operator_t function
+ returning non-zero) in the "middle" of the iteration and may be re-started
+ by the user where it left off.
+
+ NOTE: Until "subtracting" elements from a selection is implemented,
+ the selection is not modified.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+herr_t
+H5S_point_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t operator,
+ void *operator_data)
+{
+ hsize_t mem_size[H5O_LAYOUT_NDIMS]; /* Dataspace size */
+ hsize_t offset; /* offset of region in buffer */
+ void *tmp_buf; /* temporary location of the element in the buffer */
+ H5S_pnt_node_t *node; /* Point node */
+ intn rank; /* Dataspace rank */
+ herr_t ret_value=0; /* return value */
+
+ FUNC_ENTER (H5S_point_select_iterate, 0);
+
+ assert(buf);
+ assert(space);
+ assert(operator);
+ assert(H5I_DATATYPE != H5I_get_type(type_id));
+
+ /* Get the dataspace extent rank */
+ rank=space->extent.u.simple.rank;
+
+ /* Set up the size of the memory space */
+ HDmemcpy(mem_size, space->extent.u.simple.size, rank*sizeof(hsize_t));
+ mem_size[rank]=H5Tget_size(type_id);
+
+ /* Iterate through the node, checking the bounds on each element */
+ node=space->select.sel_info.pnt_lst->head;
+ while(node!=NULL && ret_value==0) {
+ /* Get the offset in the memory buffer */
+ offset=H5V_array_offset(rank+1,mem_size,node->pnt);
+ tmp_buf=((char *)buf+offset);
+
+ ret_value=(*operator)(tmp_buf,type_id,rank,node->pnt,operator_data);
+
+ node=node->next;
+ } /* end while */
+
+ FUNC_LEAVE (ret_value);
+} /* H5S_point_select_iterate() */