summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5Spoint.c25
-rw-r--r--src/H5Sprivate.h2
-rw-r--r--src/H5Spublic.h12
-rw-r--r--src/H5Sselect.c7
4 files changed, 29 insertions, 17 deletions
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index 7e17323..19d991f 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -124,7 +124,7 @@ H5S_point_init (const struct H5O_layout_t UNUSED *layout,
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-herr_t H5S_point_add (H5S_t *space, size_t num_elem, const hssize_t **_coord)
+herr_t H5S_point_add (H5S_t *space, H5S_seloper_t op, size_t num_elem, const hssize_t **_coord)
{
H5S_pnt_node_t *top, *curr, *new; /* Point selection nodes */
const hssize_t *coord=(const hssize_t *)_coord; /* Pointer to the actual coordinates */
@@ -136,6 +136,7 @@ herr_t H5S_point_add (H5S_t *space, size_t num_elem, const hssize_t **_coord)
assert(space);
assert(num_elem>0);
assert(coord);
+ assert(op==H5S_SELECT_SET || op==H5S_SELECT_APPEND || op==H5S_SELECT_PREPEND);
#ifdef QAK
printf("%s: check 1.0\n",FUNC);
@@ -186,12 +187,24 @@ herr_t H5S_point_add (H5S_t *space, size_t num_elem, const hssize_t **_coord)
printf("%s: check 2.0\n",FUNC);
#endif /* QAK */
- /* Append current list, if there is one */
- if(space->select.sel_info.pnt_lst->head!=NULL)
- curr->next=space->select.sel_info.pnt_lst->head;
+ /* Insert the list of points selected in the proper place */
+ if(op==H5S_SELECT_SET || op==H5S_SELECT_PREPEND) {
+ /* Append current list, if there is one */
+ if(space->select.sel_info.pnt_lst->head!=NULL)
+ curr->next=space->select.sel_info.pnt_lst->head;
- /* Put new list in point selection */
- space->select.sel_info.pnt_lst->head=top;
+ /* Put new list in point selection */
+ space->select.sel_info.pnt_lst->head=top;
+ }
+ else { /* op==H5S_SELECT_APPEND */
+ new=space->select.sel_info.pnt_lst->head;
+ if(new!=NULL)
+ while(new->next!=NULL)
+ new=new->next;
+
+ /* Append new list to point selection */
+ new->next=top;
+ }
/* Add the number of elements in the new selection */
space->select.num_elem+=num_elem;
diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h
index a55de31..ac822be 100644
--- a/src/H5Sprivate.h
+++ b/src/H5Sprivate.h
@@ -345,7 +345,7 @@ __DLL__ herr_t H5S_select_iterate(void *buf, hid_t type_id, H5S_t *space,
H5D_operator_t op, void *operator_data);
/* Point select functions */
-__DLL__ herr_t H5S_point_add(H5S_t *space, size_t num_elemn,
+__DLL__ herr_t H5S_point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem,
const hssize_t **coord);
__DLL__ herr_t H5S_point_release(H5S_t *space);
__DLL__ hsize_t H5S_point_npoints(const H5S_t *space);
diff --git a/src/H5Spublic.h b/src/H5Spublic.h
index afbb32b..3f57139 100644
--- a/src/H5Spublic.h
+++ b/src/H5Spublic.h
@@ -39,12 +39,12 @@ typedef enum H5S_class_t {
typedef enum H5S_seloper_t {
H5S_SELECT_NOOP = -1, /* error */
H5S_SELECT_SET = 0, /* Select "set" operation */
- H5S_SELECT_OR, /* Binary "or" operation (add new selection
- * to existing selection)
- */
- H5S_SELECT_INVALID /* Invalid upper bound on selection
- * operations
- */
+ H5S_SELECT_OR, /* Binary "or" operation for hyperslabs
+ * (add new selection to existing selection)
+ */
+ H5S_SELECT_APPEND, /* Append elements to end of point selection */
+ H5S_SELECT_PREPEND, /* Prepend elements to beginning of point selection */
+ H5S_SELECT_INVALID /* Invalid upper bound on selection operations */
} H5S_seloper_t;
#ifdef __cplusplus
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index 9f9e33b..32054f7 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -480,7 +480,7 @@ herr_t H5S_select_elements (H5S_t *space, H5S_seloper_t op, size_t num_elem,
assert(space);
assert(num_elem);
assert(coord);
- assert(op==H5S_SELECT_SET);
+ assert(op==H5S_SELECT_SET || op==H5S_SELECT_APPEND || op==H5S_SELECT_PREPEND);
#ifdef QAK
printf("%s: check 1.0\n",FUNC);
@@ -507,7 +507,7 @@ herr_t H5S_select_elements (H5S_t *space, H5S_seloper_t op, size_t num_elem,
printf("%s: check 3.0\n",FUNC);
#endif /* QAK */
/* Add points to selection */
- if(H5S_point_add(space,num_elem,coord)<0) {
+ if(H5S_point_add(space,op,num_elem,coord)<0) {
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL,
"can't insert elements");
}
@@ -568,7 +568,7 @@ herr_t H5Sselect_elements (hid_t spaceid, H5S_seloper_t op, size_t num_elem,
if(coord==NULL || num_elem==0) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "elements not specified");
} /* end if */
- if(op!=H5S_SELECT_SET) {
+ if(!(op==H5S_SELECT_SET || op==H5S_SELECT_APPEND || op==H5S_SELECT_PREPEND)) {
HRETURN_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL,
"operations other than H5S_SELECT_SET not supported currently");
} /* end if */
@@ -1451,7 +1451,6 @@ H5S_get_select_elem_pointlist(H5S_t *space, hsize_t startpoint, hsize_t numpoint
} /* end while */
/* Iterate through the node, copying each hyperslab's information */
- node=space->select.sel_info.pnt_lst->head;
while(node!=NULL && numpoints>0) {
HDmemcpy(buf,node->pnt,sizeof(hsize_t)*rank);
buf+=rank;