[svn-r9730] Purpose:

Code cleanup (sorta)

Description:
    Transition the generic property list code from using the threaded, balanced
binary tree code (H5TB<foo>() routines) to use skip lists (H5SL<foo>() routines)
for internal management of properties, etc.

Platforms tested:
    FreeBSD 4.10 (sleipnir)
    Too minor to require h5committest
This commit is contained in:
Quincey Koziol 2004-12-30 09:27:29 -05:00
parent 427ff7da28
commit 11631664fd
5 changed files with 333 additions and 339 deletions

637
src/H5P.c

File diff suppressed because it is too large Load Diff

View File

@ -38,7 +38,7 @@
#include "H5Pprivate.h"
/* Other private headers needed by this file */
#include "H5TBprivate.h" /* Threaded, balanced, binary trees (TBBTs) */
#include "H5SLprivate.h" /* Skip lists */
/* Define enum for type of object that property is within */
typedef enum {
@ -89,7 +89,7 @@ struct H5P_genclass_t {
unsigned internal; /* Whether this class is internal to the library or not */
unsigned deleted; /* Whether this class has been deleted and is waiting for dependent classes & proplists to close */
unsigned revision; /* Revision number of a particular class (global) */
H5TB_TREE *props; /* TBBT containing properties */
H5SL_t *props; /* Skip list containing properties */
/* Callback function pointers & info */
H5P_cls_create_func_t create_func; /* Function to call when a property list is created */
@ -106,12 +106,12 @@ struct H5P_genplist_t {
hid_t plist_id; /* Copy of the property list ID (for use in close callback) */
size_t nprops; /* Number of properties in class */
unsigned class_init:1; /* Whether the class initialization callback finished successfully */
H5TB_TREE *del; /* TBBT containing names of deleted properties */
H5TB_TREE *props; /* TBBT containing properties */
H5SL_t *del; /* Skip list containing names of deleted properties */
H5SL_t *props; /* Skip list containing properties */
};
/* Private functions, not part of the publicly documented API */
H5_DLL herr_t H5P_add_prop(H5TB_TREE *props, H5P_genprop_t *prop);
H5_DLL herr_t H5P_add_prop(H5SL_t *props, H5P_genprop_t *prop);
H5_DLL herr_t H5P_access_class(H5P_genclass_t *pclass, H5P_class_mod_t mod);
H5_DLL char *H5P_get_class_path(H5P_genclass_t *pclass);
H5_DLL H5P_genclass_t *H5P_open_class_path(const char *path);

View File

@ -27,6 +27,11 @@
* actual 'forward' pointer to update, instead of the node
* containing the forward pointer -QAK)
*
* (Note: This implementation does not have the information for
* implementing the "Linear List Operations" (like insert/delete/
* search by position) in section 3.4 of "A Skip List Cookbook",
* but they shouldn't be that hard to add, if necessary)
*
*/
/* Interface initialization */
@ -47,7 +52,7 @@
/* Define the code template for insertions for the "OP" in the H5SL_FIND macro */
#define H5SL_FIND_INSERT_FOUND(SLIST,X,UPDATE,I,ITEM) \
HGOTO_DONE(FAIL);
HGOTO_ERROR(H5E_SLIST,H5E_CANTINSERT,FAIL,"can't insert duplicate key");
/* Define the code template for removals for the "OP" in the H5SL_FIND macro */
#define H5SL_FIND_REMOVE_FOUND(SLIST,X,UPDATE,I,ITEM) \
@ -82,7 +87,7 @@
/* Define a code template for comparing string keys for the "CMP" in the H5SL_FIND macro */
#define H5SL_FIND_STRING_CMP(TYPE,PKEY1,PKEY2) \
(HDstrcmp(*(TYPE *)PKEY1,*(TYPE *)PKEY2)<0)
(HDstrcmp(PKEY1,PKEY2)<0)
/* Define a code template for comparing scalar keys for the "EQ" in the H5SL_FIND macro */
#define H5SL_FIND_SCALAR_EQ(TYPE,PKEY1,PKEY2) \
@ -90,7 +95,7 @@
/* Define a code template for comparing string keys for the "EQ" in the H5SL_FIND macro */
#define H5SL_FIND_STRING_EQ(TYPE,PKEY1,PKEY2) \
(HDstrcmp(*(TYPE *)PKEY1,*(TYPE *)PKEY2)==0)
(HDstrcmp(PKEY1,PKEY2)==0)
/* Macro used to find node for operation */
#define H5SL_FIND(OP,DOUPDATE,CMP,SLIST,X,UPDATE,I,TYPE,ITEM,KEY,CHECKED) \
@ -492,7 +497,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
void *
H5SL_search(H5SL_t *slist, void *key)
H5SL_search(H5SL_t *slist, const void *key)
{
H5SL_node_t *checked; /* Pointer to last node checked */
H5SL_node_t *x; /* Current node to examine */
@ -516,11 +521,11 @@ H5SL_search(H5SL_t *slist, void *key)
x=slist->header;
switch(slist->type) {
case H5SL_TYPE_INT:
H5SL_SEARCH(SCALAR,slist,x,-,i,int,-,key,checked)
H5SL_SEARCH(SCALAR,slist,x,-,i,const int,-,key,checked)
break;
case H5SL_TYPE_HADDR:
H5SL_SEARCH(SCALAR,slist,x,-,i,haddr_t,-,key,checked)
H5SL_SEARCH(SCALAR,slist,x,-,i,const haddr_t,-,key,checked)
break;
case H5SL_TYPE_STR:
@ -556,7 +561,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
void *
H5SL_remove(H5SL_t *slist, void *key)
H5SL_remove(H5SL_t *slist, const void *key)
{
H5SL_node_t **update[H5SL_LEVEL_MAX]; /* 'update' vector */
H5SL_node_t *checked; /* Pointer to last node checked */

View File

@ -60,8 +60,8 @@ typedef herr_t (*H5SL_operator_t)(void *item, void *key,
H5_DLL H5SL_t *H5SL_create(H5SL_type_t type, double p, size_t max_level);
H5_DLL size_t H5SL_count(H5SL_t *slist);
H5_DLL herr_t H5SL_insert(H5SL_t *slist, void *item, void *key);
H5_DLL void *H5SL_remove(H5SL_t *slist, void *key);
H5_DLL void *H5SL_search(H5SL_t *slist, void *key);
H5_DLL void *H5SL_remove(H5SL_t *slist, const void *key);
H5_DLL void *H5SL_search(H5SL_t *slist, const void *key);
H5_DLL H5SL_node_t *H5SL_first(H5SL_t *slist);
H5_DLL H5SL_node_t *H5SL_next(H5SL_node_t *slist_node);
H5_DLL void *H5SL_item(H5SL_node_t *slist_node);

View File

@ -552,7 +552,7 @@ test_skiplist_string(void)
/* Insert objects into the skip list */
for(u=0; u<10; u++) {
ret=H5SL_insert(slist,&data[u],&data[u].s);
ret=H5SL_insert(slist,&data[u],data[u].s);
CHECK(ret, FAIL, "H5SL_insert");
} /* end for */