added qse_htl_yanknode(), qse_htl_upyank().

added qse_raddic_deletevendorbyname(), qse_raddic_deletevendorbyid()
This commit is contained in:
2017-12-11 08:48:06 +00:00
parent 4266d8026c
commit c9bbd3c993
5 changed files with 267 additions and 45 deletions

View File

@ -197,10 +197,10 @@ static QSE_INLINE void qse_htl_setcopier (qse_htl_t* htl, qse_htl_copier_t _copi
/**
* The qse_htl_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.
* matching item. It returns the index to the slot of an internal array
* where the matching item is found.
* \return slot index if a match if found,
* #QSE_HTL_NIL if no match is found.
* #QSE_NULL if no match is found.
*/
QSE_EXPORT qse_htl_node_t* qse_htl_search (
qse_htl_t* htl, /**< hash table */
@ -215,10 +215,9 @@ QSE_EXPORT qse_htl_node_t* qse_htl_heterosearch (
);
/**
* The qse_htl_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_HTL_NIL on failure.
* The qse_htl_insert() function inserts a new item. It fails if it finds
* an existing item.
* \return a node pointer on success, #QSE_NULL on failure.
*/
QSE_EXPORT qse_htl_node_t* qse_htl_insert (
qse_htl_t* htl, /**< hash table */
@ -226,9 +225,9 @@ QSE_EXPORT qse_htl_node_t* qse_htl_insert (
);
/**
* The qse_htl_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.
* The qse_htl_upsert() function inserts a new item if it finds no matching
* item or updates an exsting item if finds a matching item.
* \return node pointer on success, #QSE_NULL on failure.
*/
QSE_EXPORT qse_htl_node_t* qse_htl_upsert (
qse_htl_t* htl, /**< hash table */
@ -236,16 +235,25 @@ QSE_EXPORT qse_htl_node_t* qse_htl_upsert (
);
/**
* The qse_htl_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_HTL_NIL on failure.
* The qse_htl_update() function updates an existing item. It fails if it finds
* no existing item.
* \return a node pointer on success, #QSE_NULL on failure.
*/
QSE_EXPORT qse_htl_node_t* qse_htl_update (
qse_htl_t* htl, /**< hash table */
void* data /**< data pointer */
);
/**
* The qse_htl_upyank() function updates an existing dataum without disposing
* the old data.
*/
QSE_EXPORT qse_htl_node_t* qse_htl_upyank (
qse_htl_t* htl, /**< hash table */
void* data, /**< data pointer */
void** oldata /**< old data pointer */
);
/**
* The qse_htl_ensert() function inserts a new item if one is not found.
* It returns an existing item otherwise.
@ -256,8 +264,8 @@ QSE_EXPORT qse_htl_node_t* qse_htl_ensert (
);
/**
* The qse_htl_delete() function deletes an existing datum. It fails if it finds
* no existing datum.
* The qse_htl_delete() function deletes an existing item. It fails if it finds
* no existing item.
* \return 0 on success, -1 on failure
*/
QSE_EXPORT int qse_htl_delete (
@ -270,6 +278,11 @@ QSE_EXPORT void* qse_htl_yank (
void* data
);
QSE_EXPORT qse_htl_node_t* qse_htl_yanknode (
qse_htl_t* ht,
void* data
);
/**
* The qse_htl_clear() functions deletes all data items.
*/

View File

@ -76,21 +76,23 @@ typedef struct qse_raddic_attr_t qse_raddic_attr_t;
struct qse_raddic_value_t
{
int attr;
int value;
qse_char_t name[1];
int attr;
int value;
qse_char_t name[1];
};
typedef struct qse_raddic_value_t qse_raddic_value_t;
typedef struct qse_raddic_vendor_t qse_raddic_vendor_t;
struct qse_raddic_vendor_t
{
int vendorpec;
int type;
int length;
int flags;
qse_char_t name[1];
int vendorpec;
int type;
int length;
int flags;
qse_raddic_vendor_t* nextv; /* next vendor with same details except the name */
qse_char_t name[1];
};
typedef struct qse_raddic_vendor_t qse_raddic_vendor_t;
typedef struct qse_raddic_t qse_raddic_t;
@ -123,6 +125,16 @@ QSE_EXPORT qse_raddic_vendor_t* qse_raddic_addvendor (
int value
);
QSE_EXPORT int qse_raddic_deletevendorbyname (
qse_raddic_t* dic,
const qse_char_t* name
);
QSE_EXPORT int qse_raddic_deletevendorbyvalue (
qse_raddic_t* dic,
int value
);
#if defined(__cplusplus)
}
#endif