mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-22 15:37:59 +00:00
unset iterate
This commit is contained in:
parent
53d94825b1
commit
27da05a3b6
1 changed files with 39 additions and 38 deletions
|
|
@ -24,7 +24,8 @@ static void mlhmmv_level_init(mlhmmv_level_t *plevel, int length);
|
|||
static void mlhmmv_level_free(mlhmmv_level_t* plevel);
|
||||
|
||||
static int mlhmmv_level_find_index_for_key(mlhmmv_level_t* plevel, mv_t* plevel_key, int* pideal_index);
|
||||
static mlhmmv_level_entry_t* mlhmmv_get_level_entry(mlhmmv_t* pmap, sllmv_t* pmvkeys);
|
||||
static mlhmmv_level_entry_t* mlhmmv_get_level_entry(mlhmmv_t* pmap, sllmv_t* pmvkeys,
|
||||
int* pindex, mlhmmv_level_t** pplevel_up);
|
||||
|
||||
static void mlhmmv_level_put(mlhmmv_level_t* plevel, sllmve_t* prest_keys, mv_t* pterminal_value);
|
||||
static void mlhmmv_level_put_no_enlarge(mlhmmv_level_t* plevel, sllmve_t* prest_keys, mv_t* pterminal_value);
|
||||
|
|
@ -310,7 +311,10 @@ mv_t* mlhmmv_get(mlhmmv_t* pmap, sllmv_t* pmvkeys, int* perror) {
|
|||
return &plevel_entry->level_value.u.mlrval;
|
||||
}
|
||||
|
||||
static mlhmmv_level_entry_t* mlhmmv_get_level_entry(mlhmmv_t* pmap, sllmv_t* pmvkeys) {
|
||||
static mlhmmv_level_entry_t* mlhmmv_get_level_entry(mlhmmv_t* pmap, sllmv_t* pmvkeys,
|
||||
int* pindex, mlhmmv_level_t** pplevel_up)
|
||||
{
|
||||
*pindex = -1;
|
||||
sllmve_t* prest_keys = pmvkeys->phead;
|
||||
if (prest_keys == NULL) {
|
||||
return NULL;
|
||||
|
|
@ -331,6 +335,8 @@ static mlhmmv_level_entry_t* mlhmmv_get_level_entry(mlhmmv_t* pmap, sllmv_t* pmv
|
|||
if (plevel_entry == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
// xxx assign *pindex
|
||||
// xxx assign pplevel_up
|
||||
return plevel_entry;
|
||||
}
|
||||
|
||||
|
|
@ -353,47 +359,42 @@ mlhmmv_level_entry_t* mlhmmv_get_next_level_entry(mlhmmv_level_t* plevel, mv_t*
|
|||
// xxx cmt re remove from here on down
|
||||
|
||||
void mlhmmv_remove(mlhmmv_t* pmap, sllmv_t* pmvkeys) {
|
||||
mlhmmv_level_entry_t* plevel_entry = mlhmmv_get_level_entry(pmap, pmvkeys);
|
||||
int index = -1;
|
||||
mlhmmv_level_t* plevel_up = NULL;
|
||||
mlhmmv_level_entry_t* plevel_entry = mlhmmv_get_level_entry(pmap, pmvkeys, &index, &plevel_up);
|
||||
if (plevel_entry == NULL)
|
||||
return;
|
||||
|
||||
// 1. excise the node and its descendants from the storage tree
|
||||
// 1. Excise the node and its descendants from the storage tree
|
||||
if (plevel_up->states[index] == OCCUPIED) {
|
||||
plevel_entry->ideal_index = -1;
|
||||
plevel_up->states[index] = DELETED;
|
||||
|
||||
//void lhmss_remove(lhmss_t* pmap, char* key) {
|
||||
// int index = lhmss_find_index_for_key(pmap, key);
|
||||
// lhmsse_t* pe = &pmap->entries[index];
|
||||
// if (pmap->states[index] == OCCUPIED) {
|
||||
// pe->ideal_index = -1;
|
||||
// pe->key = NULL;
|
||||
// pe->value = NULL;
|
||||
// pmap->states[index] = DELETED;
|
||||
//
|
||||
// if (pe == pmap->phead) {
|
||||
// if (pe == pmap->ptail) {
|
||||
// pmap->phead = NULL;
|
||||
// pmap->ptail = NULL;
|
||||
// } else {
|
||||
// pmap->phead = pe->pnext;
|
||||
// }
|
||||
// } else {
|
||||
// pe->pprev->pnext = pe->pnext;
|
||||
// pe->pnext->pprev = pe->pprev;
|
||||
// }
|
||||
//
|
||||
// pmap->num_freed++;
|
||||
// pmap->num_occupied--;
|
||||
// return;
|
||||
// }
|
||||
// else if (pmap->states[index] == EMPTY) {
|
||||
// return;
|
||||
// }
|
||||
// else {
|
||||
// fprintf(stderr, "lhmss_find_index_for_key did not find end of chain.\n");
|
||||
// exit(1);
|
||||
// }
|
||||
//}
|
||||
if (plevel_entry == plevel_up->phead) {
|
||||
if (plevel_entry == plevel_up->ptail) {
|
||||
plevel_up->phead = NULL;
|
||||
plevel_up->ptail = NULL;
|
||||
} else {
|
||||
plevel_up->phead = plevel_entry->pnext;
|
||||
}
|
||||
} else {
|
||||
plevel_entry->pprev->pnext = plevel_entry->pnext;
|
||||
plevel_entry->pnext->pprev = plevel_entry->pprev;
|
||||
}
|
||||
|
||||
// 2. free the memory for the node and its descendants
|
||||
plevel_up->num_freed++;
|
||||
plevel_up->num_occupied--;
|
||||
return;
|
||||
}
|
||||
else if (plevel_up->states[index] == EMPTY) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "%s: mlhmmv_remove: did not find end of chain.\n", MLR_GLOBALS.argv0);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// 2. Free the memory for the node and its descendants
|
||||
if (plevel_entry->level_value.is_terminal) {
|
||||
mv_free(&plevel_entry->level_value.u.mlrval);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue