This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 2432ff2cee1672f4427d289316f0fb35d0b9c239
tree f143299adf7b619a7fd1d082f053afeb54249583
parent 07711b54d84443427b94f7eff4fc076e43aee9c8
tree f143299adf7b619a7fd1d082f053afeb54249583
parent 07711b54d84443427b94f7eff4fc076e43aee9c8
ckit /
| name | age | message | |
|---|---|---|---|
| |
.gitignore | ||
| |
History | ||
| |
Makefile | ||
| |
Readme | ||
| |
benchmarks/ | ||
| |
bin/ | ||
| |
build/ | ||
| |
examples/ | ||
| |
spec/ | ||
| |
src/ |
Readme
= CKit
Suite of C libraries for building programs or languages.
== Todo
* Shrink / free when shrinking
* Adjust readme with changes to protos
* Array_diff
* Array_compact
* Array_flatten
* ...
== Libraries
CKit includes several optional libraries listed below which you may
include or copy / paste into your program (copyright must remain intact).
Many of the libraries work stand-alone, however macros available in ckit.h
allow you to customize various aspects of CKit.
Please contribute! lets make some solid C utilties :)
=== array.h
Initialize an array using CKIT_ARRAY(NAME, DATA_TYPE) like below, or use
CKIT_ARRAY_INIT(NAME, DATA_TYPE, FREE_FUNCTION) for freeing structs etc.
CKIT_ARRAY(Array, char *);
Array *
Array_new();
Array *
Array_push(Array *self, char *val);
Array *
Array_slice(Array *self, int beg, int len);
Array *
Array_from(Array *self, int i);
Array *
Array_to(Array *self, int i);
Array *
Array_last_n(Array *self, int n);
Array *
Array_select(Array *self, int (* callback)());
Array *
Array_map(Array *self, void *(* callback)());
char *
Array_find(Array *self, int (* callback)());
int
Array_any(Array *self, int (* callback)());
char *
Array_last(Array *self);
char *
Array_pop(Array *self);
Array *
Array_merge(Array *self, Array *other);
Array *
Array_unshift(Array *self, char *val);
char *
Array_delete_at(Array *self, int i);
Array *
Array_unique(Array *self, int (* callback)());
Array *
Array_union(Array *self, Array *other, int (* callback)());
char *
Array_shift(Array *self);
void
Array_destroy(Array *self);
=== file.h
int
file_size(const char *path);
char *
file_read(const char *path);
== Benchmarks
Below are the benchmark results (so far):
Running 200 times...
Array
new() : 0.00002
push() : 0.00002
slice(0, 1) : 0.00004
slice(5, 100) : 0.00091
slice(0, -1) : 0.00137
slice(-100, -1) : 0.00088
last_n(3) : 0.00006
to(3) : 0.00006
from(3) : 0.00143
select(even) : 0.00104
map(even) : 0.00132
find(above_500) : 0.00030
any(above_500) : 0.00030
last() : 0.00000
pop() : 0.00000
unshift() : 0.00082
shift() : 0.00011
merge() : 0.00008
delete_at() : 0.00099
unique() : 0.00973
union() : 0.00027
sort() : 0.00002
Avg : 0.00091
file
size(); 55 bytes : 0.00539
read(); 55 bytes : 0.00883
Avg : 0.00713
== Conventions
Functions that accept a struct as 'self' are
capitalized (Array_push, etc), where as utilities
which accept arbitrary values are lowercase (file_read("some/path")).
== License
(The MIT License)
Copyright (c) 2008 - 2009 TJ Holowaychuk <tj@vision-media.ca>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.







