Skip to content

Latest commit

History

544 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Build StatusCoverage Status

Container Category

  • Sequential Container
    • Vector --- The dynamically growable array
    • LinkedList --- The doubly linked list
  • Associative Container
    • TreeMap --- The ordered map to store key value pairs
    • HashMap --- The unordered map to store key value pairs
    • HashSet --- The unordered set to store unique elements
    • Trie --- The string dictionary
  • Simple Collection Container
    • Queue --- The FIFO queue
    • Stack --- The LIFO stack
    • PriorityQueue --- The queue to maintain priority ordering for elements

Installation

This section illustrates how to install LibCDS to your working directory.

First of all, we need to prepare the CMake build tool:

  • CMake - A cross platform build system.

For Ubuntu 12.04 and above, it should be easy:

$ sudo apt-get install -qq cmake

Now we can build the entire source tree under the package root folder:

$ ./clean.py --rebuild
$ cd build
$ cmake .. -DCMAKE_INSTALL_PREFIX=/path/to/your/destination
$ make
$ make install

Upon finishing, the public header should locate at:
/path/to/your/destination/include/
Plus, the shared library should locate at:
/path/to/your/destination/lib/

If you plan for debug build, you can specify the CMake argument list like this:

$ cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/path/to/your/destination

Usage

This chapter illustrates how to link and apply LibCDS in your project.

For header file, you just need to include the main header:

#include "cds.h"

Assume that you apply gcc for compilation, then you need the following options:

-I/path/to/your/destination/include/
-L/path/to/your/destination/lib/
-lcds

Now you successfully link LibCDS with your project! But wait, to run your project, you need to tell the dynamic linker how to find LibCDS:

LD_LIBRARY_PATH=/path/to/your/destination/lib/

For detailed API usage, you can refer to the manual or check the demo programs.

Benchmark

Thanks for the HashMap benchmark with various key-value pair manipulations provided by kbench. The results are compared with the other 49 similar C data structure libraries.

  • Criteria - C style string as hash key
  • Platform - Linux nuc 3.2.0-4-amd64 #1 SMP Debian 3.2.81-1 x86_64 GNU/Linux
  • Date - Tue Oct 25 13:25:20 CEST 2016
  • Result sorted by CPU time
RankImplementationCPU (secs)Memory (Mb)#Notes
1rigtorp-hashmap0.760347.100625792
2rdestl0.850290.004625792
3ulib1.010240.724625792
4libevent1.110504.988625792
5khash1.140240.716625792
6ccan1.210227.240625792
7hashit-overflow1.290415.924636452Bug here!
8hashit-open1.300346.448625792
9mct-closed1.380339.140625792
10amtl1.410332.428625792
11sys-apr1.410256.584625792**
12sys-glib1.440228.968625792**
13oddou-hashmap1.460299.112625792
14google-dense1.470380.128625792**
15gcc-libiberty1.500240.180625792
16uthash1.540618.028625792
17tommyds-fixed1.570944.988625792
18python1.610264.492625792
19Qt-hash1.700255.456625792**
20cfu1.710272.376625792
21ghthash1.720362.476625792
22tommyds-dynamic1.760903.452625792
23generic-c-hashmap1.770502.416698396Bug here!
24hashit-chain1.830300.464625792
25CDS1.870252.236625792
26tommyds-linear1.900889.244625792
27eastl1.910263.584625792
28c-hashtable1.940257.360625792
29sys-tcl1.960256.976625792**
30apr1.970253.012625792
31c-algoritms2.000266.996625792
32sys-boost2.080263.516625792**
33sys-python2.160834.312625792**
34redis2.280253.212625792
35htable2.380541.268625792
36gcc-unordered_map2.550263.592625792**
37ruby-st2.950255.504625792
38sys-judy3.040259.372625792**
39mct-linked3.110363.708625792
40sglib3.220450.572625792
41sys-perl3.300301.240625792**
42stb3.390282.116625792
43st3.530245.784625792
44google-sparse4.430251.376625792**
45sys-LuaHashMap6.110354.948625792**
46google-c-sparse6.140244.408625792
47google-c-dense6.480244.408625792
48gcc-map7.730264.996625792**
49Qt-map8.560266.776625792**
50lua-table102.350264.744625792
  • Result sorted by memory usage
RankImplementationCPU (secs)Memory (Mb)#Notes
1ccan1.21227.24625792
2sys-glib1.44228.968625792**
3gcc-libiberty1.5240.18625792
4khash1.14240.716625792
5ulib1.01240.724625792
6google-c-sparse6.14244.408625792
7google-c-dense6.48244.408625792
8st3.53245.784625792
9google-sparse4.43251.376625792**
10CDS1.87252.236625792
11apr1.97253.012625792
12redis2.28253.212625792
13Qt-hash1.7255.456625792**
14ruby-st2.95255.504625792
15sys-apr1.41256.584625792**
16sys-tcl1.96256.976625792**
17c-hashtable1.94257.36625792
18sys-judy3.04259.372625792**
19sys-boost2.08263.516625792**
20eastl1.91263.584625792
21gcc-unordered_map2.55263.592625792**
22python1.61264.492625792
23lua-table102.35264.744625792
24gcc-map7.73264.996625792**
25Qt-map8.56266.776625792**
26c-algoritms2266.996625792
27cfu1.71272.376625792
28stb3.39282.116625792
29rdestl0.85290.004625792
30oddou-hashmap1.46299.112625792
31hashit-chain1.83300.464625792
32sys-perl3.3301.24625792**
33amtl1.41332.428625792
34mct-closed1.38339.14625792
35hashit-open1.3346.448625792
36rigtorp-hashmap0.76347.1625792
37sys-LuaHashMap6.11354.948625792**
38ghthash1.72362.476625792
39mct-linked3.11363.708625792
40google-dense1.47380.128625792**
41hashit-overflow1.29415.924636452Bug here!
42sglib3.22450.572625792
43generic-c-hashmap1.77502.416698396Bug here!
44libevent1.11504.988625792
45htable2.38541.268625792
46uthash1.54618.028625792
47sys-python2.16834.312625792**
48tommyds-linear1.9889.244625792
49tommyds-dynamic1.76903.452625792
50tommyds-fixed1.57944.988625792

Contact

Please contact me via the mail andy.zsshen@gmail.com.

About

A fast and memory efficient C library to manipulate sequential containers, associative structures, and advanced string processing, such as tree map, hash map, and trie.

Topics

Resources

Stars

46 stars

Watchers

5 watching

Forks

Releases

Packages

Contributors

Languages