summaryrefslogtreecommitdiff
path: root/src/data
diff options
context:
space:
mode:
Diffstat (limited to 'src/data')
-rw-r--r--src/data/array.c115
-rw-r--r--src/data/array.h24
-rw-r--r--src/data/dat.c75
-rw-r--r--src/data/dat.h16
-rw-r--r--src/data/hash.c86
-rw-r--r--src/data/hash.h32
-rw-r--r--src/data/list.c117
-rw-r--r--src/data/list.h49
-rw-r--r--src/data/map.c74
-rw-r--r--src/data/map.h28
-rw-r--r--src/data/queue.c16
-rw-r--r--src/data/queue.h16
-rw-r--r--src/data/stack.c53
-rw-r--r--src/data/stack.h23
-rw-r--r--src/data/tree.c67
-rw-r--r--src/data/tree.h18
-rw-r--r--src/data/tupel.c16
-rw-r--r--src/data/tupel.h16
-rw-r--r--src/data/types.h16
19 files changed, 332 insertions, 525 deletions
diff --git a/src/data/array.c b/src/data/array.c
index f50e998..2ae4ece 100644
--- a/src/data/array.c
+++ b/src/data/array.c
@@ -1,12 +1,12 @@
/*:*
*: File: ./src/data/array.c
- *: A simple Fype interpreter
+ *: A simple interpreter
*:
- *: WWW: http://fype.buetow.org
- *: AUTHOR: http://paul.buetow.org
- *: E-Mail: fype at dev.buetow.org
+ *: WWW : http://fype.buetow.org
+ *: E-Mail : fype@dev.buetow.org
*:
- *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *: Copyright (c) 2005 2006 2007 2008, Dipl.-Inf. (FH) Paul C. Buetow
+ *: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
*: fication, are permitted provided that the following conditions are met:
@@ -15,14 +15,14 @@
*: * Redistributions in binary form must reproduce the above copyright
*: notice, this list of conditions and the following disclaimer in the
*: documentation and/or other materials provided with the distribution.
- *: * Neither the name of buetow.org nor the names of its contributors may
+ *: * Neither the name of P. B. Labs nor the names of its contributors may
*: be used to endorse or promote products derived from this software
*: without specific prior written permission.
*:
- *: THIS SOFTWARE IS PROVIDED BY PAUL C. BUETOW AS IS'' AND ANY EXPRESS OR
+ *: THIS SOFTWARE IS PROVIDED BY Paul Buetow AS IS'' AND ANY EXPRESS OR
*: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
*: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- *: DISCLAIMED. IN NO EVENT SHALL PAUL C. BUETOW BE LIABLE FOR ANY DIRECT,
+ *: DISCLAIMED. IN NO EVENT SHALL Paul Buetow BE LIABLE FOR ANY DIRECT,
*: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
*: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
*: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -40,32 +40,10 @@ array_new() {
p_array->i_size = 0;
p_array->pp_ae = NULL;
- array_set_used(p_array, 0);
- return (p_array);
+ return p_array;
}
-Array*
-array_new_size(int i_size) {
- Array *p_array = array_new();
-
- array_resize(p_array, i_size);
-
- return (p_array);
-}
-
-void
-_unshift_cb(void *p_array, void *p_void) {
- array_unshift(p_array, p_void);
-}
-
-Array*
-array_new_copy(Array *p_array) {
- Array *p_array_cpy = array_new_size(array_get_size(p_array));
- array_iterate2(p_array, _unshift_cb, p_array_cpy);
-
- return (p_array_cpy);
-}
void
array_delete(Array *p_array) {
@@ -83,23 +61,6 @@ array_delete(Array *p_array) {
}
void
-array_delete_iterate(Array *p_array, void (*func)(void *)) {
- if (!p_array)
- return;
-
- array_iterate(p_array, func);
-
- if (p_array->i_size)
- for (int i = p_array->i_size - 1; i >= 0; --i)
- arrayelement_delete(p_array->pp_ae[i]);
-
- if (p_array->pp_ae)
- free(p_array->pp_ae);
-
- free(p_array);
-}
-
-void
array_set(Array *p_array, int i_index, void *p_val) {
if (p_array->i_size > i_index) {
p_array->pp_ae[i_index]->p_val = p_val;
@@ -108,18 +69,9 @@ array_set(Array *p_array, int i_index, void *p_val) {
array_resize(p_array, i_index + 1);
p_array->pp_ae[i_index]->p_val = p_val;
}
-
- if (p_array->i_used < i_index)
- array_set_used(p_array, i_index);
}
void
-array_set_used(Array *p_array, int i_used) {
- p_array->i_used = i_used;
-}
-
-
-void
array_insert(Array *p_array, int i_index, void *p_val) {
if (p_array->i_size <= i_index) {
array_set(p_array, i_index, p_val);
@@ -135,15 +87,12 @@ array_insert(Array *p_array, int i_index, void *p_val) {
p_array->pp_ae[i] = p_ae;
p_ae->p_val = p_val;
}
-
- if (p_array->i_used < i_index)
- array_set_used(p_array, i_index);
}
void*
array_remove(Array *p_array, int i_index) {
if (p_array->i_size <= i_index)
- return (NULL);
+ return NULL;
ArrayElement *p_ae = p_array->pp_ae[i_index];
void *p_ret = p_ae->p_val;
@@ -155,7 +104,8 @@ array_remove(Array *p_array, int i_index) {
p_array->pp_ae[i-1] = p_ae;
array_resize(p_array, p_array->i_size - 1);
- return (p_ret);
+
+ return p_ret;
}
void
@@ -192,24 +142,22 @@ array_resize(Array *p_array, int i_size) {
p_array->pp_ae[i] = arrayelement_new(NULL);
p_array->i_size = i_size;
- if (p_array->i_used > i_size)
- array_set_used(p_array, i_size);
}
void*
array_get(Array *p_array, int i_index) {
if (p_array->i_size > i_index)
- return (p_array->pp_ae[i_index]->p_val);
+ return p_array->pp_ae[i_index]->p_val;
- return (NULL);
+ return NULL;
}
_Bool
array_defined(Array *p_array, int i_index) {
if (i_index >= p_array->i_size)
- return (false);
+ return false;
- return (p_array->pp_ae[i_index]->p_val != NULL);
+ return p_array->pp_ae[i_index]->p_val != NULL;
}
void
@@ -235,9 +183,8 @@ array_splice(Array *p_array, int i_index, Array *p_array2) {
void
array_unshift(Array *p_array, void *p_void) {
- int i_used = array_get_used(p_array);
- array_set(p_array, i_used, p_void);
- array_set_used(p_array, 1+i_used);
+ int i_size = array_get_size(p_array);
+ array_set(p_array, i_size, p_void);
}
void
@@ -252,18 +199,11 @@ array_push(Array *p_array, void *p_void) {
}
void
-array_append(Array *p_array, Array *p_array_append) {
- int i_size = array_get_size(p_array) + array_get_size(p_array_append);
- array_resize(p_array, i_size);
- array_iterate2(p_array_append, _unshift_cb, p_array);
-}
-
-void
array_iterate(Array *p_array, void (*func)(void *)) {
if (!p_array)
return;
- for (int i = 0; i < array_get_used(p_array); ++i)
+ for (int i = 0; i < array_get_size(p_array); ++i)
(*func) (array_get(p_array, i));
}
@@ -272,7 +212,7 @@ array_iterate2(Array *p_array, void (*func)(void *, void *), void *p_void) {
if (!p_array)
return;
- for (int i = 0; i < array_get_used(p_array); ++i)
+ for (int i = 0; i < array_get_size(p_array); ++i)
(*func) (array_get(p_array, i), p_void);
}
@@ -282,7 +222,7 @@ arrayelement_new(void *p_val) {
p_ae->p_val = p_val;
- return (p_ae);
+ return p_ae;
}
void
@@ -296,13 +236,13 @@ arrayelement_delete(ArrayElement *p_ae) {
ArrayIterator*
arrayiterator_new(Array *p_array) {
if (!p_array)
- return (NULL);
+ return NULL;
ArrayIterator *p_arrayiterator = malloc(sizeof(ArrayIterator));
p_arrayiterator->p_array = p_array;
p_arrayiterator->i_cur_pos = 0;
- return (p_arrayiterator);
+ return p_arrayiterator;
}
void
@@ -313,15 +253,14 @@ arrayiterator_delete(ArrayIterator *p_arrayiterator) {
_Bool
arrayiterator_has_next(ArrayIterator *p_arrayiterator) {
- //printf("[%d]", p_arrayiterator->p_array->i_used);
- return (p_arrayiterator->i_cur_pos <
- array_get_used(p_arrayiterator->p_array));
+ return p_arrayiterator->i_cur_pos <
+ array_get_size(p_arrayiterator->p_array);
}
void*
arrayiterator_next(ArrayIterator *p_arrayiterator) {
if (!arrayiterator_has_next(p_arrayiterator))
- return (NULL);
+ return NULL;
- return (array_get(p_arrayiterator->p_array, p_arrayiterator->i_cur_pos++));
+ return array_get(p_arrayiterator->p_array, p_arrayiterator->i_cur_pos++);
}
diff --git a/src/data/array.h b/src/data/array.h
index 6800061..b343521 100644
--- a/src/data/array.h
+++ b/src/data/array.h
@@ -1,12 +1,12 @@
/*:*
*: File: ./src/data/array.h
- *: A simple Fype interpreter
+ *: A simple interpreter
*:
- *: WWW: http://fype.buetow.org
- *: AUTHOR: http://paul.buetow.org
- *: E-Mail: fype at dev.buetow.org
+ *: WWW : http://fype.buetow.org
+ *: E-Mail : fype@dev.buetow.org
*:
- *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *: Copyright (c) 2005 2006 2007 2008, Dipl.-Inf. (FH) Paul C. Buetow
+ *: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
*: fication, are permitted provided that the following conditions are met:
@@ -15,14 +15,14 @@
*: * Redistributions in binary form must reproduce the above copyright
*: notice, this list of conditions and the following disclaimer in the
*: documentation and/or other materials provided with the distribution.
- *: * Neither the name of buetow.org nor the names of its contributors may
+ *: * Neither the name of P. B. Labs nor the names of its contributors may
*: be used to endorse or promote products derived from this software
*: without specific prior written permission.
*:
- *: THIS SOFTWARE IS PROVIDED BY PAUL C. BUETOW AS IS'' AND ANY EXPRESS OR
+ *: THIS SOFTWARE IS PROVIDED BY Paul Buetow AS IS'' AND ANY EXPRESS OR
*: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
*: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- *: DISCLAIMED. IN NO EVENT SHALL PAUL C. BUETOW BE LIABLE FOR ANY DIRECT,
+ *: DISCLAIMED. IN NO EVENT SHALL Paul Buetow BE LIABLE FOR ANY DIRECT,
*: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
*: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
*: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -41,8 +41,6 @@
#include "../defines.h"
#define array_get_size(a) a->i_size
-#define array_get_used(a) a->i_used
-#define array_get_ind(a) (a->i_used - 1)
#define array_empty(a) a->i_size == 0
#define array_clear(a) array_resize(a, 0)
#define array_get_first(a) array_get(a, 0)
@@ -54,7 +52,6 @@ typedef struct {
typedef struct {
ArrayElement **pp_ae;
- int i_used;
int i_size;
} Array;
@@ -64,10 +61,7 @@ typedef struct {
} ArrayIterator;
Array *array_new();
-Array *array_new_size(int i_size);
-Array *array_new_copy(Array *p_array);
void array_delete(Array *p_array);
-void array_delete_iterate(Array *p_array, void (*func)(void*));
void array_set(Array *p_array, int i_index, void *p_val);
void array_insert(Array *p_array, int i_index, void *p_val);
void *array_remove(Array *p_array, int i_index);
@@ -77,12 +71,10 @@ _Bool array_defined(Array *p_array, int i_index);
void array_print_int(Array *p_array);
void array_splice(Array *p_array, int i_index, Array *p_array2);
void array_push(Array *p_array, void *p_void);
-void array_append(Array *p_array, Array *p_array_append);
void array_unshift(Array *p_array, void *p_void);
void array_iterate(Array *p_array, void (*func)(void *));
void array_iterate2(Array *p_array, void (*func)(void *, void *),
void *p_void);
-void array_set_used(Array *p_array, int i_used);
ArrayElement *arrayelement_new(void *p_val);
void arrayelement_delete(ArrayElement *p_ae);
diff --git a/src/data/dat.c b/src/data/dat.c
index b448cdc..6d4f10d 100644
--- a/src/data/dat.c
+++ b/src/data/dat.c
@@ -1,12 +1,12 @@
/*:*
*: File: ./src/data/dat.c
- *: A simple Fype interpreter
+ *: A simple interpreter
*:
- *: WWW: http://fype.buetow.org
- *: AUTHOR: http://paul.buetow.org
- *: E-Mail: fype at dev.buetow.org
+ *: WWW : http://fype.buetow.org
+ *: E-Mail : fype@dev.buetow.org
*:
- *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *: Copyright (c) 2005 2006 2007 2008, Dipl.-Inf. (FH) Paul C. Buetow
+ *: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
*: fication, are permitted provided that the following conditions are met:
@@ -15,14 +15,14 @@
*: * Redistributions in binary form must reproduce the above copyright
*: notice, this list of conditions and the following disclaimer in the
*: documentation and/or other materials provided with the distribution.
- *: * Neither the name of buetow.org nor the names of its contributors may
+ *: * Neither the name of P. B. Labs nor the names of its contributors may
*: be used to endorse or promote products derived from this software
*: without specific prior written permission.
*:
- *: THIS SOFTWARE IS PROVIDED BY PAUL C. BUETOW AS IS'' AND ANY EXPRESS OR
+ *: THIS SOFTWARE IS PROVIDED BY Paul Buetow AS IS'' AND ANY EXPRESS OR
*: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
*: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- *: DISCLAIMED. IN NO EVENT SHALL PAUL C. BUETOW BE LIABLE FOR ANY DIRECT,
+ *: DISCLAIMED. IN NO EVENT SHALL Paul Buetow BE LIABLE FOR ANY DIRECT,
*: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
*: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
*: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -35,7 +35,6 @@
#include "dat.h"
#include <stdlib.h>
-#include "../defines.h"
Dat*
dat_new() {
@@ -45,12 +44,12 @@ dat_new() {
p_dat->p_last = 0;
p_dat->i_size = 0;
- return (p_dat);
+ return p_dat;
}
DatElem*
datelem_new() {
- return (datelem_new_t(TYPE_UNKNOWN));
+ return datelem_new_t(TYPE_UNKNOWN);
}
DatElem*
@@ -61,15 +60,15 @@ datelem_new_t(TYPE type) {
p_elem->p_val = 0;
p_elem->type = type;
- return (p_elem);
+ return p_elem;
}
_Bool
dat_empty(Dat *p_dat) {
if (p_dat == NULL)
- return (false);
+ return 0;
- return (p_dat->i_size == 0);
+ return p_dat->i_size == 0;
}
void
@@ -93,13 +92,13 @@ dat_push_t(Dat *p_dat, void *p_val, TYPE type) {
void*
dat_pop(Dat *p_dat) {
TYPE type;
- return (dat_pop_t(p_dat, &type));
+ return dat_pop_t(p_dat, &type);
}
void*
dat_pop_t(Dat *p_dat, TYPE *p_type) {
if (dat_empty(p_dat))
- return (NULL);
+ return 0;
DatElem *p_elem = p_dat->p_first;
p_dat->p_first = p_elem->p_next;
@@ -109,7 +108,7 @@ dat_pop_t(Dat *p_dat, TYPE *p_type) {
void *p_ret = p_elem->p_val;
*p_type = p_elem->type;
free(p_elem);
- return (p_ret);
+ return p_ret;
}
void
@@ -125,7 +124,7 @@ dat_delete(Dat *p_dat) {
unsigned
dat_size(Dat *p_dat) {
- return (p_dat->i_size);
+ return p_dat->i_size;
}
void
@@ -164,52 +163,52 @@ dat_iterate_tl(Dat *p_dat, void (*func)(void *, TYPE, _Bool)) {
void*
dat_first(Dat *p_dat) {
if (dat_empty(p_dat))
- return (NULL);
+ return NULL;
- return (p_dat->p_first->p_val);
+ return p_dat->p_first->p_val;
}
void*
dat_second(Dat *p_dat) {
- if (2 > dat_size(p_dat))
- return (NULL);
+ if ( 2 > dat_size(p_dat))
+ return NULL;
- return (p_dat->p_first->p_next->p_val);
+ return p_dat->p_first->p_next->p_val;
}
void*
dat_last(Dat *p_dat) {
if (dat_empty(p_dat))
- return (NULL);
+ return NULL;
- return (p_dat->p_last->p_val);
+ return p_dat->p_last->p_val;
}
void*
dat_first_t(Dat *p_dat, TYPE *p_type) {
if (dat_empty(p_dat))
- return (NULL);
+ return NULL;
*p_type = p_dat->p_first->type;
- return (p_dat->p_first->p_val);
+ return p_dat->p_first->p_val;
}
void*
dat_second_t(Dat *p_dat, TYPE *p_type) {
- if (2 > dat_size(p_dat))
- return (NULL);
+ if ( 2 > dat_size(p_dat))
+ return NULL;
*p_type = p_dat->p_first->p_next->type;
- return (p_dat->p_first->p_next->p_val);
+ return p_dat->p_first->p_next->p_val;
}
void*
dat_last_t(Dat *p_dat, TYPE *p_type) {
if (dat_empty(p_dat))
- return (NULL);
+ return NULL;
*p_type = p_dat->p_last->type;
- return (p_dat->p_last->p_val);
+ return p_dat->p_last->p_val;
}
DatIter*
@@ -222,7 +221,7 @@ datiter_new(Dat *p_dat) {
p_iter->i_left = dat_size(p_dat);
p_iter->p_dat = p_dat;
- return (p_iter);
+ return p_iter;
}
void
@@ -239,13 +238,13 @@ datiter_skip(DatIter *p_iter, unsigned i_num) {
void*
datiter_next(DatIter *p_iter) {
TYPE type;
- return (datiter_next_t(p_iter, &type));
+ return datiter_next_t(p_iter, &type);
}
void*
datiter_next_t(DatIter *p_iter, TYPE *p_type) {
if (p_iter->p_next == NULL)
- return (NULL);
+ return NULL;
void *p_ret = p_iter->p_next->p_val;
*p_type = p_iter->p_next->type;
@@ -253,16 +252,16 @@ datiter_next_t(DatIter *p_iter, TYPE *p_type) {
p_iter->p_next = p_iter->p_next->p_next;
--p_iter->i_left;
- return (p_ret);
+ return p_ret;
}
unsigned
datiter_left(DatIter *p_iter) {
- return (p_iter->i_left);
+ return p_iter->i_left;
}
Dat*
datiter_dat(DatIter *p_iter) {
- return (p_iter->p_dat);
+ return p_iter->p_dat;
}
diff --git a/src/data/dat.h b/src/data/dat.h
index dcc7928..83e24a6 100644
--- a/src/data/dat.h
+++ b/src/data/dat.h
@@ -1,12 +1,12 @@
/*:*
*: File: ./src/data/dat.h
- *: A simple Fype interpreter
+ *: A simple interpreter
*:
- *: WWW: http://fype.buetow.org
- *: AUTHOR: http://paul.buetow.org
- *: E-Mail: fype at dev.buetow.org
+ *: WWW : http://fype.buetow.org
+ *: E-Mail : fype@dev.buetow.org
*:
- *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *: Copyright (c) 2005 2006 2007 2008, Dipl.-Inf. (FH) Paul C. Buetow
+ *: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
*: fication, are permitted provided that the following conditions are met:
@@ -15,14 +15,14 @@
*: * Redistributions in binary form must reproduce the above copyright
*: notice, this list of conditions and the following disclaimer in the
*: documentation and/or other materials provided with the distribution.
- *: * Neither the name of buetow.org nor the names of its contributors may
+ *: * Neither the name of P. B. Labs nor the names of its contributors may
*: be used to endorse or promote products derived from this software
*: without specific prior written permission.
*:
- *: THIS SOFTWARE IS PROVIDED BY PAUL C. BUETOW AS IS'' AND ANY EXPRESS OR
+ *: THIS SOFTWARE IS PROVIDED BY Paul Buetow AS IS'' AND ANY EXPRESS OR
*: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
*: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- *: DISCLAIMED. IN NO EVENT SHALL PAUL C. BUETOW BE LIABLE FOR ANY DIRECT,
+ *: DISCLAIMED. IN NO EVENT SHALL Paul Buetow BE LIABLE FOR ANY DIRECT,
*: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
*: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
*: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
diff --git a/src/data/hash.c b/src/data/hash.c
index e196840..5555eb1 100644
--- a/src/data/hash.c
+++ b/src/data/hash.c
@@ -1,12 +1,12 @@
/*:*
*: File: ./src/data/hash.c
- *: A simple Fype interpreter
+ *: A simple interpreter
*:
- *: WWW: http://fype.buetow.org
- *: AUTHOR: http://paul.buetow.org
- *: E-Mail: fype at dev.buetow.org
+ *: WWW : http://fype.buetow.org
+ *: E-Mail : fype@dev.buetow.org
*:
- *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *: Copyright (c) 2005 2006 2007 2008, Dipl.-Inf. (FH) Paul C. Buetow
+ *: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
*: fication, are permitted provided that the following conditions are met:
@@ -15,14 +15,14 @@
*: * Redistributions in binary form must reproduce the above copyright
*: notice, this list of conditions and the following disclaimer in the
*: documentation and/or other materials provided with the distribution.
- *: * Neither the name of buetow.org nor the names of its contributors may
+ *: * Neither the name of P. B. Labs nor the names of its contributors may
*: be used to endorse or promote products derived from this software
*: without specific prior written permission.
*:
- *: THIS SOFTWARE IS PROVIDED BY PAUL C. BUETOW AS IS'' AND ANY EXPRESS OR
+ *: THIS SOFTWARE IS PROVIDED BY Paul Buetow AS IS'' AND ANY EXPRESS OR
*: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
*: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- *: DISCLAIMED. IN NO EVENT SHALL PAUL C. BUETOW BE LIABLE FOR ANY DIRECT,
+ *: DISCLAIMED. IN NO EVENT SHALL Paul Buetow BE LIABLE FOR ANY DIRECT,
*: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
*: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
*: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -50,7 +50,7 @@ hash_new(unsigned i_size) {
for (int i = 0; i < i_size; ++i)
p_hash->p_elems[i].flag = 'f';
- return (p_hash);
+ return p_hash;
}
void
@@ -68,10 +68,10 @@ hash_insert_ht(Hash *p_hash, char *c_key, void *p_val, TYPE type) {
if (p_hash->i_cur_size == p_hash->i_size)
hash_size(p_hash, p_hash->i_size *2);
- int i_addr = hash_getaddr(p_hash, c_key, FREE_ADDR);
+ int i_addr = hash_getaddr(p_hash, c_key, free_ADDR);
if (i_addr == RET_ERROR )
- return (RET_NO_SPACE);
+ return RET_NO_SPACE;
strncpy(p_hash->p_elems[i_addr].c_key, c_key, HASH_MKEYLEN);
@@ -80,12 +80,12 @@ hash_insert_ht(Hash *p_hash, char *c_key, void *p_val, TYPE type) {
p_hash->p_elems[i_addr].p_val = p_val;
p_hash->i_cur_size++;
- return (RET_OK);
+ return RET_OK;
}
RETCODE
hash_insert(Hash *p_hash, char *c_key, void *p_val) {
- return (hash_insert_ht(p_hash, c_key, p_val, TYPE_VOIDP));
+ return hash_insert_ht(p_hash, c_key, p_val, TYPE_VOIDP);
}
void*
@@ -96,20 +96,20 @@ hash_remove(Hash *p_hash, char *c_key) {
int i_addr = hash_getaddr(p_hash, c_key, OCC_ADDR);
if (i_addr == -1 )
- return (NULL);
+ return 0;
void *p_val = p_hash->p_elems[i_addr].p_val;
p_hash->p_elems[i_addr].flag = 'm';
p_hash->p_elems[i_addr].p_val = 0;
--p_hash->i_cur_size;
- return (p_val);
+ return p_val;
}
void*
hash_get_ht(Hash *p_hash, char *c_key, TYPE *p_type) {
int i_addr;
- return (hash_get_ht_addr(p_hash, c_key, p_type, &i_addr));
+ return hash_get_ht_addr(p_hash, c_key, p_type, &i_addr);
}
void*
@@ -117,16 +117,16 @@ hash_get_ht_addr(Hash *p_hash, char *c_key, TYPE *p_type, int *p_addr) {
int i_addr = *p_addr = hash_getaddr(p_hash, c_key, OCC_ADDR);
if (i_addr == -1 )
- return (NULL);
+ return 0;
*p_type = p_hash->p_elems[i_addr].type;
- return (p_hash->p_elems[i_addr].p_val);
+ return p_hash->p_elems[i_addr].p_val;
}
void*
hash_get(Hash *p_hash, char *c_key) {
TYPE type;
- return (hash_get_ht(p_hash, c_key, &type));
+ return hash_get_ht(p_hash, c_key, &type);
}
int
@@ -144,68 +144,67 @@ hash_getaddr(Hash *p_hash, char *c_key, HASH_OP OP) {
i_addr = (i_addr *p_hash->i_size + (int) c_key[i]) % p_hash->i_size;
switch (OP) {
- case FREE_ADDR:
+ case free_ADDR:
if (!hash_addrisfree(p_hash,i_addr))
- return (i_addr);
+ return i_addr;
break;
case OCC_ADDR:
if (!hash_addrisocc(p_hash,i_addr, c_key))
- return (i_addr);
+ return i_addr;
break;
default:
- return (RET_ERROR);
+ return RET_ERROR;
}
- return (hash_nextaddr(p_hash, p_hash->i_size, c_key, i_addr, OP));
+ return hash_nextaddr(p_hash, p_hash->i_size, c_key, i_addr, OP);
}
RETCODE
hash_addrisfree(Hash *p_hash, int i_addr) {
if (p_hash->p_elems[i_addr].flag == 'f' ||
p_hash->p_elems[i_addr].flag == 'm')
- return (RET_OK);
+ return RET_OK;
- return (RET_ERROR);
+ return RET_ERROR;
}
RETCODE
hash_addrisocc(Hash *p_hash, int i_addr, char *c_key) {
if (p_hash->p_elems[i_addr].flag == 'o' &&
!strcmp(p_hash->p_elems[i_addr].c_key, c_key))
- return (RET_OK);
+ return RET_OK;
- return (RET_ERROR);
+ return RET_ERROR;
}
int
hash_nextaddr(Hash *p_hash, int i_max_tries, char *c_key, int i_addr,
HASH_OP OP) {
if ( --i_max_tries < 0 )
- return (RET_ERROR);
+ return RET_ERROR;
i_addr = (i_addr + 1) % p_hash->i_size;
switch (OP) {
- case FREE_ADDR:
+ case free_ADDR:
if (!hash_addrisfree(p_hash,i_addr))
- return (i_addr);
+ return i_addr;
break;
case OCC_ADDR:
if (!hash_addrisocc(p_hash,i_addr, c_key))
- return (i_addr);
+ return i_addr;
break;
}
- return (hash_nextaddr(p_hash, i_max_tries, c_key, i_addr, OP));
+ return hash_nextaddr(p_hash, i_max_tries, c_key, i_addr, OP);
}
void
hash_print(Hash *p_hash) {
- printf("hash_print [size:%d,cur:%d] syntax "
- " (flag[,key][=TYPE[<val>]]):\n -> ",
+ printf("hash_print [size:%d,cur:%d] syntax (flag[,key][=TYPE[<val>]]):\n -> ",
p_hash->i_size,p_hash->i_cur_size);
for (int i = 0; i < p_hash->i_size; ++i) {
@@ -280,7 +279,7 @@ hash_size(Hash *p_hash, int i_size) {
p_old_elems[i].p_val, p_old_elems[i].type);
free(p_old_elems);
- return (RET_OK);
+ return RET_OK;
}
void
@@ -289,18 +288,3 @@ hash_iterate(Hash *p_hash, void (*func)(void *)) {
if (p_hash->p_elems[i].flag == 'o')
(*func) (p_hash->p_elems[i].p_val);
}
-
-void
-hash_iterate_key(Hash *p_hash, void (*func)(void *, char *)) {
- for (int i = 0; i < p_hash->i_size; ++i)
- if (p_hash->p_elems[i].flag == 'o')
- (*func) (p_hash->p_elems[i].p_val, p_hash->p_elems[i].c_key);
-}
-
-_Bool
-hash_key_exists(Hash *p_hash, char *c_key) {
- if (hash_get(p_hash, c_key))
- return (true);
-
- return (false);
-}
diff --git a/src/data/hash.h b/src/data/hash.h
index 8bf0a49..196c4a8 100644
--- a/src/data/hash.h
+++ b/src/data/hash.h
@@ -1,12 +1,12 @@
/*:*
*: File: ./src/data/hash.h
- *: A simple Fype interpreter
+ *: A simple interpreter
*:
- *: WWW: http://fype.buetow.org
- *: AUTHOR: http://paul.buetow.org
- *: E-Mail: fype at dev.buetow.org
+ *: WWW : http://fype.buetow.org
+ *: E-Mail : fype@dev.buetow.org
*:
- *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *: Copyright (c) 2005 2006 2007 2008, Dipl.-Inf. (FH) Paul C. Buetow
+ *: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
*: fication, are permitted provided that the following conditions are met:
@@ -15,14 +15,14 @@
*: * Redistributions in binary form must reproduce the above copyright
*: notice, this list of conditions and the following disclaimer in the
*: documentation and/or other materials provided with the distribution.
- *: * Neither the name of buetow.org nor the names of its contributors may
+ *: * Neither the name of P. B. Labs nor the names of its contributors may
*: be used to endorse or promote products derived from this software
*: without specific prior written permission.
*:
- *: THIS SOFTWARE IS PROVIDED BY PAUL C. BUETOW AS IS'' AND ANY EXPRESS OR
+ *: THIS SOFTWARE IS PROVIDED BY Paul Buetow AS IS'' AND ANY EXPRESS OR
*: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
*: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- *: DISCLAIMED. IN NO EVENT SHALL PAUL C. BUETOW BE LIABLE FOR ANY DIRECT,
+ *: DISCLAIMED. IN NO EVENT SHALL Paul Buetow BE LIABLE FOR ANY DIRECT,
*: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
*: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
*: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -39,7 +39,7 @@
#include "types.h"
typedef enum HASH_OP_ {
- FREE_ADDR,
+ free_ADDR,
OCC_ADDR
} HASH_OP;
@@ -60,10 +60,10 @@ Hash*hash_new(unsigned i_size);
void hash_delete(Hash *p_hash);
RETCODE hash_insert(Hash *p_hash, char *c_key, void *p_val);
RETCODE hash_insert_ht(Hash *p_hash, char *c_key, void *p_val, TYPE type);
-void* hash_get(Hash *p_hash, char *c_key);
-void* hash_get_ht(Hash *p_hash, char *c_key, TYPE *p_type);
-void* hash_get_ht_addr(Hash *p_hash, char *c_key, TYPE *p_type, int *p_addr);
-void* hash_remove(Hash *p_hash, char *c_key);
+void*hash_get(Hash *p_hash, char *c_key);
+void*hash_get_ht(Hash *p_hash, char *c_key, TYPE *p_type);
+void*hash_get_ht_addr(Hash *p_hash, char *c_key, TYPE *p_type, int *p_addr);
+void*hash_remove(Hash *p_hash, char *c_key);
void hash_print(Hash *p_hash);
void hash_print_addrval(Hash *p_hash, int i_addr);
RETCODE hash_size(Hash *p_hash, int i_size);
@@ -71,12 +71,8 @@ RETCODE hash_size(Hash *p_hash, int i_size);
int hash_getaddr(Hash *p_hash, char *c_key, HASH_OP OP);
RETCODE hash_addrisfree(Hash *p_hash, int i_addr);
RETCODE hash_addrisocc(Hash *p_hash, int i_addr, char *c_key);
-int hash_nextaddr(Hash *p_hash, int i_max_tries,
- char *c_key, int i_addr,
- HASH_OP OP);
+int hash_nextaddr(Hash *p_hash, int i_max_tries, char *c_key, int i_addr, HASH_OP OP);
void hash_iterate(Hash *p_hash, void (*func)(void *));
-void hash_iterate_key(Hash *p_hash, void (*func)(void *, char *));
-_Bool hash_key_exists(Hash *p_hash, char *c_key);
#define hash_get_cur_size(hash) hash->i_cur_size
#define hash_get_size(hash) hash->i_size
diff --git a/src/data/list.c b/src/data/list.c
index e641133..83860c3 100644
--- a/src/data/list.c
+++ b/src/data/list.c
@@ -1,12 +1,12 @@
/*:*
*: File: ./src/data/list.c
- *: A simple Fype interpreter
+ *: A simple interpreter
*:
- *: WWW: http://fype.buetow.org
- *: AUTHOR: http://paul.buetow.org
- *: E-Mail: fype at dev.buetow.org
+ *: WWW : http://fype.buetow.org
+ *: E-Mail : fype@dev.buetow.org
*:
- *: The Fype Language; (c) 2005 - 2010 - Dipl.-Inform. (FH) Paul C. Buetow
+ *: Copyright (c) 2005 2006 2007 2008, Dipl.-Inf. (FH) Paul C. Buetow
+ *: All rights reserved.
*:
*: Redistribution and use in source and binary forms, with or without modi-
*: fication, are permitted provided that the following conditions are met:
@@ -15,14 +15,14 @@
*: * Redistributions in binary form must reproduce the above copyright
*: notice, this list of conditions and the following disclaimer in the
*: documentation and/or other materials provided with the distribution.
- *: * Neither the name of buetow.org nor the names of its contributors may
+ *: * Neither the name of P. B. Labs nor the names of its contributors may
*: be used to endorse or promote products derived from this software
*: without specific prior written permission.
*:
- *: THIS SOFTWARE IS PROVIDED BY PAUL C. BUETOW AS IS'' AND ANY EXPRESS OR
+ *: THIS SOFTWARE IS PROVIDED BY Paul Buetow AS IS'' AND ANY EXPRESS OR
*: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
*: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- *: DISCLAIMED. IN NO EVENT SHALL PAUL C. BUETOW BE LIABLE FOR ANY DIRECT,