高效的 C 語言列表實現 SimCList 1.6 發布
SimCList 是一個用來處理列表(List)的的高效C庫。內置很多基于列表的算法,例如排序、查找、隨機處理等等。
SimCList 1.6 提供了 Windows 下的兼容性,修復了一些函數的bug和文檔的完善,修改了 list dump 的格式。
下面是一段使用SimCList的示例代碼:
#include <stdio.h> #include <simclist.h> /* use the SimCList library */ int main() { list_t mylist; /* declare a list */ int userval; list_init(& mylist); /* initialize the list */ printf("Insert your number: "); scanf("%d", & userval); list_append(& mylist, & userval); /* add an element to the list */ printf("The list now holds %u elements.\n", \ list_size(& mylist)); /* get the size of the list */ printf("Your number was: %d\n", \ * (int*)list_get_at(& mylist, 0)); /* extract the first element of the list */ list_destroy(&mylist); return 0; }項目地址: http://mij.oltrelinux.com/devel/simclist/
The SimCList API
SimCList API is good because:
- it is simple, yet powerful
- it makes elegant and consistent use of information hiding
- it abstracts the actual data type to store
- it is fairly
total
The library itself is very performant and makes a good compromise between performance in terms of time and space:
- insertion is O(n) [typically n/8]
- extraction and deletion are O(n) [typically n/8]
- iteration is O(1)
- sorting is always O(n logn), without worst case
本文由用戶 openkk 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!