added missing functions and macros.
documented more functions
This commit is contained in:
parent
95e975f514
commit
70bf0fceaf
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: chr.h 323 2010-04-05 12:50:01Z hyunghwan.chung $
|
||||
* $Id: chr.h 356 2010-09-07 12:29:25Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -24,10 +24,8 @@
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
/****t* Common/qse_ccls_id_t
|
||||
* NAME
|
||||
* qse_ccls_id_t - define character class types
|
||||
* SYNOPSIS
|
||||
/**
|
||||
* The qse_ccls_id_t type defines character class types.
|
||||
*/
|
||||
enum qse_ccls_id_t
|
||||
{
|
||||
@ -44,7 +42,6 @@ enum qse_ccls_id_t
|
||||
QSE_CCLS_PUNCT
|
||||
};
|
||||
typedef enum qse_ccls_id_t qse_ccls_id_t;
|
||||
/******/
|
||||
|
||||
#ifdef USE_STDC
|
||||
# if defined(QSE_CHAR_IS_MCHAR)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: dll.h 354 2010-09-03 12:50:08Z hyunghwan.chung $
|
||||
* $Id: dll.h 356 2010-09-07 12:29:25Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -109,7 +109,7 @@
|
||||
|
||||
#define QSE_DLL_HEAD(dll) QSE_GDL_HEAD(&(dll)->gdl)
|
||||
#define QSE_DLL_TAIL(dll) QSE_GDL_TAIL(&(dll)->gdl)
|
||||
#define QSE_DLL_SIZE(dll) ((dll)->size)
|
||||
#define QSE_DLL_SIZE(dll) ((const qse_size_t)(dll)->size)
|
||||
|
||||
/**
|
||||
* The QSE_DLL_ADDHEAD macro add a member node @a x to the head of
|
||||
@ -219,11 +219,10 @@ struct qse_dll_t
|
||||
#define QSE_DLL_COPIER_SIMPLE ((qse_dll_copier_t)1)
|
||||
#define QSE_DLL_COPIER_INLINE ((qse_dll_copier_t)2)
|
||||
|
||||
#define QSE_DLL_SCALE(dll) ((dll)->scale)
|
||||
#define QSE_DLL_SCALE(dll) ((const int)(dll)->scale)
|
||||
#define QSE_DLL_DPTR(node) ((node)->dptr)
|
||||
#define QSE_DLL_DLEN(node) ((node)->dlen)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -323,6 +322,21 @@ qse_dll_freeer_t qse_dll_getfreeer (
|
||||
qse_dll_t* dll /**< doubly linked list */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_dll_getcomper() function returns the data comparator.
|
||||
*/
|
||||
qse_dll_comper_t qse_dll_getcomper (
|
||||
qse_dll_t* dll /**< doubly linked list */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_dll_setcomper() function changes the data comparator
|
||||
*/
|
||||
void qse_dll_setcomper (
|
||||
qse_dll_t* dll, /**< doubly linked list */
|
||||
qse_dll_comper_t comper /**< comparator */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_dll_getsize() function returns the number of the data nodes held
|
||||
* in a doubly linked list.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: htb.h 355 2010-09-07 10:57:43Z hyunghwan.chung $
|
||||
* $Id: htb.h 356 2010-09-07 12:29:25Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -158,7 +158,6 @@ struct qse_htb_t
|
||||
|
||||
qse_byte_t scale[2]; /**< length scale */
|
||||
qse_byte_t factor; /**< load factor in percentage */
|
||||
qse_byte_t filler0;
|
||||
|
||||
qse_size_t size;
|
||||
qse_size_t capa;
|
||||
@ -173,26 +172,17 @@ struct qse_htb_t
|
||||
/**
|
||||
* The QSE_HTB_SIZE() macro returns the number of pairs in a hash table.
|
||||
*/
|
||||
#define QSE_HTB_SIZE(m) ((m)->size)
|
||||
#define QSE_HTB_SIZE(m) ((const qse_size_t)(m)->size)
|
||||
|
||||
/**
|
||||
* The QSE_HTB_CAPA() macro returns the maximum number of pairs that can be
|
||||
* stored in a hash table without further reorganization.
|
||||
*/
|
||||
#define QSE_HTB_CAPA(m) ((m)->capa)
|
||||
#define QSE_HTB_CAPA(m) ((const qse_size_t)(m)->capa)
|
||||
|
||||
#define QSE_HTB_KCOPIER(m) ((m)->copier[QSE_HTB_KEY])
|
||||
#define QSE_HTB_VCOPIER(m) ((m)->copier[QSE_HTB_VAL])
|
||||
#define QSE_HTB_KFREEER(m) ((m)->freeer[QSE_HTB_KEY])
|
||||
#define QSE_HTB_VFREEER(m) ((m)->freeer[QSE_HTB_VAL])
|
||||
#define QSE_HTB_HASHER(m) ((m)->hasher)
|
||||
#define QSE_HTB_COMPER(m) ((m)->comper)
|
||||
#define QSE_HTB_KEEPER(m) ((m)->keeper)
|
||||
#define QSE_HTB_SIZER(m) ((m)->sizer)
|
||||
|
||||
#define QSE_HTB_FACTOR(m) ((m)->factor)
|
||||
#define QSE_HTB_KSCALE(m) ((m)->scale[QSE_HTB_KEY])
|
||||
#define QSE_HTB_VSCALE(m) ((m)->scale[QSE_HTB_VAL])
|
||||
#define QSE_HTB_FACTOR(m) ((const int)(m)->factor)
|
||||
#define QSE_HTB_KSCALE(m) ((const int)(m)->scale[QSE_HTB_KEY])
|
||||
#define QSE_HTB_VSCALE(m) ((const int)(m)->scale[QSE_HTB_VAL])
|
||||
|
||||
#define QSE_HTB_KPTR(p) ((p)->kptr)
|
||||
#define QSE_HTB_KLEN(p) ((p)->klen)
|
||||
@ -364,7 +354,7 @@ void qse_htb_setsizer (
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_htb_search() function searches hash table to find a pair with a
|
||||
* The qse_htb_search() function searches a hash table to find a pair with a
|
||||
* matching key. It returns the pointer to the pair found. If it fails
|
||||
* to find one, it returns QSE_NULL.
|
||||
* @return pointer to the pair with a maching key,
|
||||
@ -377,7 +367,7 @@ qse_htb_pair_t* qse_htb_search (
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_htb_upsert() function searches hash table for the pair with a
|
||||
* The qse_htb_upsert() function searches a hash table for the pair with a
|
||||
* matching key. If one is found, it updates the pair. Otherwise, it inserts
|
||||
* a new pair with the key and value given. It returns the pointer to the
|
||||
* pair updated or inserted.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: lda.h 341 2010-08-04 07:25:48Z hyunghwan.chung $
|
||||
* $Id: lda.h 356 2010-09-07 12:29:25Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -45,19 +45,13 @@ typedef enum qse_lda_walk_t qse_lda_walk_t;
|
||||
|
||||
#define QSE_LDA_NIL ((qse_size_t)-1)
|
||||
|
||||
#define QSE_LDA_SIZE(lda) ((lda)->size)
|
||||
#define QSE_LDA_CAPA(lda) ((lda)->capa)
|
||||
#define QSE_LDA_SIZE(lda) ((const qse_size_t)(lda)->size)
|
||||
#define QSE_LDA_CAPA(lda) ((const qse_size_t)(lda)->capa)
|
||||
|
||||
#define QSE_LDA_NODE(lda,index) ((lda)->node[index])
|
||||
#define QSE_LDA_DPTR(lda,index) ((lda)->node[index]->dptr)
|
||||
#define QSE_LDA_DLEN(lda,index) ((lda)->node[index]->dlen)
|
||||
|
||||
#define QSE_LDA_COPIER(lda) ((lda)->copier)
|
||||
#define QSE_LDA_FREEER(lda) ((lda)->freeer)
|
||||
#define QSE_LDA_COMPER(lda) ((lda)->comper)
|
||||
#define QSE_LDA_KEEPER(lda) ((lda)->keeper)
|
||||
#define QSE_LDA_SIZER(lda) ((lda)->sizer)
|
||||
|
||||
/**
|
||||
* The qse_lda_copier_t type defines a callback function for node construction.
|
||||
* A node is contructed when a user adds data to a list. The user can
|
||||
|
@ -18,18 +18,47 @@
|
||||
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _QSE_OHT_T_
|
||||
#define _QSE_OHT_T_
|
||||
|
||||
/** @file
|
||||
* This file provides the open-addressed hash table for fixed-size data.
|
||||
*/
|
||||
#ifndef _QSE_OHT_T_
|
||||
#define _QSE_OHT_T_
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
#define QSE_OHT_INVALID_INDEX ((qse_size_t)-1)
|
||||
/**
|
||||
* The #QSE_OHT_NIL macro represents an invalid index.
|
||||
*/
|
||||
#define QSE_OHT_NIL ((qse_size_t)-1)
|
||||
|
||||
enum qse_oht_mark_t
|
||||
/**
|
||||
* The #QSE_OHT_SIZE macro returns the number of items.
|
||||
*/
|
||||
#define QSE_OHT_SIZE(oht) ((const qse_size_t)(oht)->size)
|
||||
|
||||
/**
|
||||
* The #QSE_OHT_CAPA macro returns the capacity of a table.
|
||||
*/
|
||||
#define QSE_OHT_CAPA(oht) ((const qse_size_t)(oht)->capa.hard)
|
||||
|
||||
/**
|
||||
* The #QSE_OHT_LIMIT macro returns the maximum number of items.
|
||||
* It is equal to or less than the capacity.
|
||||
*/
|
||||
#define QSE_OHT_LIMIT(oht) ((const qse_size_t)(oht)->capa.soft)
|
||||
|
||||
/**
|
||||
* The #QSE_OHT_SCALE macro returns the size of an item in bytes.
|
||||
*/
|
||||
#define QSE_OHT_SCALE(oht) ((const int)(oht)->scale)
|
||||
|
||||
/**
|
||||
* The #qse_oht_mark_t type defines enumerations values to indicate
|
||||
* the slot status.
|
||||
*/
|
||||
enum qse_oht_mark_t
|
||||
{
|
||||
QSE_OHT_EMPTY = 0,
|
||||
QSE_OHT_OCCUPIED = 1 /*,
|
||||
@ -37,6 +66,9 @@ enum qse_oht_mark_t
|
||||
};
|
||||
typedef enum qse_oht_mark_t qse_oht_mark_t;
|
||||
|
||||
/**
|
||||
* The #qse_oht_walk_t type defines walking directions.
|
||||
*/
|
||||
enum qse_oht_walk_t
|
||||
{
|
||||
QSE_OHT_WALK_STOP = 0,
|
||||
@ -47,7 +79,15 @@ typedef enum qse_oht_walk_t qse_oht_walk_t;
|
||||
typedef struct qse_oht_t qse_oht_t;
|
||||
|
||||
/**
|
||||
* The qse_oht_comper_t type defines a key comparator that is called when
|
||||
* The #qse_oht_hasher_t type defines a data hasher function.
|
||||
*/
|
||||
typedef qse_size_t (*qse_oht_hasher_t) (
|
||||
qse_oht_t* oht,
|
||||
const void* data
|
||||
);
|
||||
|
||||
/**
|
||||
* The #qse_oht_comper_t type defines a key comparator that is called when
|
||||
* the list needs to compare data. The comparator must return 0 if the data
|
||||
* are the same and a non-zero integer otherwise.
|
||||
*/
|
||||
@ -57,28 +97,30 @@ typedef int (*qse_oht_comper_t) (
|
||||
const void* data2 /**< data pointer */
|
||||
);
|
||||
|
||||
/**
|
||||
* The #qse_oht_copier_t type defines a data copier function.
|
||||
*/
|
||||
typedef void (*qse_oht_copier_t) (
|
||||
qse_oht_t* oht,
|
||||
void* dst,
|
||||
const void* src
|
||||
);
|
||||
|
||||
typedef qse_size_t (*qse_oht_hasher_t) (
|
||||
qse_oht_t* oht,
|
||||
const void* data
|
||||
);
|
||||
|
||||
/**
|
||||
* The #qse_oht_t type defines an open-address hash table for fixed-size data.
|
||||
* Unlike #qse_rbt_t or #qse_htb_t, it does not separate a key from a value.
|
||||
*/
|
||||
struct qse_oht_t
|
||||
{
|
||||
QSE_DEFINE_COMMON_FIELDS(oht)
|
||||
|
||||
int scale;
|
||||
struct
|
||||
{
|
||||
qse_size_t hard;
|
||||
qse_size_t soft;
|
||||
} capa;
|
||||
qse_size_t size;
|
||||
qse_size_t scale;
|
||||
|
||||
qse_oht_hasher_t hasher;
|
||||
qse_oht_comper_t comper;
|
||||
@ -88,6 +130,10 @@ struct qse_oht_t
|
||||
void* data;
|
||||
};
|
||||
|
||||
/**
|
||||
* The #qse_oht_walker_t function defines a callback function
|
||||
* for qse_oht_walk().
|
||||
*/
|
||||
typedef qse_oht_walk_t (*qse_oht_walker_t) (
|
||||
qse_oht_t* oht,
|
||||
void* data,
|
||||
@ -100,90 +146,157 @@ extern "C" {
|
||||
|
||||
QSE_DEFINE_COMMON_FUNCTIONS (oht)
|
||||
|
||||
/**
|
||||
* The qse_oht_open() function creates an open-addressed hash table.
|
||||
*/
|
||||
qse_oht_t* qse_oht_open (
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t xtnsize,
|
||||
qse_size_t scale,
|
||||
int scale,
|
||||
qse_size_t capa,
|
||||
qse_size_t limit
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_oht_close() function destroys an open-addressed hash table.
|
||||
*/
|
||||
void qse_oht_close (
|
||||
qse_oht_t* oht
|
||||
qse_oht_t* oht /**< open-addressed hash table */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_oht_open() function initializes a statically declared
|
||||
* open-addressed hash table.
|
||||
*/
|
||||
qse_oht_t* qse_oht_init (
|
||||
qse_oht_t* oht,
|
||||
qse_mmgr_t* mmgr,
|
||||
qse_size_t scale,
|
||||
int scale,
|
||||
qse_size_t capa,
|
||||
qse_size_t limit
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_oht_close() function finalizes an open-addressed hash table.
|
||||
*/
|
||||
void qse_oht_fini (
|
||||
qse_oht_t* oht
|
||||
qse_oht_t* oht /**< open-addressed hash table */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_oht_getcomper() function returns the data hasher.
|
||||
*/
|
||||
qse_oht_hasher_t qse_oht_gethasher (
|
||||
qse_oht_t* oht
|
||||
qse_oht_t* oht /**< open-addressed hash table */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_oht_setcomper() function changes the data hasher
|
||||
*/
|
||||
void qse_oht_sethasher (
|
||||
qse_oht_t* oht,
|
||||
qse_oht_hasher_t hahser
|
||||
qse_oht_t* oht, /**< open-addressed hash table */
|
||||
qse_oht_hasher_t hasher /**< hasher */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_oht_getcomper() function returns the data comparator.
|
||||
*/
|
||||
qse_oht_comper_t qse_oht_getcomper (
|
||||
qse_oht_t* oht
|
||||
qse_oht_t* oht /**< open-addressed hash table */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_oht_setcomper() function changes the data comparator
|
||||
*/
|
||||
void qse_oht_setcomper (
|
||||
qse_oht_t* oht,
|
||||
qse_oht_comper_t hahser
|
||||
qse_oht_t* oht, /**< open-addressed hash table */
|
||||
qse_oht_comper_t comper /**< comparator */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_oht_getcomper() function returns the data copier.
|
||||
*/
|
||||
qse_oht_copier_t qse_oht_getcopier (
|
||||
qse_oht_t* oht
|
||||
qse_oht_t* oht /**< open-addressed hash table */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_oht_setcomper() function changes the data copier.
|
||||
*/
|
||||
void qse_oht_setcopier (
|
||||
qse_oht_t* oht,
|
||||
qse_oht_copier_t hahser
|
||||
qse_oht_t* oht, /**< open-addressed hash table */
|
||||
qse_oht_copier_t copier /**< copier */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_oht_search() function searches a hash table to find a
|
||||
* matching datum. It returns the index to the slot of an internal array
|
||||
* where the matching datum is found.
|
||||
* @return slot index if a match if found,
|
||||
* #QSE_OHT_NIL if no match is found.
|
||||
*/
|
||||
qse_size_t qse_oht_search (
|
||||
qse_oht_t* oht,
|
||||
void* data
|
||||
qse_oht_t* oht, /**< open-addressed hash table */
|
||||
void* data /**< data pointer */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_oht_insert() function inserts a new datum. It fails if it finds
|
||||
* an existing datum.
|
||||
* @return slot index where the new datum is inserted on success,
|
||||
* #QSE_OHT_NIL on failure.
|
||||
*/
|
||||
qse_size_t qse_oht_insert (
|
||||
qse_oht_t* oht,
|
||||
const void* data
|
||||
qse_oht_t* oht, /**< open-addressed hash table */
|
||||
const void* data /**< data pointer */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_oht_upsert() function inserts a new datum if it finds no matching
|
||||
* datum or updates an exsting datum if finds a matching datum.
|
||||
* @return slot index where the datum is inserted or updated.
|
||||
*/
|
||||
qse_size_t qse_oht_upsert (
|
||||
qse_oht_t* oht,
|
||||
const void* data
|
||||
qse_oht_t* oht, /**< open-addressed hash table */
|
||||
const void* data /**< data pointer */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_oht_update() function updates an existing datum. It fails if it finds
|
||||
* no existing datum.
|
||||
* @return slot index where an existing datum is updated on success,
|
||||
* #QSE_OHT_NIL on failure.
|
||||
*/
|
||||
qse_size_t qse_oht_update (
|
||||
qse_oht_t* oht,
|
||||
const void* data
|
||||
qse_oht_t* oht, /**< open-addressed hash table */
|
||||
const void* data /**< data pointer */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_oht_delete() function deletes an existing datum. It fails if it finds
|
||||
* no existing datum.
|
||||
* @return slot index where an existing datum is deleted on success,
|
||||
* #QSE_OHT_NIL on failure.
|
||||
*/
|
||||
qse_size_t qse_oht_delete (
|
||||
qse_oht_t* oht,
|
||||
const void* data
|
||||
qse_oht_t* oht, /**< open-addressed hash table */
|
||||
const void* data /**< data pointer */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_oht_clear() functions deletes all data items.
|
||||
*/
|
||||
void qse_oht_clear (
|
||||
qse_oht_t* oht
|
||||
qse_oht_t* oht /**< open-addressed hash table */
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* The qse_oht_walk() function executes the callback function @a walker for
|
||||
* each valid data item.
|
||||
*/
|
||||
void qse_oht_walk (
|
||||
qse_oht_t* oht, /**< open-addressed hash table */
|
||||
qse_oht_walker_t walker, /**< walker function */
|
||||
qse_oht_walker_t walker, /**< callback function */
|
||||
void* ctx /**< context */
|
||||
);
|
||||
|
||||
|
@ -143,8 +143,6 @@ struct qse_rbt_t
|
||||
qse_rbt_keeper_t keeper; /**< value keeper */
|
||||
|
||||
qse_byte_t scale[2]; /**< length scale */
|
||||
qse_byte_t factor; /**< load factor */
|
||||
qse_byte_t filler0;
|
||||
|
||||
qse_rbt_pair_t nil; /**< internal nil node */
|
||||
|
||||
@ -167,18 +165,9 @@ struct qse_rbt_t
|
||||
/**
|
||||
* The QSE_RBT_SIZE() macro returns the number of pairs in red-black tree.
|
||||
*/
|
||||
#define QSE_RBT_SIZE(m) ((m)->size)
|
||||
|
||||
#define QSE_RBT_KCOPIER(m) ((m)->copier[QSE_RBT_KEY])
|
||||
#define QSE_RBT_VCOPIER(m) ((m)->copier[QSE_RBT_VAL])
|
||||
#define QSE_RBT_KFREEER(m) ((m)->freeer[QSE_RBT_KEY])
|
||||
#define QSE_RBT_VFREEER(m) ((m)->freeer[QSE_RBT_VAL])
|
||||
#define QSE_RBT_COMPER(m) ((m)->comper)
|
||||
#define QSE_RBT_KEEPER(m) ((m)->keeper)
|
||||
|
||||
#define QSE_RBT_FACTOR(m) ((m)->factor)
|
||||
#define QSE_RBT_KSCALE(m) ((m)->scale[QSE_RBT_KEY])
|
||||
#define QSE_RBT_VSCALE(m) ((m)->scale[QSE_RBT_VAL])
|
||||
#define QSE_RBT_SIZE(m) ((const qse_size_t)(m)->size)
|
||||
#define QSE_RBT_KSCALE(m) ((const int)(m)->scale[QSE_RBT_KEY])
|
||||
#define QSE_RBT_VSCALE(m) ((const int)(m)->scale[QSE_RBT_VAL])
|
||||
|
||||
#define QSE_RBT_KPTR(p) ((p)->kptr)
|
||||
#define QSE_RBT_KLEN(p) ((p)->klen)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: sll.h 355 2010-09-07 10:57:43Z hyunghwan.chung $
|
||||
* $Id: sll.h 356 2010-09-07 12:29:25Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -131,14 +131,10 @@ struct qse_sll_node_t
|
||||
#define QSE_SLL_COPIER_SIMPLE ((qse_sll_copier_t)1)
|
||||
#define QSE_SLL_COPIER_INLINE ((qse_sll_copier_t)2)
|
||||
|
||||
#define QSE_SLL_COPIER(sll) ((sll)->copier)
|
||||
#define QSE_SLL_FREEER(sll) ((sll)->freeer)
|
||||
#define QSE_SLL_COMPER(sll) ((sll)->comper)
|
||||
|
||||
#define QSE_SLL_HEAD(sll) ((sll)->head)
|
||||
#define QSE_SLL_TAIL(sll) ((sll)->tail)
|
||||
#define QSE_SLL_SIZE(sll) ((sll)->size)
|
||||
#define QSE_SLL_SCALE(sll) ((sll)->scale)
|
||||
#define QSE_SLL_SIZE(sll) ((const qse_size_t)(sll)->size)
|
||||
#define QSE_SLL_SCALE(sll) ((const int)(sll)->scale)
|
||||
|
||||
/**
|
||||
* The QSE_SLL_DPTR macro gets the data pointer in a node.
|
||||
@ -278,7 +274,7 @@ qse_sll_comper_t qse_sll_getcomper (
|
||||
* The qse_sll_setcomper() function changes the data comparator
|
||||
*/
|
||||
void qse_sll_setcomper (
|
||||
qse_sll_t* sll /**< singly linked list */,
|
||||
qse_sll_t* sll, /**< singly linked list */
|
||||
qse_sll_comper_t comper /**< comparator */
|
||||
);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: str.h 354 2010-09-03 12:50:08Z hyunghwan.chung $
|
||||
* $Id: str.h 356 2010-09-07 12:29:25Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -32,11 +32,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#define QSE_STR_LEN(s) ((s)->len) /**< string length */
|
||||
#define QSE_STR_PTR(s) ((s)->ptr) /**< string/buffer pointer */
|
||||
#define QSE_STR_CAPA(s) ((s)->capa) /**< buffer capacity */
|
||||
#define QSE_STR_LEN(s) ((const qse_size_t)(s)->len) /**< string length */
|
||||
#define QSE_STR_PTR(s) ((qse_char_t* const)(s)->ptr) /**< string/buffer pointer */
|
||||
#define QSE_STR_CAPA(s) ((qse_size_t)(s)->capa) /**< buffer capacity */
|
||||
#define QSE_STR_CHAR(s,idx) ((s)->ptr[idx]) /**< character at given position */
|
||||
#define QSE_STR_SIZER(s) ((s)->sizer) /**< buffer resizer function */
|
||||
|
||||
typedef struct qse_str_t qse_str_t;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: time.h 287 2009-09-15 10:01:02Z hyunghwan.chung $
|
||||
* $Id: time.h 356 2010-09-07 12:29:25Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -21,6 +21,10 @@
|
||||
#ifndef _QSE_CMN_TIME_H_
|
||||
#define _QSE_CMN_TIME_H_
|
||||
|
||||
/** @file
|
||||
* This file provides time manipulation functions.
|
||||
*/
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
|
||||
@ -78,20 +82,15 @@ struct qse_btime_t
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/****f* Common/qse_gettime
|
||||
* NAME
|
||||
* qse_gettime - get the current time
|
||||
* SYNPOSIS
|
||||
/**
|
||||
* The qse_gettime() function gets the current time.
|
||||
*/
|
||||
int qse_gettime (
|
||||
qse_ntime_t* nt
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* Common/qse_settime
|
||||
* NAME
|
||||
* qse_settime - set the current time
|
||||
* SYNOPSIS
|
||||
/**
|
||||
* The qse_settime() function sets the current time.
|
||||
*/
|
||||
int qse_settime (
|
||||
qse_ntime_t nt
|
||||
@ -114,7 +113,6 @@ int qse_localtime (
|
||||
qse_ntime_t nt,
|
||||
qse_btime_t* bt
|
||||
);
|
||||
/******/
|
||||
|
||||
/**
|
||||
* The qse_timegm() converts broken-down time to numeric time. It is the
|
||||
@ -125,7 +123,6 @@ int qse_timegm (
|
||||
const qse_btime_t* bt,
|
||||
qse_ntime_t* nt
|
||||
);
|
||||
/******/
|
||||
|
||||
/**
|
||||
* The qse_timelocal() converts broken-down time to numeric time. It is the
|
||||
@ -135,13 +132,9 @@ int qse_timelcoal (
|
||||
const qse_btime_t* bt,
|
||||
qse_ntime_t* nt
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* Common/qse_strftime
|
||||
* NAME
|
||||
* qse_strftime - format time
|
||||
*
|
||||
* SYNOPSIS
|
||||
/**
|
||||
* The qse_strftime() functions formats time.
|
||||
*/
|
||||
qse_size_t qse_strftime (
|
||||
qse_char_t* buf,
|
||||
@ -149,7 +142,6 @@ qse_size_t qse_strftime (
|
||||
const qse_char_t* fmt,
|
||||
qse_btime_t* bt
|
||||
);
|
||||
/******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: tio.h 291 2009-09-21 13:28:18Z hyunghwan.chung $
|
||||
* $Id: tio.h 356 2010-09-07 12:29:25Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -21,11 +21,15 @@
|
||||
#ifndef _QSE_CMN_TIO_H_
|
||||
#define _QSE_CMN_TIO_H_
|
||||
|
||||
/** @file
|
||||
* This file provides an interface to a text stream processor.
|
||||
*/
|
||||
|
||||
#include <qse/types.h>
|
||||
#include <qse/macros.h>
|
||||
#include <qse/cmn/str.h>
|
||||
|
||||
enum qse_tio_err_t
|
||||
enum qse_tio_errnum_t
|
||||
{
|
||||
QSE_TIO_ENOERR = 0,
|
||||
QSE_TIO_ENOMEM, /* out of memory */
|
||||
@ -43,7 +47,7 @@ enum qse_tio_err_t
|
||||
QSE_TIO_EOUTCL /* output function failed to close */
|
||||
};
|
||||
|
||||
typedef enum qse_tio_err_t qse_tio_err_t;
|
||||
typedef enum qse_tio_errnum_t qse_tio_errnum_t;
|
||||
|
||||
enum
|
||||
{
|
||||
@ -62,7 +66,7 @@ enum
|
||||
QSE_TIO_IO_DATA
|
||||
};
|
||||
|
||||
#define QSE_TIO_ERRNUM(tio) ((tio)->errnum)
|
||||
#define QSE_TIO_ERRNUM(tio) ((const qse_tio_errnum_t)(tio)->errnum)
|
||||
|
||||
typedef struct qse_tio_t qse_tio_t;
|
||||
|
||||
@ -84,7 +88,7 @@ typedef qse_ssize_t (*qse_tio_io_t) (
|
||||
struct qse_tio_t
|
||||
{
|
||||
QSE_DEFINE_COMMON_FIELDS (tio)
|
||||
qse_tio_err_t errnum;
|
||||
qse_tio_errnum_t errnum;
|
||||
|
||||
/* io functions */
|
||||
qse_tio_io_t input_func;
|
||||
@ -123,150 +127,107 @@ int qse_tio_close (
|
||||
qse_tio_t* tio
|
||||
);
|
||||
|
||||
/****f* Common/qse_tio_init
|
||||
* NAME
|
||||
* qse_tio_init - initialize an text IO processor
|
||||
* SYNOPSIS
|
||||
/**
|
||||
* The qse_tio_init() function initialize a statically declared
|
||||
* text stream processor.
|
||||
*/
|
||||
qse_tio_t* qse_tio_init (
|
||||
qse_tio_t* tip,
|
||||
qse_mmgr_t* mmgr
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* Common/qse_tio_fini
|
||||
* NAME
|
||||
* qse_tio_fini - finalize an text IO processor
|
||||
* SYNOPSIS
|
||||
/**
|
||||
* The qse_tio_fini() function finalizes a text stream processor
|
||||
*/
|
||||
int qse_tio_fini (
|
||||
qse_tio_t* tio
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* Common/qse_tio_geterrnum
|
||||
* NAME
|
||||
* qse_tio_geterrnum - get an error code
|
||||
*
|
||||
* SYNOPSIS
|
||||
/**
|
||||
* The qse_tio_geterrnum() function return an error code.
|
||||
*/
|
||||
qse_tio_err_t qse_tio_geterrnum (
|
||||
qse_tio_errnum_t qse_tio_geterrnum (
|
||||
qse_tio_t* tio
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* Common/qse_tio_geterrmsg
|
||||
* NAME
|
||||
* qse_tio_geterrmsg - translate an error code to a string
|
||||
* RETURN
|
||||
* A pointer to a constant string describing the last error occurred.
|
||||
/**
|
||||
* The qse_tio_geterrmsg() function translates an error code to a string.
|
||||
* @return pointer to a constant string describing the last error occurred.
|
||||
*/
|
||||
const qse_char_t* qse_tio_geterrmsg (
|
||||
qse_tio_t* tio
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* Common/qse_tio_attachin
|
||||
* NAME
|
||||
* qse_tio_attachin - attaches an input handler
|
||||
* RETURN
|
||||
* 0 on success, -1 on failure
|
||||
* SYNOPSIS
|
||||
/**
|
||||
* The qse_tio_attachin() function attachs an input handler .
|
||||
* @return 0 on success, -1 on failure
|
||||
*/
|
||||
int qse_tio_attachin (
|
||||
qse_tio_t* tio,
|
||||
qse_tio_io_t input,
|
||||
void* arg
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* Common/qse_tio_detachin
|
||||
* NAME
|
||||
* qse_tio_detachin - detach an input handler
|
||||
* RETURN
|
||||
* 0 on success, -1 on failure
|
||||
* SYNOPSIS
|
||||
/**
|
||||
* The qse_tio_detachin() function detaches an input handler .
|
||||
* @return 0 on success, -1 on failure
|
||||
*/
|
||||
int qse_tio_detachin (
|
||||
qse_tio_t* tio
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* Common/qse_tio_attachout
|
||||
* NAME
|
||||
* qse_tio_attachout - attaches an output handler
|
||||
* RETURN
|
||||
* 0 on success, -1 on failure
|
||||
* SYNOPSIS
|
||||
/**
|
||||
* The qse_tio_attachout() function attaches an output handler.
|
||||
* @return 0 on success, -1 on failure
|
||||
*/
|
||||
int qse_tio_attachout (
|
||||
qse_tio_t* tio,
|
||||
qse_tio_io_t output,
|
||||
void* arg
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* Common/qse_tio_detachout
|
||||
* NAME
|
||||
* qse_tio_detachout - detaches an output handler
|
||||
* RETURN
|
||||
* 0 on success, -1 on failure
|
||||
* SYNOPSIS
|
||||
/**
|
||||
* The qse_tio_detachout() function detaches an output handler .
|
||||
* @return 0 on success, -1 on failure
|
||||
*/
|
||||
int qse_tio_detachout (
|
||||
qse_tio_t* tio
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* Common/qse_tio_flush
|
||||
* NAME
|
||||
* qse_tio_flush - flush the output buffer
|
||||
* RETURNS
|
||||
* The qse_tio_flush() function return the number of bytes written on
|
||||
* success, -1 on failure.
|
||||
* SYNOPSIS
|
||||
/**
|
||||
* The qse_tio_flush() function flushes the output buffer. It returns the
|
||||
* number of bytes written on success, -1 on failure.
|
||||
*/
|
||||
qse_ssize_t qse_tio_flush (
|
||||
qse_tio_t* tio
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* Common/qse_tio_purge
|
||||
* NAME
|
||||
* qse_tio_purge - empty input and output buffers
|
||||
* SYNOPSIS
|
||||
/**
|
||||
* The qse_tio_purge() function empties input and output buffers.
|
||||
*/
|
||||
void qse_tio_purge (
|
||||
qse_tio_t* tio
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* Common/qse_tio_read
|
||||
* NAME
|
||||
* qse_tio_read - read text
|
||||
* SYNOPSIS
|
||||
/**
|
||||
* The qse_tio_read() functio reads text.
|
||||
*/
|
||||
qse_ssize_t qse_tio_read (
|
||||
qse_tio_t* tio,
|
||||
qse_char_t* buf,
|
||||
qse_size_t size
|
||||
);
|
||||
/******/
|
||||
|
||||
/****f* Common/qse_tio_write
|
||||
* NAME
|
||||
* qse_tio_write - write text
|
||||
* DESCRIPTION
|
||||
* If the size paramenter is (qse_size_t)-1, the function treats the data
|
||||
* parameter as a pointer to a null-terminated string.
|
||||
* SYNOPSIS
|
||||
/**
|
||||
* The qse_tio_write() function writes text.
|
||||
* If the size paramenter is (qse_size_t)-1, the function treats the data
|
||||
* parameter as a pointer to a null-terminated string.
|
||||
*/
|
||||
qse_ssize_t qse_tio_write (
|
||||
qse_tio_t* tio,
|
||||
const qse_char_t* data,
|
||||
qse_size_t size
|
||||
);
|
||||
/******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: rio.c 312 2009-12-10 13:03:54Z hyunghwan.chung $
|
||||
* $Id: rio.c 356 2010-09-07 12:29:25Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -299,7 +299,8 @@ int qse_awk_rtx_readio (
|
||||
QSE_STR_PTR(buf) + QSE_STR_LEN(buf) ==
|
||||
match.ptr + match.len);
|
||||
|
||||
QSE_STR_LEN(buf) -= match.len;
|
||||
/*QSE_STR_LEN(buf) -= match.len;*/
|
||||
buf->len -= match.len;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -322,7 +323,8 @@ int qse_awk_rtx_readio (
|
||||
if (pc == QSE_T('\r') &&
|
||||
QSE_STR_LEN(buf) > 0)
|
||||
{
|
||||
QSE_STR_LEN(buf) -= 1;
|
||||
/*QSE_STR_LEN(buf) -= 1;*/
|
||||
buf->len -= 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -335,7 +337,8 @@ int qse_awk_rtx_readio (
|
||||
if (pc == QSE_T('\r') &&
|
||||
QSE_STR_LEN(buf) > 0)
|
||||
{
|
||||
QSE_STR_LEN(buf) -= 1;
|
||||
/*QSE_STR_LEN(buf) -= 1;*/
|
||||
buf->len -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -353,7 +356,8 @@ int qse_awk_rtx_readio (
|
||||
/* when a blank line is encountered,
|
||||
* it needs to snip off the line
|
||||
* terminator of the previous line */
|
||||
QSE_STR_LEN(buf) -= 1;
|
||||
/*QSE_STR_LEN(buf) -= 1;*/
|
||||
buf->len -= 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -394,7 +398,8 @@ int qse_awk_rtx_readio (
|
||||
QSE_STR_PTR(buf) + QSE_STR_LEN(buf) ==
|
||||
match.ptr + match.len);
|
||||
|
||||
QSE_STR_LEN(buf) -= match.len;
|
||||
/*QSE_STR_LEN(buf) -= match.len;*/
|
||||
buf->len -= match.len;
|
||||
p->in.pos--; /* unread the character in c */
|
||||
break;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ static QSE_INLINE_ALWAYS void default_copier (
|
||||
|
||||
qse_oht_t* qse_oht_open (
|
||||
qse_mmgr_t* mmgr, qse_size_t xtnsize,
|
||||
qse_size_t scale, qse_size_t capa, qse_size_t limit)
|
||||
int scale, qse_size_t capa, qse_size_t limit)
|
||||
{
|
||||
qse_oht_t* oht;
|
||||
|
||||
@ -78,12 +78,12 @@ void qse_oht_close (qse_oht_t* oht)
|
||||
|
||||
qse_oht_t* qse_oht_init (
|
||||
qse_oht_t* oht, qse_mmgr_t* mmgr,
|
||||
qse_size_t scale, qse_size_t capa, qse_size_t limit)
|
||||
int scale, qse_size_t capa, qse_size_t limit)
|
||||
{
|
||||
qse_size_t i;
|
||||
|
||||
if (scale <= 0) scale = 1;
|
||||
if (capa >= QSE_OHT_INVALID_INDEX - 1) capa = QSE_OHT_INVALID_INDEX - 1;
|
||||
if (capa >= QSE_OHT_NIL - 1) capa = QSE_OHT_NIL - 1;
|
||||
if (limit > capa || limit <= 0) limit = capa;
|
||||
|
||||
QSE_MEMSET (oht, 0, QSE_SIZEOF(*oht));
|
||||
@ -165,13 +165,13 @@ static QSE_INLINE qse_size_t search (
|
||||
}
|
||||
}
|
||||
|
||||
return QSE_OHT_INVALID_INDEX;
|
||||
return QSE_OHT_NIL;
|
||||
}
|
||||
|
||||
qse_size_t qse_oht_search (qse_oht_t* oht, void* data)
|
||||
{
|
||||
qse_size_t i = search (oht, data, HASH_DATA(oht,data));
|
||||
if (i != QSE_OHT_INVALID_INDEX && data)
|
||||
if (i != QSE_OHT_NIL && data)
|
||||
COPY_DATA (oht, data, DATA_PTR(oht,i));
|
||||
return i;
|
||||
}
|
||||
@ -179,7 +179,7 @@ qse_size_t qse_oht_search (qse_oht_t* oht, void* data)
|
||||
qse_size_t qse_oht_update (qse_oht_t* oht, const void* data)
|
||||
{
|
||||
qse_size_t i = search (oht, data, HASH_DATA(oht,data));
|
||||
if (i != QSE_OHT_INVALID_INDEX)
|
||||
if (i != QSE_OHT_NIL)
|
||||
COPY_DATA (oht, DATA_PTR(oht,i), data);
|
||||
return i;
|
||||
}
|
||||
@ -190,14 +190,14 @@ qse_size_t qse_oht_upsert (qse_oht_t* oht, const void* data)
|
||||
|
||||
/* find the existing item */
|
||||
i = search (oht, data, hash);
|
||||
if (i != QSE_OHT_INVALID_INDEX)
|
||||
if (i != QSE_OHT_NIL)
|
||||
{
|
||||
COPY_DATA (oht, DATA_PTR(oht,i), data);
|
||||
return i;
|
||||
}
|
||||
|
||||
/* check if there is a free slot to insert data into */
|
||||
if (oht->size >= oht->capa.soft) return QSE_OHT_INVALID_INDEX;
|
||||
if (oht->size >= oht->capa.soft) return QSE_OHT_NIL;
|
||||
|
||||
/* get the unoccupied slot and insert the data into it.
|
||||
* iterate at most 'the number of items (oht->size)' times + 1. */
|
||||
@ -213,7 +213,7 @@ qse_size_t qse_oht_upsert (qse_oht_t* oht, const void* data)
|
||||
}
|
||||
}
|
||||
|
||||
return QSE_OHT_INVALID_INDEX;
|
||||
return QSE_OHT_NIL;
|
||||
}
|
||||
|
||||
qse_size_t qse_oht_insert (qse_oht_t* oht, const void* data)
|
||||
@ -221,13 +221,13 @@ qse_size_t qse_oht_insert (qse_oht_t* oht, const void* data)
|
||||
qse_size_t i, hash;
|
||||
|
||||
/* check if there is a free slot to insert data into */
|
||||
if (oht->size >= oht->capa.soft) return QSE_OHT_INVALID_INDEX;
|
||||
if (oht->size >= oht->capa.soft) return QSE_OHT_NIL;
|
||||
|
||||
hash = HASH_DATA (oht, data);
|
||||
|
||||
/* check if the item already exits */
|
||||
i = search (oht, data, hash);
|
||||
if (i != QSE_OHT_INVALID_INDEX) return QSE_OHT_INVALID_INDEX;
|
||||
if (i != QSE_OHT_NIL) return QSE_OHT_NIL;
|
||||
|
||||
/* get the unoccupied slot and insert the data into it.
|
||||
* iterate at most 'the number of items (oht->size)' times + 1. */
|
||||
@ -243,7 +243,7 @@ qse_size_t qse_oht_insert (qse_oht_t* oht, const void* data)
|
||||
}
|
||||
}
|
||||
|
||||
return QSE_OHT_INVALID_INDEX;
|
||||
return QSE_OHT_NIL;
|
||||
}
|
||||
|
||||
qse_size_t qse_oht_delete (qse_oht_t* oht, const void* data)
|
||||
@ -251,10 +251,10 @@ qse_size_t qse_oht_delete (qse_oht_t* oht, const void* data)
|
||||
#if 0
|
||||
qse_size_t index;
|
||||
|
||||
if (oht->size <= 0) return QSE_OHT_INVALID_INDEX;
|
||||
if (oht->size <= 0) return QSE_OHT_NIL;
|
||||
|
||||
index = search (oht, data, HASH_DATA(oht,data));
|
||||
if (index != QSE_OHT_INVALID_INDEX)
|
||||
if (index != QSE_OHT_NIL)
|
||||
{
|
||||
oht->mark[index] = QSE_OHT_DELETED;
|
||||
oht->size--;
|
||||
@ -266,11 +266,11 @@ qse_size_t qse_oht_delete (qse_oht_t* oht, const void* data)
|
||||
qse_size_t index, i, x, y, z;
|
||||
|
||||
/* check if the oht is empty. if so, do nothing */
|
||||
if (oht->size <= 0) return QSE_OHT_INVALID_INDEX;
|
||||
if (oht->size <= 0) return QSE_OHT_NIL;
|
||||
|
||||
/* check if the item exists. otherwise, do nothing. */
|
||||
index = search (oht, data, HASH_DATA(oht,data));
|
||||
if (index == QSE_OHT_INVALID_INDEX) return QSE_OHT_INVALID_INDEX;
|
||||
if (index == QSE_OHT_NIL) return QSE_OHT_NIL;
|
||||
|
||||
/* compact the cluster */
|
||||
for (i = 0, x = index, y = index; i < oht->size; i++)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: tio.c 348 2010-08-26 06:26:28Z hyunghwan.chung $
|
||||
* $Id: tio.c 356 2010-09-07 12:29:25Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -89,7 +89,7 @@ int qse_tio_fini (qse_tio_t* tio)
|
||||
return 0;
|
||||
}
|
||||
|
||||
qse_tio_err_t qse_tio_geterrnum (qse_tio_t* tio)
|
||||
qse_tio_errnum_t qse_tio_geterrnum (qse_tio_t* tio)
|
||||
{
|
||||
return tio->errnum;
|
||||
}
|
||||
|
@ -31,13 +31,13 @@ static qse_oht_walk_t walk2 (qse_oht_t* oht, void* data, void* ctx)
|
||||
return QSE_OHT_WALK_FORWARD;
|
||||
}
|
||||
|
||||
static qse_size_t hash (qse_oht_t* oht, void* data)
|
||||
static qse_size_t hash (qse_oht_t* oht, const void* data)
|
||||
{
|
||||
item_t* item = (item_t*)data;
|
||||
return item->a;
|
||||
return item->a + 123445;
|
||||
}
|
||||
|
||||
static int comp (qse_oht_t* oht, void* data1, void* data2)
|
||||
static int comp (qse_oht_t* oht, const void* data1, const void* data2)
|
||||
{
|
||||
return ((item_t*)data1)->a != ((item_t*)data2)->a;
|
||||
}
|
||||
@ -73,6 +73,7 @@ static int test1 ()
|
||||
x, (unsigned long)qse_oht_search (oht, &x));
|
||||
|
||||
|
||||
qse_printf (QSE_T("total %lu items\n"), (unsigned long)QSE_OHT_SIZE(oht));
|
||||
qse_oht_walk (oht, walk1, QSE_NULL);
|
||||
qse_oht_close (oht);
|
||||
return 0;
|
||||
@ -83,7 +84,7 @@ static int test2 ()
|
||||
item_t x;
|
||||
qse_oht_t* oht;
|
||||
|
||||
oht = qse_oht_open (QSE_NULL, 0, QSE_SIZEOF(x), 10, 5);
|
||||
oht = qse_oht_open (QSE_NULL, 0, QSE_SIZEOF(x), 10, 10);
|
||||
if (oht == QSE_NULL)
|
||||
{
|
||||
qse_printf (QSE_T("failed to open a table\n"));
|
||||
@ -114,6 +115,7 @@ static int test2 ()
|
||||
x.a, (unsigned long)qse_oht_search (oht, &x));
|
||||
|
||||
|
||||
qse_printf (QSE_T("total %lu items\n"), (unsigned long)QSE_OHT_SIZE(oht));
|
||||
qse_oht_walk (oht, walk2, QSE_NULL);
|
||||
qse_oht_close (oht);
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user