QObject *qdict_get(const QDict *qdict, const char *key) { QDictEntry *entry; entry = qdict_find(qdict, key, tdb_hash(key) % QDICT_HASH_SIZE); return (entry == NULL ? NULL : entry->value); }
void qdict_del(QDict *qdict, const char *key) { QDictEntry *entry; entry = qdict_find(qdict, key, tdb_hash(key) % QDICT_HASH_SIZE); if (entry) { QLIST_REMOVE(entry, next); qentry_destroy(entry); qdict->size--; } }
void qdict_put_obj(QDict *qdict, const char *key, QObject *value) { unsigned int hash; QDictEntry *entry; hash = tdb_hash(key) % QDICT_HASH_SIZE; entry = qdict_find(qdict, key, hash); if (entry) { /* replace key's value */ qobject_decref(entry->value); entry->value = value; } else { /* allocate a new entry */ entry = alloc_entry(key, value); QLIST_INSERT_HEAD(&qdict->table[hash], entry, next); qdict->size++; } }
int qdict_haskey(const QDict *qdict, const char *key) { unsigned int hash = tdb_hash(key) % QDICT_HASH_SIZE; return (qdict_find(qdict, key, hash) == NULL ? 0 : 1); }
/** * qdict_haskey(): Check if 'key' exists * * Return 1 if 'key' exists in the dict, 0 otherwise */ int qdict_haskey(const QDict *qdict, const char *key) { unsigned int bucket = tdb_hash(key) % QDICT_BUCKET_MAX; return (qdict_find(qdict, key, bucket) == NULL ? 0 : 1); }