Home | History | Annotate | Download | only in libxml2

Lines Matching refs:table

55  * A single entry in the hash table
69 * The entire hash table
72 struct _xmlHashEntry *table;
86 xmlHashComputeKey(xmlHashTablePtr table, const xmlChar *name,
92 value = table->random_seed;
110 return (value % table->size);
114 xmlHashComputeQKey(xmlHashTablePtr table,
122 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));
193 table->random_seed = rand();
195 return(table);
197 xmlFree(table);
204 * @size: the size of the hash table
213 xmlHashTablePtr table;
215 table = xmlHashCreate(size);
216 if (table != NULL) {
217 table->dict = dict;
220 return(table);
225 * @table: the hash table
226 * @size: the new size of the hash table
228 * resize the hash table
233 xmlHashGrow(xmlHashTablePtr table, int size) {
242 if (table == NULL)
249 oldsize = table->size;
250 oldtable = table->table;
254 table->table = xmlMalloc(size * sizeof(xmlHashEntry));
255 if (table->table == NULL) {
256 table->table = oldtable;
259 memset(table->table, 0, size * sizeof(xmlHashEntry));
260 table->size = size;
264 the main table. So instead, we run through the array twice, first
271 key = xmlHashComputeKey(table, oldtable[i].name, oldtable[i].name2,
273 memcpy(&(table->table[key]), &(oldtable[i]), sizeof(xmlHashEntry));
274 table->table[key].next = NULL;
283 * put back the entry in the new table
286 key = xmlHashComputeKey(table, iter->name, iter->name2,
288 if (table->table[key].valid == 0) {
289 memcpy(&(table->table[key]), iter, sizeof(xmlHashEntry));
290 table->table[key].next = NULL;
293 iter->next = table->table[key].next;
294 table->table[key].next = iter;
317 * @table: the hash table
320 * Free the hash @table and its contents. The userdata is
324 xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f) {
331 if (table == NULL)
333 if (table->table) {
334 nbElems = table->nbElems;
335 for(i = 0; (i < table->size) && (nbElems > 0); i++) {
336 iter = &(table->table[i]);
344 if (table->dict == NULL) {
360 xmlFree(table->table);
362 if (table->dict)
363 xmlDictFree(table->dict);
364 xmlFree(table);
369 * @table: the hash table
373 * Add the @userdata to the hash @table. This can later be retrieved
379 xmlHashAddEntry(xmlHashTablePtr table, const xmlChar *name, void *userdata) {
380 return(xmlHashAddEntry3(table, name, NULL, NULL, userdata));
385 * @table: the hash table
390 * Add the @userdata to the hash @table. This can later be retrieved
396 xmlHashAddEntry2(xmlHashTablePtr table, const xmlChar *name,
398 return(xmlHashAddEntry3(table, name, name2, NULL, userdata));
403 * @table: the hash table
408 * Add the @userdata to the hash @table. This can later be retrieved
415 xmlHashUpdateEntry(xmlHashTablePtr table, const xmlChar *name,
417 return(xmlHashUpdateEntry3(table, name, NULL, NULL, userdata, f));
422 * @table: the hash table
428 * Add the @userdata to the hash @table. This can later be retrieved
435 xmlHashUpdateEntry2(xmlHashTablePtr table, const xmlChar *name,
438 return(xmlHashUpdateEntry3(table, name, name2, NULL, userdata, f));
443 * @table: the hash table
451 xmlHashLookup(xmlHashTablePtr table, const xmlChar *name) {
452 return(xmlHashLookup3(table, name, NULL, NULL));
457 * @table: the hash table
466 xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name,
468 return(xmlHashLookup3(table, name, name2, NULL));
473 * @table: the hash table
482 xmlHashQLookup(xmlHashTablePtr table, const xmlChar *prefix,
484 return(xmlHashQLookup3(table, prefix, name, NULL, NULL, NULL, NULL));
489 * @table: the hash table
500 xmlHashQLookup2(xmlHashTablePtr table, const xmlChar *prefix,
503 return(xmlHashQLookup3(table, prefix, name, prefix2, name2, NULL, NULL));
508 * @table: the hash table
514 * Add the @userdata to the hash @table. This can later be retrieved
521 xmlHashAddEntry3(xmlHashTablePtr table, const xmlChar *name,
528 if ((table == NULL) || (name == NULL))
534 if (table->dict) {
535 if (!xmlDictOwns(table->dict, name)) {
536 name = xmlDictLookup(table->dict, name, -1);
540 if ((name2 != NULL) && (!xmlDictOwns(table->dict, name2))) {
541 name2 = xmlDictLookup(table->dict, name2, -1);
545 if ((name3 != NULL) && (!xmlDictOwns(table->dict, name3))) {
546 name3 = xmlDictLookup(table->dict, name3, -1);
555 key = xmlHashComputeKey(table, name, name2, name3);
556 if (table->table[key].valid == 0) {
559 if (table->dict) {
560 for (insert = &(table->table[key]); insert->next != NULL;
573 for (insert = &(table->table[key]); insert->next != NULL;
589 entry = &(table->table[key]);
596 if (table->dict != NULL) {
613 table->nbElems++;
616 xmlHashGrow(table, MAX_HASH_LEN * table->size);
623 * @table: the hash table
630 * Add the @userdata to the hash @table. This can later be retrieved
637 table, const xmlChar *name,
644 if ((table == NULL) || name == NULL)
650 if (table->dict) {
651 if (!xmlDictOwns(table->dict, name)) {
652 name = xmlDictLookup(table->dict, name, -1);
656 if ((name2 != NULL) && (!xmlDictOwns(table->dict, name2))) {
657 name2 = xmlDictLookup(table->dict, name2, -1);
661 if ((name3 != NULL) && (!xmlDictOwns(table->dict, name3))) {
662 name3 = xmlDictLookup(table->dict, name3, -1);
671 key = xmlHashComputeKey(table, name, name2, name3);
672 if (table->table[key].valid == 0) {
675 if (table ->dict) {
676 for (insert = &(table->table[key]); insert->next != NULL;
696 for (insert = &(table->table[key]); insert->next != NULL;
719 entry = &(table->table[key]);
726 if (table->dict != NULL) {
738 table->nbElems++;
749 * @table: the hash table
759 xmlHashLookup3(xmlHashTablePtr table, const xmlChar *name,
764 if (table == NULL)
768 key = xmlHashComputeKey(table, name, name2, name3);
769 if (table->table[key].valid == 0)
771 if (table->dict) {
772 for (entry = &(table->table[key]); entry != NULL; entry = entry->next) {
779 for (entry = &(table->table[key]); entry != NULL; entry = entry->next) {
790 * @table: the hash table
803 xmlHashQLookup3(xmlHashTablePtr table,
810 if (table == NULL)
814 key = xmlHashComputeQKey(table, prefix, name, prefix2,
816 if (table->table[key].valid == 0)
818 for (entry = &(table->table[key]); entry != NULL; entry = entry->next) {
842 * @table: the hash table
846 * Scan the hash @table and applied @f to each value.
849 xmlHashScan(xmlHashTablePtr table, xmlHashScanner f, void *data) {
853 xmlHashScanFull (table, stubHashScannerFull, &stubdata);
858 * @table: the hash table
862 * Scan the hash @table and applied @f to each value.
865 xmlHashScanFull(xmlHashTablePtr table, xmlHashScannerFull f, void *data) {
870 if (table == NULL)
875 if (table->table) {
876 for(i = 0; i < table->size; i++) {
877 if (table->table[i].valid == 0)
879 iter = &(table->table[i]);
882 nb = table->nbElems;
886 if (nb != table->nbElems) {
887 /* table was modified by the callback, be careful */
888 if (iter == &(table->table[i])) {
889 if (table->table[i].valid == 0)
891 if (table->table[i].next != next)
892 iter = &(table->table[i]);
904 * @table: the hash table
911 * Scan the hash @table and applied @f to each value matching
916 xmlHashScan3(xmlHashTablePtr table, const xmlChar *name,
919 xmlHashScanFull3 (table, name, name2, name3,
925 * @table: the hash table
932 * Scan the hash @table and applied @f to each value matching
937 xmlHashScanFull3(xmlHashTablePtr table, const xmlChar *name,
944 if (table == NULL)
949 if (table->table) {
950 for(i = 0; i < table->size; i++) {
951 if (table->table[i].valid == 0)
953 iter = &(table->table[i]);
971 * @table: the hash table
974 * Scan the hash @table and applied @f to each value.
976 * Returns the new table or NULL in case of error.
979 xmlHashCopy(xmlHashTablePtr table, xmlHashCopier f) {
985 if (table == NULL)
990 ret = xmlHashCreate(table->size);
991 if (table->table) {
992 for(i = 0; i < table->size; i++) {
993 if (table->table[i].valid == 0)
995 iter = &(table->table[i]);
1004 ret->nbElems = table->nbElems;
1010 * @table: the hash table
1012 * Query the number of elements installed in the hash @table.
1014 * Returns the number of elements in the hash table or
1018 xmlHashSize(xmlHashTablePtr table) {
1019 if (table == NULL)
1021 return(table->nbElems);
1026 * @table: the hash table
1031 * it from the hash @table. Existing userdata for this tuple will be removed
1036 int xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name,
1038 return(xmlHashRemoveEntry3(table, name, NULL, NULL, f));
1043 * @table: the hash table
1049 * it from the hash @table. Existing userdata for this tuple will be removed
1055 xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name,
1057 return(xmlHashRemoveEntry3(table, name, name2, NULL, f));
1062 * @table: the hash table
1069 * it from the hash @table. Existing userdata for this tuple will be removed
1075 xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,
1081 if (table == NULL || name == NULL)
1084 key = xmlHashComputeKey(table, name, name2, name3);
1085 if (table->table[key].valid == 0) {
1088 for (entry = &(table->table[key]); entry != NULL; entry = entry->next) {
1095 if (table->dict == NULL) {
1111 memcpy(&(table->table[key]), entry, sizeof(xmlHashEntry));
1115 table->nbElems--;