static tb_pointer_t tb_single_list_entry_itor_item(tb_iterator_ref_t iterator, tb_size_t itor) { // check tb_single_list_entry_head_ref_t list = tb_container_of(tb_single_list_entry_head_t, itor, iterator); tb_assert(list && list->eoff < itor); // data return (tb_pointer_t)(itor - list->eoff); }
static tb_size_t tb_single_list_entry_itor_last(tb_iterator_ref_t iterator) { // check tb_single_list_entry_head_ref_t list = tb_container_of(tb_single_list_entry_head_t, itor, iterator); tb_assert(list); // last return (tb_size_t)list->last; }
/* ////////////////////////////////////////////////////////////////////////////////////// * iterator implementation */ static tb_size_t tb_single_list_entry_itor_size(tb_iterator_ref_t iterator) { // check tb_single_list_entry_head_ref_t list = tb_container_of(tb_single_list_entry_head_t, itor, iterator); tb_assert(list); // the size return list->size; }
static tb_size_t tb_single_list_entry_itor_head(tb_iterator_ref_t iterator) { // check tb_single_list_entry_head_ref_t list = tb_container_of(tb_single_list_entry_head_t, itor, iterator); tb_assert_abort(list); // head return (tb_size_t)list->next; }
static tb_void_t tb_single_list_entry_itor_copy(tb_iterator_ref_t iterator, tb_size_t itor, tb_cpointer_t item) { // check tb_single_list_entry_head_ref_t list = tb_container_of(tb_single_list_entry_head_t, itor, iterator); tb_assert(list && list->copy); tb_assert(list->eoff < itor && item); // copy it list->copy((tb_pointer_t)(itor - list->eoff), (tb_pointer_t)item); }
static tb_void_t tb_single_list_entry_itor_remove_range(tb_iterator_ref_t iterator, tb_size_t prev, tb_size_t next, tb_size_t size) { // check tb_single_list_entry_head_ref_t list = tb_container_of(tb_single_list_entry_head_t, itor, iterator); tb_assert(list && prev && next); // no size? tb_check_return(size); // the entry tb_single_list_entry_ref_t prev_entry = (tb_single_list_entry_ref_t)prev; tb_single_list_entry_ref_t next_entry = (tb_single_list_entry_ref_t)next; // remove entries prev_entry->next = next_entry; // update size list->size -= size; }