[antlr-interest] C Runtime - list container suggestions
jimi at temporal-wave.com
Mon Aug 13 15:29:28 PDT 2007
This email reminds me that I need to fix that. I was going to change it
to use ANTLR3_VECTOR, but something prompted me not to do this and I
have to look at my notes as to why. The List was once of the first
structures I wrote, before I had decided that these things would
probably be useful for C grammar programmers in general, hence it only
did what I needed it to do for ANTLR, where such a sequence would not
I will implement a temporary fix, then look at changing to vectors,
which are faster than the hash table for this anyway. I think my doubts
were whether you should be able to delete an element from the list and
expect the keys to be preserved, or whether the key should be an
ordinal, in that you can delete list entry #1 as many times as there is
a list entry #1 left. I need to decide which it should be then implement
either a key field in the structure (so that it does not reuse the same
key in the hashtable), or change to vectors and make the key ordinal
(which is what I think a list means actually).
In the meantime, look at the vector, as this is more likely what you
want if you were using this sequence.
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Cameron Esfahani
Sent: Monday, August 13, 2007 3:18 PM
To: antlr-interest Interest
Subject: [antlr-interest] C Runtime - list container suggestions
I've noticed two problems with the antlr3List "class" in
- Nearly all of the routines take a "key" parameter: get, put, delete
and remove. But, the add routine doesn't return a key. After calling
add, there is no way to determine where in the list the element was put.
- The list uses the size of the hash as it's key. This is a problem if
elements are removed from the list. You will get hash collisions. In
my case, I did the following operations:
delete first add
delete second add
then the next add would return an error because it would hash to the
dirty at apple.com
"With or without religion, good people can behave well and bad people
can do evil; but for good people to do evil - that takes religion."
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the antlr-interest