diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2008-10-07 13:32:32 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2008-10-07 13:32:32 (GMT) |
commit | bdbdbb9f89db8d3a76fc71705cdbbd89124f4687 (patch) | |
tree | 53d16d2097c591d2c7094da6b8e2b23ef5663a0f /src/H5SL.c | |
parent | b256db872d5ce4f81c6486b60c4e29e8122b67c2 (diff) | |
download | hdf5-bdbdbb9f89db8d3a76fc71705cdbbd89124f4687.zip hdf5-bdbdbb9f89db8d3a76fc71705cdbbd89124f4687.tar.gz hdf5-bdbdbb9f89db8d3a76fc71705cdbbd89124f4687.tar.bz2 |
[svn-r15801] Description:
Bring r15800 back from trunk:
- File free space branch changes through r15794
Tested on:
Mac OS X/32 10.5.5 (amazon) in debug mode
Mac OS X/32 10.5.5 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Diffstat (limited to 'src/H5SL.c')
-rw-r--r-- | src/H5SL.c | 181 |
1 files changed, 181 insertions, 0 deletions
@@ -1290,6 +1290,187 @@ done: /*-------------------------------------------------------------------------- NAME + H5SL_below + PURPOSE + Search for _node_ in a skip list whose object is less than or equal to 'key' + USAGE + H5SL_node_t *H5SL_below(slist, key) + H5SL_t *slist; IN/OUT: Pointer to skip list + void *key; IN: Key for item to search for + + RETURNS + Returns pointer to _node_ who key is less than or equal to 'key' on success, + NULL on failure + DESCRIPTION + Search for a node with an object in a skip list, according to it's key, + returning the node itself (for an exact match), or the node with the next + highest key that is less than 'key' + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +H5SL_node_t * +H5SL_below(H5SL_t *slist, const void *key) +{ + H5SL_node_t *x; /* Current node to examine */ + uint32_t hashval = 0; /* Hash value for key */ + H5SL_node_t *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_below) + + /* Check args */ + HDassert(slist); + HDassert(key); + + /* Check internal consistency */ + /* (Pre-condition) */ + + /* Insert item into skip list */ + + /* Work through the forward pointers for a node, finding the node at each + * level that is before the location to insert + */ + x = slist->header; + switch(slist->type) { + case H5SL_TYPE_INT: + H5SL_FIND(SCALAR, slist, x, -, const int, key, -) + break; + + case H5SL_TYPE_HADDR: + H5SL_FIND(SCALAR, slist, x, -, const haddr_t, key, -) + break; + + case H5SL_TYPE_STR: + H5SL_FIND(STRING, slist, x, -, char *, key, hashval) + break; + + case H5SL_TYPE_HSIZE: + H5SL_FIND(SCALAR, slist, x, -, const hsize_t, key, -) + break; + + case H5SL_TYPE_UNSIGNED: + H5SL_FIND(SCALAR, slist, x, -, const unsigned, key, -) + break; + + case H5SL_TYPE_SIZE: + H5SL_FIND(SCALAR, slist, x, -, const size_t, key, -) + break; + + case H5SL_TYPE_OBJ: + H5SL_FIND(OBJ, slist, x, -, const H5_obj_t, key, -) + break; + } /* end switch */ + + /* An exact match for 'key' must not have been found in list, if we get here */ + /* Check for a node with a key that is less than the given 'key' */ + if(NULL == x) { + /* Check for walking off the list */ + if(slist->last != slist->header) + ret_value = slist->last; + else + ret_value = NULL; + } /* end if */ + else { + if(x->backward != slist->header) + ret_value = x->backward; + else + ret_value = NULL; + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5SL_below() */ + + +/*-------------------------------------------------------------------------- + NAME + H5SL_above + PURPOSE + Search for _node_ in a skip list whose object is greater than or equal to 'key' + USAGE + H5SL_node_t *H5SL_above(slist, key) + H5SL_t *slist; IN/OUT: Pointer to skip list + void *key; IN: Key for item to search for + + RETURNS + Returns pointer to _node_ with object that has a key is greater than or + equal to 'key' on success, NULL on failure + DESCRIPTION + Search for a node with an object in a skip list, according to it's key, + returning the node itself (for an exact match), or the node with the next + lowest key that is greater than 'key' + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +H5SL_node_t * +H5SL_above(H5SL_t *slist, const void *key) +{ + H5SL_node_t *x; /* Current node to examine */ + uint32_t hashval = 0; /* Hash value for key */ + H5SL_node_t *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SL_above) + + /* Check args */ + HDassert(slist); + HDassert(key); + + /* Check internal consistency */ + /* (Pre-condition) */ + + /* Insert item into skip list */ + + /* Work through the forward pointers for a node, finding the node at each + * level that is before the location to insert + */ + x = slist->header; + switch(slist->type) { + case H5SL_TYPE_INT: + H5SL_FIND(SCALAR, slist, x, -, const int, key, -) + break; + + case H5SL_TYPE_HADDR: + H5SL_FIND(SCALAR, slist, x, -, const haddr_t, key, -) + break; + + case H5SL_TYPE_STR: + H5SL_FIND(STRING, slist, x, -, char *, key, hashval) + break; + + case H5SL_TYPE_HSIZE: + H5SL_FIND(SCALAR, slist, x, -, const hsize_t, key, -) + break; + + case H5SL_TYPE_UNSIGNED: + H5SL_FIND(SCALAR, slist, x, -, const unsigned, key, -) + break; + + case H5SL_TYPE_SIZE: + H5SL_FIND(SCALAR, slist, x, -, const size_t, key, -) + break; + + case H5SL_TYPE_OBJ: + H5SL_FIND(OBJ, slist, x, -, const H5_obj_t, key, -) + break; + } /* end switch */ + + /* An exact match for 'key' must not have been found in list, if we get here */ + /* ('x' must be the next node with a key greater than the 'key', or NULL) */ + if(x) + ret_value = x; + else + ret_value = NULL; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5SL_above() */ + + +/*-------------------------------------------------------------------------- + NAME H5SL_first PURPOSE Gets a pointer to the first node in a skip list |