cleanup, fixes, w/o snaps
This commit is contained in:
parent
acd2db46a9
commit
0f3b3c4f82
|
@ -12,15 +12,26 @@
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
#define SKIPLIST_DEBUG slex
|
#define SKIPLIST_DEBUG slex
|
||||||
|
//define SKIPLIST_MAX_HEIGHT 12
|
||||||
/* Setting this will do two things:
|
/* Setting this will do two things:
|
||||||
* 1) limit our max height across all instances of this datastructure.
|
* 1) limit our max height across all instances of this datastructure.
|
||||||
* 2) remove a heap allocation on frequently used paths, insert/remove/etc.
|
* 2) remove a heap allocation on frequently used paths, insert/remove/etc.
|
||||||
* so, use it when you need it.
|
* so, use it when you need it.
|
||||||
*/
|
*/
|
||||||
#define SKIPLIST_MAX_HEIGHT 12
|
|
||||||
#include "../include/sl.h"
|
#include "../include/sl.h"
|
||||||
|
|
||||||
|
//define INTEGRITY
|
||||||
|
#ifdef INTEGRITY
|
||||||
|
#define INTEGRITY_CHK __skip_integrity_check_slex(list, 0)
|
||||||
|
#else
|
||||||
|
#define INTEGRITY_CHK ((void)0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//define SNAPSHOTS
|
||||||
|
//define DOT
|
||||||
|
#define TEST_ARRAY_SIZE 2000
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SKIPLIST EXAMPLE:
|
* SKIPLIST EXAMPLE:
|
||||||
*
|
*
|
||||||
|
@ -189,17 +200,6 @@ shuffle(int *array, size_t n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define INTEGRITY
|
|
||||||
#ifdef INTEGRITY
|
|
||||||
#define INTEGRITY_CHK __skip_integrity_check_slex(list, 0)
|
|
||||||
#else
|
|
||||||
#define INTEGRITY_CKH ((void)0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SNAPSHOTS
|
|
||||||
#define DOT
|
|
||||||
#define TEST_ARRAY_SIZE 5
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
|
@ -219,12 +219,16 @@ main()
|
||||||
if (list == NULL)
|
if (list == NULL)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
|
|
||||||
rc = api_skip_init_slex(list, 12, __slm_key_compare);
|
rc = api_skip_init_slex(list, -12, __slm_key_compare);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
#ifdef DOT
|
#ifdef DOT
|
||||||
api_skip_dot_slex(of, list, gen++, "init", sprintf_slex_node);
|
api_skip_dot_slex(of, list, gen++, "init", sprintf_slex_node);
|
||||||
#endif
|
#endif
|
||||||
|
if (api_skip_get_slex(list, 0) != NULL)
|
||||||
|
perror("found a non-existent item!");
|
||||||
|
api_skip_del_slex(list, 0);
|
||||||
|
INTEGRITY_CHK;
|
||||||
|
|
||||||
#ifdef SNAPSHOTS
|
#ifdef SNAPSHOTS
|
||||||
/* Test creating a snapshot of an empty Skiplist */
|
/* Test creating a snapshot of an empty Skiplist */
|
||||||
|
@ -234,7 +238,10 @@ main()
|
||||||
|
|
||||||
/* Insert 7 key/value pairs into the list. */
|
/* Insert 7 key/value pairs into the list. */
|
||||||
int i, j;
|
int i, j;
|
||||||
char *numeral, msg[1024];
|
char *numeral;
|
||||||
|
#ifdef DOT
|
||||||
|
char msg[1024];
|
||||||
|
#endif
|
||||||
int amt = TEST_ARRAY_SIZE, asz = (amt * 2) + 1;
|
int amt = TEST_ARRAY_SIZE, asz = (amt * 2) + 1;
|
||||||
int array[(TEST_ARRAY_SIZE * 2) + 1];
|
int array[(TEST_ARRAY_SIZE * 2) + 1];
|
||||||
for (j = 0, i = -amt; i <= amt; i++, j++)
|
for (j = 0, i = -amt; i <= amt; i++, j++)
|
||||||
|
@ -248,8 +255,8 @@ main()
|
||||||
INTEGRITY_CHK;
|
INTEGRITY_CHK;
|
||||||
#ifdef SNAPSHOTS
|
#ifdef SNAPSHOTS
|
||||||
snp[i + 1] = api_skip_snapshot_slex(list);
|
snp[i + 1] = api_skip_snapshot_slex(list);
|
||||||
#endif
|
|
||||||
INTEGRITY_CHK;
|
INTEGRITY_CHK;
|
||||||
|
#endif
|
||||||
#ifdef DOT
|
#ifdef DOT
|
||||||
sprintf(msg, "put key: %d value: %s", i, numeral);
|
sprintf(msg, "put key: %d value: %s", i, numeral);
|
||||||
api_skip_dot_slex(of, list, gen++, msg, sprintf_slex_node);
|
api_skip_dot_slex(of, list, gen++, msg, sprintf_slex_node);
|
||||||
|
@ -286,6 +293,20 @@ main()
|
||||||
|
|
||||||
api_skip_del_slex(list, 0);
|
api_skip_del_slex(list, 0);
|
||||||
INTEGRITY_CHK;
|
INTEGRITY_CHK;
|
||||||
|
if (api_skip_get_slex(list, 0) != NULL)
|
||||||
|
perror("found a deleted item!");
|
||||||
|
api_skip_del_slex(list, 0);
|
||||||
|
INTEGRITY_CHK;
|
||||||
|
if (api_skip_get_slex(list, 0) != NULL)
|
||||||
|
perror("found a deleted item!");
|
||||||
|
int key = TEST_ARRAY_SIZE + 1;
|
||||||
|
numeral = int_to_roman_numeral(key);
|
||||||
|
api_skip_del_slex(list, key);
|
||||||
|
INTEGRITY_CHK;
|
||||||
|
key = -(TEST_ARRAY_SIZE) - 1;
|
||||||
|
numeral = int_to_roman_numeral(key);
|
||||||
|
api_skip_del_slex(list, key);
|
||||||
|
INTEGRITY_CHK;
|
||||||
#ifdef SNAPSHOTS
|
#ifdef SNAPSHOTS
|
||||||
snp[++i] = api_skip_snapshot_slex(list);
|
snp[++i] = api_skip_snapshot_slex(list);
|
||||||
INTEGRITY_CHK;
|
INTEGRITY_CHK;
|
||||||
|
|
|
@ -23,11 +23,12 @@
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
autoconf
|
autoconf
|
||||||
bashInteractive
|
bashInteractive
|
||||||
graphviz-nox
|
clang-tools
|
||||||
ed
|
ed
|
||||||
gdb
|
gdb
|
||||||
clang-tools
|
graphviz-nox
|
||||||
meson
|
meson
|
||||||
|
python311Packages.rbtools
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
|
|
712
include/sl.h
712
include/sl.h
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue