Library of Simple C Utilities
C Makefile
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
.travis.yml
LICENSE
Makefile
NOTICE
README.md
TODO.md

README.md

Build Status

libscu

Library of Simple C Utilities. Contains implementations for hash maps, sets, linked list, stacks, queues, pseudo random number generators, and hashes.

Table of Contents

  1. Interfaces
  1. Using LibSCU
  1. Dependencies
  2. Installation
  3. Testing
  4. License

Interfaces

#include <scu.h>

Include the scu.h file to use the following interfaces.

List

Interface
Example usage

List data structure. Can insert arbitrary key and value types (structs, ints, strings, etc).

Map

Interface
Example usage

Map data structure. Can insert arbitrary key and value types (structs, ints, strings, etc).

Set

Interface
Example usage

Set data structure. Can insert arbitrary value types (structs, ints, strings, etc).

Heap

Interface
Example usage

Heap data structure. Can insert arbitrary value types (structs, ints, strings, etc).

Stack

Interface
Example usage

Stack data structure. Can insert arbitrary value types (structs, ints, strings, etc).

Queue

Interface
Example usage

Queue data structure. Can insert arbitrary value types (structs, ints, strings, etc).

Pseudo Ranom Number Generator

Interface
Example usage

Pseudo Ranom Number Generator (prng) provides random uint8_t, uint_16_t, uint32_t and uint64_t values. The values are generated by xoroshiro128+.

Hash

Interface
Example usage

Hash data into a uint32_t or uint64_t value. Uses fasthash. Also supports seeded hash, for generating multiple hash values from a single object.

HyperLogLog

Interface
Example usage

HyperLogLog is a distinct value estimator. For example, it can estimate distinct values in the ~17 trillion range with a 2.25% standard error, using only 2kb of memory.

Math

Interface
Example usage

Provides limited math functions. Fast estimate of log base 2, 10, and e. Count leading or trailing zeros.

Using LibSCU

You can link with the libSCU shared object, statically compile with the libSCU static object, or rip out the .h and .c files that you want to use in your own project.

Here is a sample program using libSCU:

#include <string.h>
#include <stdio.h>
#include <inttypes.h>
#include <scu.h>

int main() {
    char s[] = "Hash this string!";
    uint32_t h = SCU_Hash32(s, strlen(s));
    fprintf(stdout, "Hash of %s is %" PRIu32 "\n", s, h);
    return EXIT_SUCCESS;
}

Shared library

Here is how you can compile with the shared library:

gcc -lscul main.c -o main
./main

Static library

Here is how you can compile with the static library:

gcc main.c /usr/local/lib/libscul.a -o main
./main

This will statically compile only libSCU into your executable. You can also do full static compilation, but that may result in a larger executable:

gcc -static main.c -lscul -o main
./main

Dependencies

LibSCU has no dependencies.

Installation

First, make sure that /usr/local/lib is on your linker path. Edit /etc/ld.so.conf and add the line /usr/local/lib if it doesn't exist.

Next checkout libSCU, build, and install:

git clone git@github.com:joshwalters/scul.git
cd scul
make
sudo make install

This will build dynamic and static libraries, and install them in /usr/local/lib. The header files will be installed in /usr/local/include.

You can now follow the steps in using libSCU.

Testing

Build libSCU and run the test suite:

make test

License

LibSCU is released under the MIT license.