c array implementation

Our CKit library is a collection of high performance, elegant, and logical utilities for creating parsers, programming languages, and much more. Currently the star of the CKit Library is the Array implementation which allows you to create one or more name-spaced array structs using the CKIT_ARRAY macro.

Array Functions

CKit is packed with several high performance, flexible array functions, which are listed below, after initializing an array with the following macro which prefixes with Array with values of the type char *.

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);

Benchmarks

Below are benchmarks for CKit's Array implementation (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