mirror of
https://gitee.com/apaki/unicstl.git
synced 2025-05-17 19:41:36 +08:00
困了,不写了。明天继续
This commit is contained in:
parent
cfcf212f96
commit
09e082cc68
@ -76,7 +76,16 @@ bool deque_back(struct _deque* self, void* obj)
|
||||
|
||||
bool deque_front(struct _deque* self, void* obj)
|
||||
{
|
||||
assert(self != NULL);
|
||||
assert(self->_head != NULL);
|
||||
assert(obj != NULL);
|
||||
|
||||
if (self->empty(self))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
memmove(obj, self->_head->prev->obj, self->_obj_size);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool deque_insert(struct _deque* self, int index, void* obj)
|
||||
@ -143,7 +152,7 @@ void deque_print(struct _deque* self)
|
||||
|
||||
uint32_t i = 0;
|
||||
struct _deque_node * node = self->_head->prev;
|
||||
while (node != self->_head->next)
|
||||
for (uint32_t i = 0; i < self->size(self); i++)
|
||||
{
|
||||
self->print_obj(node->obj);
|
||||
node = node->next;
|
||||
|
@ -24,16 +24,26 @@ static void deque_test_num(void)
|
||||
{
|
||||
dq.push_back(&dq, &data[i]);
|
||||
|
||||
dq.back(&dq, &temp);
|
||||
|
||||
printf("push_back = ");
|
||||
dq.front(&dq, &temp);
|
||||
printf("front = ");
|
||||
dq.print_obj(&temp);
|
||||
printf("\tsize after push_back = %2d\n", dq.size(&dq));
|
||||
|
||||
dq.back(&dq, &temp);
|
||||
printf("\tback = ");
|
||||
dq.print_obj(&temp);
|
||||
|
||||
printf("\tsize = %2d\n", dq.size(&dq));
|
||||
}
|
||||
printf("----- print -----\n");
|
||||
dq.print(&dq);
|
||||
printf("\n");
|
||||
|
||||
dq.clear(&dq);
|
||||
if (dq.empty(&dq))
|
||||
{
|
||||
printf("----- empty -----\n");
|
||||
}
|
||||
|
||||
#if 0
|
||||
printf("----- pop -----\n");
|
||||
for (i = 0; i < len + 1; i++)
|
||||
|
Loading…
Reference in New Issue
Block a user