new tables
- Posted by Jiri Babor <jbabor at PARADISE.NET.NZ> Sep 07, 2002
- 399 views
Hi Everybody, This is mainly for the wise ones, who do not visit my pages at all - it's hardly worth it anyway. I have just posted a new version of associative lists, this time called, briefly and correctly, tables ;). The basic scheme is different from the 'parallel sequences' I used originally. It can be summarised as {val1, val2, ... valN, {key1, key2, ... keyN}} The speed is roughly the same as previously, except for 'appending' of new entries, which is slightly faster. The only real advantage of the new scheme is that it's more intuitive in situations, when the entry index is already known. Then the most common functions set() and fetch() that rely on relatively slow find() can be replaced by much faster simple assignments: table[i] = new_value and value = table[i] respectively, where 'i' is obviously the previously determined index. This simple library is quite good for small to medium sized tables. If your tables contain more than about 200 entries, you might be better off with sorted tables. For those I use a binary search, or alternatively, a 'hybrid' variant, which relies on a mixture of find() and binary search, depending on the size of the particular table. Just give me a yell, if you are *really* interested. jiri