ArraySTF impl

Implements array which supports strings as index values.

Summary
ArraySTF implImplements array which supports strings as index values.
CopyrightThis program is free software.
Files
C-kern/api/ds/inmem/arraystf.hHeader file ArraySTF.
C-kern/ds/inmem/arraystf.cImplementation file ArraySTF impl.
arraystf_node_t
static variables
s_arraystf_errtimerSimulates an error in different functions.
helper
compiletime_assertChecks that arraystf_node_t can be castet into string_t.
arraystf_keyval_tDescribes the value of a key string at a certain memory offset.
Functions
init_arraystfkeyvalLoads next key data byte at offset from node into keyval.
initdiff_arraystfkeyvalSearches the first position where the two keys differ.
arraystf_t
helper
lifetime
query
change
arraystf_iterator_t
test

Copyright

This program is free software.  You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 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 General Public License for more details.

Author

© 2011 Jörg Seebohn

Files

C-kern/api/ds/inmem/arraystf.h

Header file ArraySTF.

C-kern/ds/inmem/arraystf.c

Implementation file ArraySTF impl.

arraystf_node_t

Summary
static variables
s_arraystf_errtimerSimulates an error in different functions.
helper
compiletime_assertChecks that arraystf_node_t can be castet into string_t.

static variables

s_arraystf_errtimer

static test_errortimer_t s_arraystf_errtimer

Simulates an error in different functions.

helper

compiletime_assert

static inline void compiletime_assert(void)

Checks that arraystf_node_t can be castet into string_t.

arraystf_keyval_t

struct arraystf_keyval_t

Describes the value of a key string at a certain memory offset.

Summary
Functions
init_arraystfkeyvalLoads next key data byte at offset from node into keyval.
initdiff_arraystfkeyvalSearches the first position where the two keys differ.

Functions

init_arraystfkeyval

static void init_arraystfkeyval(/*out*/arraystf_keyval_t *keyval,
size_t offset,
arraystf_node_t *node)

Loads next key data byte at offset from node into keyval.  The key is defined to be 0 at offsets beyond arraystf_node_t.size.  The special offset (-1) returns in keyval the length of the key.  This special key encoding ensures that no key is a prefix of another (longer) key.

initdiff_arraystfkeyval

static int initdiff_arraystfkeyval(/*out*/arraystf_keyval_t *keyval,
arraystf_node_t *node,
arraystf_node_t *key)

Searches the first position where the two keys differ.  This position is returned in keyval as offset and data value.  The returned data value is result of the the xor operation between the two key values at the computed offset.

The xor operation is chosen so that the first differing bit generates a set bit in <arraystf_keyval_t.data>.  With log2_int it is possible to compute the bit index and to determine the value of arraystf_mwaybranch_t.shift.

arraystf_t

helper

lifetime

query

change

arraystf_iterator_t

test

Array implementation which supports strings as indizes (st).
Implements array which supports strings as index values.
static test_errortimer_t s_arraystf_errtimer
Simulates an error in different functions.
static inline void compiletime_assert(void)
Checks that arraystf_node_t can be castet into string_t.
struct arraystf_keyval_t
Describes the value of a key string at a certain memory offset.
static void init_arraystfkeyval(/*out*/arraystf_keyval_t *keyval,
size_t offset,
arraystf_node_t *node)
Loads next key data byte at offset from node into keyval.
static int initdiff_arraystfkeyval(/*out*/arraystf_keyval_t *keyval,
arraystf_node_t *node,
arraystf_node_t *key)
Searches the first position where the two keys differ.
size_t size
Length of key in memory in bytes.
Implements int_t.log2_int as a generic function.
uint8_t shift
Index of bit of key data byte at position offset used to branch.
Close