add function uniq_skiplist_clear
parent
a19119f962
commit
2c5734ab22
3
HISTORY
3
HISTORY
|
|
@ -1,8 +1,9 @@
|
|||
|
||||
Version 1.66 2023-05-04
|
||||
Version 1.66 2023-05-08
|
||||
* struct fast_task_info add field: notify_next for nio notify queue
|
||||
* lc_pair in struct fc_queue change to lcp
|
||||
* sorted queue use double link chain for quick push
|
||||
* add function uniq_skiplist_clear
|
||||
|
||||
Version 1.65 2023-01-09
|
||||
* locked_list.h: add functions locked_list_move and locked_list_move_tail
|
||||
|
|
|
|||
|
|
@ -149,6 +149,19 @@ static void test_delete()
|
|||
assert(i==0);
|
||||
}
|
||||
|
||||
static void test_clear()
|
||||
{
|
||||
int64_t start_time;
|
||||
int64_t end_time;
|
||||
|
||||
start_time = get_current_time_ms();
|
||||
uniq_skiplist_clear(sl);
|
||||
assert(uniq_skiplist_empty(sl));
|
||||
assert(instance_count == 0);
|
||||
end_time = get_current_time_ms();
|
||||
printf("clear time used: %"PRId64" ms\n", end_time - start_time);
|
||||
}
|
||||
|
||||
static void test_find_range()
|
||||
{
|
||||
int n_start;
|
||||
|
|
@ -302,10 +315,8 @@ int main(int argc, char *argv[])
|
|||
test_insert();
|
||||
printf("\n");
|
||||
|
||||
/*
|
||||
test_delete();
|
||||
test_clear();
|
||||
printf("\n");
|
||||
*/
|
||||
|
||||
printf("skiplist level_count: %d\n", sl->top_level_index + 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -253,6 +253,19 @@ static inline bool uniq_skiplist_empty(UniqSkiplist *sl)
|
|||
return sl->top->links[0] == sl->factory->tail;
|
||||
}
|
||||
|
||||
static inline void uniq_skiplist_clear(UniqSkiplist *sl)
|
||||
{
|
||||
volatile UniqSkiplistNode *current;
|
||||
volatile UniqSkiplistNode *deleted;
|
||||
|
||||
current = sl->top->links[0];
|
||||
while (current != sl->factory->tail) {
|
||||
deleted = current;
|
||||
current = current->links[0];
|
||||
uniq_skiplist_delete(sl, deleted->data);
|
||||
}
|
||||
}
|
||||
|
||||
#define LEVEL0_DOUBLE_CHAIN_NEXT_LINK(node) node->links[0]
|
||||
#define LEVEL0_DOUBLE_CHAIN_PREV_LINK(node) node->links[node->level_index + 1]
|
||||
#define LEVEL0_DOUBLE_CHAIN_TAIL(sl) LEVEL0_DOUBLE_CHAIN_PREV_LINK(sl->top)
|
||||
|
|
|
|||
Loading…
Reference in New Issue