mirror of
https://gitee.com/apaki/unicstl.git
synced 2025-05-18 03:51:35 +08:00
添加队列满的判断
This commit is contained in:
parent
cdb69e326b
commit
8f11e431b5
@ -242,7 +242,8 @@ static void queue_test_char(void)
|
|||||||
uint32_t len = sizeof(data) / sizeof(data[0]) - 1;
|
uint32_t len = sizeof(data) / sizeof(data[0]) - 1;
|
||||||
|
|
||||||
struct _queue queue;
|
struct _queue queue;
|
||||||
queue2_init(&queue, sizeof(char), 64);
|
// queue2_init(&queue, sizeof(char), 64);
|
||||||
|
queue2_init(&queue, sizeof(char), 10);
|
||||||
queue.print_obj = print_char;
|
queue.print_obj = print_char;
|
||||||
|
|
||||||
printf("\n\n----- queue_test_char -----\n");
|
printf("\n\n----- queue_test_char -----\n");
|
||||||
@ -250,17 +251,27 @@ static void queue_test_char(void)
|
|||||||
printf("----- after push-----\n");
|
printf("----- after push-----\n");
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
queue.push(&queue, &data[i]);
|
if(queue.push(&queue, &data[i]))
|
||||||
|
{
|
||||||
|
queue.front(&queue, &temp);
|
||||||
|
printf("front = ");
|
||||||
|
queue.print_obj(&temp);
|
||||||
|
|
||||||
queue.front(&queue, &temp);
|
queue.back(&queue, &temp);
|
||||||
printf("front = ");
|
printf("\tback = ");
|
||||||
queue.print_obj(&temp);
|
queue.print_obj(&temp);
|
||||||
|
|
||||||
queue.back(&queue, &temp);
|
printf("\tsize = %2d\n", queue.size(&queue));
|
||||||
printf("\tback = ");
|
}
|
||||||
queue.print_obj(&temp);
|
else
|
||||||
|
{
|
||||||
|
printf("push failed! because it is full\n");
|
||||||
|
}
|
||||||
|
|
||||||
printf("\tsize = %2d\n", queue.size(&queue));
|
if(queue.full(&queue))
|
||||||
|
{
|
||||||
|
printf("----- full -----\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
printf("----- print -----\n");
|
printf("----- print -----\n");
|
||||||
queue.print(&queue);
|
queue.print(&queue);
|
||||||
|
Loading…
Reference in New Issue
Block a user