Lines Matching refs:table
51 * A single entry in the hash table
65 * The entire hash table
68 struct _xmlHashEntry *table;
82 xmlHashComputeKey(xmlHashTablePtr table, const xmlChar *name,
88 value = table->random_seed;
108 return (value % table->size);
112 xmlHashComputeQKey(xmlHashTablePtr table,
120 value = table->random_seed;
162 return (value % table->size);
167 * @size: the size of the hash table
175 xmlHashTablePtr table;
180 table = xmlMalloc(sizeof(xmlHashTable));
181 if (table) {
182 table->dict = NULL;
183 table->size = size;
184 table->nbElems = 0;
185 table->table = xmlMalloc(size * sizeof(xmlHashEntry));
186 if (table->table) {
187 memset(table->table, 0, size * sizeof(xmlHashEntry));
189 table->random_seed = __xmlRandom();
191 return(table);
193 xmlFree(table);
200 * @size: the size of the hash table
209 xmlHashTablePtr table;
211 table = xmlHashCreate(size);
212 if (table != NULL) {
213 table->dict = dict;
216 return(table);
221 * @table: the hash table
222 * @size: the new size of the hash table
224 * resize the hash table
229 xmlHashGrow(xmlHashTablePtr table, int size) {
238 if (table == NULL)
245 oldsize = table->size;
246 oldtable = table->table;
250 table->table = xmlMalloc(size * sizeof(xmlHashEntry));
251 if (table->table == NULL) {
252 table->table = oldtable;
255 memset(table->table, 0, size * sizeof(xmlHashEntry));
256 table->size = size;
260 the main table. So instead, we run through the array twice, first
267 key = xmlHashComputeKey(table, oldtable[i].name, oldtable[i].name2,
269 memcpy(&(table->table[key]), &(oldtable[i]), sizeof(xmlHashEntry));
270 table->table[key].next = NULL;
279 * put back the entry in the new table
282 key = xmlHashComputeKey(table, iter->name, iter->name2,
284 if (table->table[key].valid == 0) {
285 memcpy(&(table->table[key]), iter, sizeof(xmlHashEntry));
286 table->table[key].next = NULL;
289 iter->next = table->table[key].next;
290 table->table[key].next = iter;
313 * @table: the hash table
316 * Free the hash @table and its contents. The userdata is
320 xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f) {
327 if (table == NULL)
329 if (table->table) {
330 nbElems = table->nbElems;
331 for(i = 0; (i < table->size) && (nbElems > 0); i++) {
332 iter = &(table->table[i]);
340 if (table->dict == NULL) {
356 xmlFree(table->table);
358 if (table->dict)
359 xmlDictFree(table->dict);
360 xmlFree(table);
365 * @table: the hash table
369 * Add the @userdata to the hash @table. This can later be retrieved
375 xmlHashAddEntry(xmlHashTablePtr table, const xmlChar *name, void *userdata) {
376 return(xmlHashAddEntry3(table, name, NULL, NULL, userdata));
381 * @table: the hash table
386 * Add the @userdata to the hash @table. This can later be retrieved
392 xmlHashAddEntry2(xmlHashTablePtr table, const xmlChar *name,
394 return(xmlHashAddEntry3(table, name, name2, NULL, userdata));
399 * @table: the hash table
404 * Add the @userdata to the hash @table. This can later be retrieved
411 xmlHashUpdateEntry(xmlHashTablePtr table, const xmlChar *name,
413 return(xmlHashUpdateEntry3(table, name, NULL, NULL, userdata, f));
418 * @table: the hash table
424 * Add the @userdata to the hash @table. This can later be retrieved
431 xmlHashUpdateEntry2(xmlHashTablePtr table, const xmlChar *name,
434 return(xmlHashUpdateEntry3(table, name, name2, NULL, userdata, f));
439 * @table: the hash table
447 xmlHashLookup(xmlHashTablePtr table, const xmlChar *name) {
448 return(xmlHashLookup3(table, name, NULL, NULL));
453 * @table: the hash table
462 xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name,
464 return(xmlHashLookup3(table, name, name2, NULL));
469 * @table: the hash table
478 xmlHashQLookup(xmlHashTablePtr table, const xmlChar *prefix,
480 return(xmlHashQLookup3(table, prefix, name, NULL, NULL, NULL, NULL));
485 * @table: the hash table
496 xmlHashQLookup2(xmlHashTablePtr table, const xmlChar *prefix,
499 return(xmlHashQLookup3(table, prefix, name, prefix2, name2, NULL, NULL));
504 * @table: the hash table
510 * Add the @userdata to the hash @table. This can later be retrieved
517 xmlHashAddEntry3(xmlHashTablePtr table, const xmlChar *name,
524 if ((table == NULL) || (name == NULL))
530 if (table->dict) {
531 if (!xmlDictOwns(table->dict, name)) {
532 name = xmlDictLookup(table->dict, name, -1);
536 if ((name2 != NULL) && (!xmlDictOwns(table->dict, name2))) {
537 name2 = xmlDictLookup(table->dict, name2, -1);
541 if ((name3 != NULL) && (!xmlDictOwns(table->dict, name3))) {
542 name3 = xmlDictLookup(table->dict, name3, -1);
551 key = xmlHashComputeKey(table, name, name2, name3);
552 if (table->table[key].valid == 0) {
555 if (table->dict) {
556 for (insert = &(table->table[key]); insert->next != NULL;
569 for (insert = &(table->table[key]); insert->next != NULL;
585 entry = &(table->table[key]);
592 if (table->dict != NULL) {
609 table->nbElems++;
612 xmlHashGrow(table, MAX_HASH_LEN * table->size);
619 * @table: the hash table
626 * Add the @userdata to the hash @table. This can later be retrieved
633 table, const xmlChar *name,
640 if ((table == NULL) || name == NULL)
646 if (table->dict) {
647 if (!xmlDictOwns(table->dict, name)) {
648 name = xmlDictLookup(table->dict, name, -1);
652 if ((name2 != NULL) && (!xmlDictOwns(table->dict, name2))) {
653 name2 = xmlDictLookup(table->dict, name2, -1);
657 if ((name3 != NULL) && (!xmlDictOwns(table->dict, name3))) {
658 name3 = xmlDictLookup(table->dict, name3, -1);
667 key = xmlHashComputeKey(table, name, name2, name3);
668 if (table->table[key].valid == 0) {
671 if (table ->dict) {
672 for (insert = &(table->table[key]); insert->next != NULL;
692 for (insert = &(table->table[key]); insert->next != NULL;
715 entry = &(table->table[key]);
722 if (table->dict != NULL) {
734 table->nbElems++;
745 * @table: the hash table
755 xmlHashLookup3(xmlHashTablePtr table, const xmlChar *name,
760 if (table == NULL)
764 key = xmlHashComputeKey(table, name, name2, name3);
765 if (table->table[key].valid == 0)
767 if (table->dict) {
768 for (entry = &(table->table[key]); entry != NULL; entry = entry->next) {
775 for (entry = &(table->table[key]); entry != NULL; entry = entry->next) {
786 * @table: the hash table
799 xmlHashQLookup3(xmlHashTablePtr table,
806 if (table == NULL)
810 key = xmlHashComputeQKey(table, prefix, name, prefix2,
812 if (table->table[key].valid == 0)
814 for (entry = &(table->table[key]); entry != NULL; entry = entry->next) {
838 * @table: the hash table
842 * Scan the hash @table and applied @f to each value.
845 xmlHashScan(xmlHashTablePtr table, xmlHashScanner f, void *data) {
849 xmlHashScanFull (table, stubHashScannerFull, &stubdata);
854 * @table: the hash table
858 * Scan the hash @table and applied @f to each value.
861 xmlHashScanFull(xmlHashTablePtr table, xmlHashScannerFull f, void *data) {
866 if (table == NULL)
871 if (table->table) {
872 for(i = 0; i < table->size; i++) {
873 if (table->table[i].valid == 0)
875 iter = &(table->table[i]);
878 nb = table->nbElems;
882 if (nb != table->nbElems) {
883 /* table was modified by the callback, be careful */
884 if (iter == &(table->table[i])) {
885 if (table->table[i].valid == 0)
887 if (table->table[i].next != next)
888 iter = &(table->table[i]);
900 * @table: the hash table
907 * Scan the hash @table and applied @f to each value matching
912 xmlHashScan3(xmlHashTablePtr table, const xmlChar *name,
915 xmlHashScanFull3 (table, name, name2, name3,
921 * @table: the hash table
928 * Scan the hash @table and applied @f to each value matching
933 xmlHashScanFull3(xmlHashTablePtr table, const xmlChar *name,
940 if (table == NULL)
945 if (table->table) {
946 for(i = 0; i < table->size; i++) {
947 if (table->table[i].valid == 0)
949 iter = &(table->table[i]);
967 * @table: the hash table
970 * Scan the hash @table and applied @f to each value.
972 * Returns the new table or NULL in case of error.
975 xmlHashCopy(xmlHashTablePtr table, xmlHashCopier f) {
981 if (table == NULL)
986 ret = xmlHashCreate(table->size);
987 if (table->table) {
988 for(i = 0; i < table->size; i++) {
989 if (table->table[i].valid == 0)
991 iter = &(table->table[i]);
1000 ret->nbElems = table->nbElems;
1006 * @table: the hash table
1008 * Query the number of elements installed in the hash @table.
1010 * Returns the number of elements in the hash table or
1014 xmlHashSize(xmlHashTablePtr table) {
1015 if (table == NULL)
1017 return(table->nbElems);
1022 * @table: the hash table
1027 * it from the hash @table. Existing userdata for this tuple will be removed
1032 int xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name,
1034 return(xmlHashRemoveEntry3(table, name, NULL, NULL, f));
1039 * @table: the hash table
1045 * it from the hash @table. Existing userdata for this tuple will be removed
1051 xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name,
1053 return(xmlHashRemoveEntry3(table, name, name2, NULL, f));
1058 * @table: the hash table
1065 * it from the hash @table. Existing userdata for this tuple will be removed
1071 xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,
1077 if (table == NULL || name == NULL)
1080 key = xmlHashComputeKey(table, name, name2, name3);
1081 if (table->table[key].valid == 0) {
1084 for (entry = &(table->table[key]); entry != NULL; entry = entry->next) {
1091 if (table->dict == NULL) {
1107 memcpy(&(table->table[key]), entry, sizeof(xmlHashEntry));
1111 table->nbElems--;