Skip to content

gundermanc/c-datastructs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C-Datastructs Library
(C) 2013-2015 Christian Gunderman

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

Contact Email: gundermanc@gmail.com


INTRODUCTION:
This package compiles to a C static library containing a few common data
structures, including a Stack, a tail cached Linked List, a dynamically
expanding string buffer, and a dynamically resizing HashTable.

**UPDATES**:
Hashtable is now tested to working without memory errors and I am 99% sure
that it has sound logic. In addition, I have added the HashSet datastructure.

DATASTRUCTURES:
ht.c  : Dynamically expanding C hashtable.
ll.c  : Tail Cached Linked list. Supports iterating and appending.
stk.c : Array stack. Supports peek and pop.
sb.c  : Dynamically expanding String "rope" buffer.
set.c : HashSet, built on top of hashtable.

All of these data structures can store the same common type: DSValue,
a union defined in include/build_config.h. By commenting out preprocessor
definitions, a developer can define how large DSValue will be, and what
kind of primitive data types can be stored in it. Tweak this value to your
heart's content to optimize these data structures for your particular
application.

BUILDING:
This build requires GCC and GNU make. Run 'make' or 'make library' to
build the static library which is out put to the main directory and is
named lib.a. For your convenience, a test_app.c file is included as well
which can be used to test the structures and get your bearings. This can
be build with 'make testapp'.
Library is all implemented in C89 code, and should be mostly portable.

DOCUMENTATION:
I am terribly lazy, so most documentation is in the form of comments in
the C files. Most of it is pretty self explanatory. Each C file contains
one data structure. See the C files for usage information.

To use any of the libraries, import their headers from the include directory
and link to the static library. You should then be able to create any of the
structures using **_new() function, where ** is the file name of the structure.

For additional operations, see the comments in the source files. They are
well commented and reable. :)

BUGS:
Most of the code is fairly mature and bug free. The exception to this is the
HashSet (set.c) which was just added. It is built on top of the hashtable,
however, which is pretty stable. Set has no known bugs, but some may exist.

MEMORY ERRORS:
No known errors. Checked with Valgrind.

About

Portable C Datastructures: LinkedList, HashTable, Stack/ArrayList, and StringBuffer with Union

Resources

License

Stars

Watchers

Forks

Packages

No packages published