Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DSA Library

DSA Library offers a collection of common Data Structures & Algorithms in C, along with multiple utilities.

Usage

The library includes the dsa's specified in dsa_list file, listing paths to dsa's headers with striped include/dsa/ and .h from path to dsa header, as in:

include/dsa/categories/*/header.h
data_structures/vector
sorting/quicksort

If dsa_list is not created all dsa's are included into the library.

To install the library do:

make install

To compile the library into build/libdsa.a do:

make lib

Declaration Interface

The interface for algorithms consists of declarations of Algorithm functions prefixed by dsa_ namespace.

Unless the opposite is specified (ex: array), the interface for data structures assumes that struct fields are never directly accessed regardless of them being hidden or not, declarations are prefixed by the data structure name.

Common types are found in include/types which have no namespace but are intended to avoid collisions, declarations in include/utils have static linkage, although users can include them for extra utilities, but they have no namespace.

/* algorithm base interface */
type dsa_algorithm(/*args...*/);

/* data structure base interface */
struct data_struct{
    /*fields...*/

    // if data_struct contains allocator
    const struct allocator *const alloc;
};

// null constant for data_struct
// NULL constant for data_struct
const struct data_struct NULL_DATA_STRUCT {nulled_fields...}

// if data_struct contains allocator, default to stdlib_allocator
struct data_struct data_struct_new(/*fields...*/);
// if data_struct contains allocator, creates it with given allocator
struct data_struct data_struct_new_with_alloc(/*fields...*/, const struct* allocator);
void data_struct_free(struct data_struct*);

bool data_struct_is_null(const struct data_struct*);

type data_struct_function(struct data_struct*, /*args...*/);

Testing

The project uses criterion testing framework, check their corresponding installation. Each dsa declaration include/category/dsa is accompanied by a corresponding set of unit tests located in tests/category/dsa directory.

To compile and run the tests do:

make test

# check criterion docs for testing options
make run-test ARGS='args...'

Contributing

Contributions are welcome! If you'd like to contribute to this repository, please follow the guide on contributing.

License

DSA library source code is available under the MIT License.

About

data structures and algorithms in C

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages