mirror of
https://gitee.com/apaki/unicstl.git
synced 2026-05-29 07:04:20 +08:00
- 移除 list 源码、头文件及测试用例 - 将 demo 及测试迁移至 arraylist - 在 arraylist 中实现 slice 功能并支持负索引 - 修复 arraylist 负数索引计算逻辑 - 修复 darray 打印函数参数错误 - 优化 mempool 日志输出格式 BREAKING CHANGE: 移除 list 模块;arraylist::slice 返回值改为新列表实例
73 lines
1.3 KiB
C
73 lines
1.3 KiB
C
/**
|
|
* @file demo.c
|
|
* @author wenjf (Orig5826@163.com)
|
|
* @brief
|
|
* @version 0.1
|
|
* @date 2024-08-27
|
|
*
|
|
* @copyright Copyright (c) 2024
|
|
*
|
|
*/
|
|
#include "demo.h"
|
|
|
|
void print_num(const void* obj)
|
|
{
|
|
printf("(%2d ) ", *(int*)obj);
|
|
}
|
|
|
|
int compare_num(const void *obj, const void *obj2)
|
|
{
|
|
int num1 = *(int*)obj;
|
|
int num2 = *(int*)obj2;
|
|
if(num1 == num2)
|
|
{
|
|
return 0;
|
|
}
|
|
return num1 > num2 ? 1 : -1;
|
|
}
|
|
|
|
void print_struct(const void* obj)
|
|
{
|
|
struct _student* student = (struct _student*)obj;
|
|
printf("(%4d:%-8s) ", student->id, student->name);
|
|
}
|
|
|
|
int compare_struct(const void *obj, const void *obj2)
|
|
{
|
|
struct _student num1 = *(struct _student*)obj;
|
|
struct _student num2 = *(struct _student*)obj2;
|
|
if(num1.id == num2.id)
|
|
{
|
|
return 0;
|
|
}
|
|
return num1.id > num2.id ? 1 : -1;
|
|
}
|
|
|
|
void print_char(const void* obj)
|
|
{
|
|
printf("(%2c ) ", *(char*)obj);
|
|
}
|
|
|
|
void print_str(const void* obj)
|
|
{
|
|
printf("(%s ) ", (char*)obj);
|
|
}
|
|
|
|
int main()
|
|
{
|
|
printf("----- unicstl demo -----\n");
|
|
// while (1)
|
|
{
|
|
demo_queue();
|
|
demo_stack();
|
|
demo_arraylist();
|
|
demo_deque();
|
|
demo_tree();
|
|
demo_heap();
|
|
demo_graph();
|
|
}
|
|
|
|
printf("----- unicstl ok -----\n");
|
|
return 0;
|
|
}
|