[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[pdf-devel] Hash Module implementation
From: |
gerel |
Subject: |
[pdf-devel] Hash Module implementation |
Date: |
Wed, 16 Apr 2008 01:00:30 -0300 |
Well, I've finished the Hash Module implementation.
BTW, I prefered to use gl_list directly because otherwise I'd need to change the
List Module API or use both (gl_list and pdf_list) which was kind of
ugly. Anyway we may find a use for pdf_list_sorted_* in the future (I hope). :-)
It seems to work fine, Here is the integrated test I tried,
##
pdf_hash_t table;
int e1,e2,e3,e4, *pe;
char *key;
pdf_hash_iterator_t itr;
e1 = 1;
e2 = 2;
e3 = 3;
e4 = 4;
pdf_hash_create (NULL, NULL, &table);
pdf_hash_add (table, "00", &e1);
pdf_hash_add (table, "ac", &e2);
pdf_hash_add (table, "aa0", &e3);
pdf_hash_add (table, "02", &e4);
pdf_hash_iterator (table, &itr);
while (pdf_hash_iterator_next (&itr, &key) == PDF_OK)
{
pdf_hash_search (table, key, &pe);
printf ("key:%s - val:%d\n", key, *pe);
}
pdf_hash_iterator_free (&itr);
pdf_hash_remove (table, "aa0");
pdf_hash_search (table, "00", &pe);
printf (":: %d\n", *pe);
fail_if (pdf_hash_key_p (table, "00") != PDF_TRUE);
fail_if (pdf_hash_rename (table, "00", "pepe") != PDF_OK);
fail_if (pdf_hash_key_p (table, "00") != PDF_FALSE);
fail_if (pdf_hash_key_p (table, "pepe") != PDF_TRUE);
pdf_hash_iterator (table, &itr);
while (pdf_hash_iterator_next (&itr, &key) == PDF_OK)
{
pdf_hash_search (table, key, &pe);
printf ("key:%s - val:%d\n", key, *pe);
}
pdf_hash_iterator_free (&itr);
pdf_hash_search (table, "pepe", &pe);
printf (":: %d\n", *pe);
pdf_hash_destroy (&table);
###
Here is the output,
##
key:00 - val:1
key:02 - val:4
key:aa0 - val:3
key:ac - val:2
:: 1
key:02 - val:4
key:ac - val:2
key:pepe - val:1
:: 1
###
I'm now working on some simple API tests, I'll send the patches over the week.
cheers
-gerel
- [pdf-devel] Hash Module implementation,
gerel <=