GithubHelp home page GithubHelp logo

fragglet / c-algorithms Goto Github PK

View Code? Open in Web Editor NEW
3.2K 189.0 718.0 583 KB

A library of common data structures and algorithms written in C.

Home Page: https://fragglet.github.io/c-algorithms/

License: ISC License

Shell 0.39% C++ 1.13% C 96.71% Makefile 0.64% M4 0.47% Ruby 0.66%
algorithm data-structures c library isc

c-algorithms's Introduction

C Algorithms

The C programming language includes a very limited standard library in
comparison to other modern programming languages.  This is a collection of
common Computer Science algorithms which may be used in C projects.

The code is licensed under the ISC license (a simplified version of the BSD
license that is functionally identical).  As such, it may legitimately be
reused in any project, whether Proprietary or Open Source.

c-algorithms's People

Contributors

fragglet avatar losintikfos avatar thestefan avatar waldyrious avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

c-algorithms's Issues

regarding the missing rb_tree_subtree_height function in the rb_tree.c file

As addressed earlier also, the implementation of rb_tree_subtree_height function is missing in the file rb_tree.c which is specified there in the header file.
I have implemented and coded that function, so can you allow me to make a pull request for the same, so that you cam look at it, in order to resolve the issue?

Prototype for AVLTreeCompareFunc is incorrect, causing confusion

At line 119 of https://github.com/fragglet/c-algorithms/blob/master/src/avl-tree.h, there is a function pointer for AVLTreeCompareFunc declared.

The declaration is:

typedef int (*AVLTreeCompareFunc)(AVLTreeValue value1, AVLTreeValue value2);

But the documentation (and code) shows that this function is for comparing the keys of two nodes in the tree, so the declaration should actually be:

typedef int (*AVLTreeCompareFunc)(AVLTreeKey key1, AVLTreeKey key2);

As both AVLTreeKey and AVLTreeValue are themselves typedefed as **void ***, it doesn’t actually make any difference to the function operation, but it makes the prototype confusing.

c-algorithms code quality

looking for c data structures and algorithms as my c tool kit, the recent release of c-algorithms is 8 years ago, is it actively maintained and 'production ready'? does it go through lots of test cases and field use, or at this point it's more of a reference implementation for others to learn how to do data structure and algorithms coding in C?

Cannot distinguish between no-op insert and memory error

I preface that I'm quite new to C so this may be completely off. However, in:

c-algorithms/src/set.c

Lines 256 to 275 in 5b0555f

if (set->equal_func(data, rover->data) != 0) {
/* This data is already in the set */
return 0;
}
rover = rover->next;
}
/* Not in the set. We must add a new entry. */
/* Make a new entry for this data */
newentry = (SetEntry *) malloc(sizeof(SetEntry));
if (newentry == NULL) {
return 0;
}

the 0 return value is used both for an operation that does not change the state of a set (because the value already exists), which may or may not be an issue, and a memory error, which is more likely to be an issue, and of a different type.

Shall the former not use a kind of custom error code, and the latter an ENOMEM according to https://www.gnu.org/software/libc/manual/html_node/Error-Codes.html ?

Thanks.

Do we need to call `arraylist_new` again in a cleared array list when we want to put items.

Hi,
I am using the arraylist library in cython hobby project. So far so good. My project is a win32 api ui library. I have list box control . It has an items property which is internally your arraylist. I need to implement an option to clear all the items from list box. It's okay, because I can call the arraylist_clear function. But after clearing the arraylist, if my user wants to put another set of items what should I do ? Should I call arraylist_free & arraylist_new ?
Thanks in advance.

Build on Mac

On Mac how can I build the code, I found autogen.sh can't run on Mac.

Cannot modify data of list entry. Was this meant to be this way?

There are functions to get the value of a ListEntry, but there are no functions to write to the data of a ListEntry.

The underlying struct is defined in the list.c file so it is not possible to access it directly.

I am willing to implement the feature if needed.

Might it be a good idea to add splint annotations to the source code?

Splint is a static code analysis tool, splint works with annotations. These annotations help you to do two things, it defines how functions behaves and which assumptions on input are made. Using splint memory leaks might be detected.

The only downside is that it is a lot of work to go through all code. But maybe it is possible to implement it data structure by data structure in a separate branch untill all structures are done.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.