aijazasoomro
January 23rd, 2009, 07:19 AM
Dear all,
I am developing a Parser for xml ( a compiler in simple words).
You might know how the compiler is developed….
There are six phases, like Lexical Analysis, Syntax/Syntactic Analysis , Semantic Analysis, etc.
To implement the Lexical Phase we need to divide the source code ( Source code means stream of characters) into token.
Source code example :
“<book> C++</book>” (may be taken from a text box)
Tokens: Book as valid identifier, < Lessthan a separate token, / as separate token ….
For doing this suppose String s=”<book> C++</book>”
It means every character of the String s should be separately processed as character array.
for creating a character array I could do this like
Char c [1000] = s.tocharArray();
Over here what I have done I have created a character array c of size 1000, it means I will be able to process 1000 characters , but if I will need to process 10000000000 characters then definitely I must need to create a character array of size 10000000000 in advance.
But it is not necessary that After creating such a big size of character array I may only use few hundred characters.
To overcome the problem of this wastage of unused memory, I definitely need some automatic resizable arrays.
Now for doing this I can do this by Creating an ArrayList in visual c++.
Now the problem is that I need to create not only one ArrayList , but I need to create many ArrayList instead of many static arrays.
Problem expectation: since on addition of new element into ArrayList possibly the ArrayList object will be resizing the internal Array Structure.
My Question: Which technique will be Better
Either to create big static array Vs automatic resizing of Arraylist??
The static array will take fixed huge memory , while Arraylist can have resizing overhead when every time item is added.
I have used the ArrayList , but I want to confirm that can I be suffered from the ArrayList automatic resizing , or the big static ArrayCreation will take more memory /computational resources.
I hope you must have understood what I want to know, If you are still not clear then I can explain more here, or can call you easily any where in the world, or by voice conversations on messenger.
Waiting for your kind cooperation, if you really have such type of vision to answer my question.
Regards
Aijaz Soomro
aijazasoomro@hotmail.com
aijazasoomro@yahoo.com
I am developing a Parser for xml ( a compiler in simple words).
You might know how the compiler is developed….
There are six phases, like Lexical Analysis, Syntax/Syntactic Analysis , Semantic Analysis, etc.
To implement the Lexical Phase we need to divide the source code ( Source code means stream of characters) into token.
Source code example :
“<book> C++</book>” (may be taken from a text box)
Tokens: Book as valid identifier, < Lessthan a separate token, / as separate token ….
For doing this suppose String s=”<book> C++</book>”
It means every character of the String s should be separately processed as character array.
for creating a character array I could do this like
Char c [1000] = s.tocharArray();
Over here what I have done I have created a character array c of size 1000, it means I will be able to process 1000 characters , but if I will need to process 10000000000 characters then definitely I must need to create a character array of size 10000000000 in advance.
But it is not necessary that After creating such a big size of character array I may only use few hundred characters.
To overcome the problem of this wastage of unused memory, I definitely need some automatic resizable arrays.
Now for doing this I can do this by Creating an ArrayList in visual c++.
Now the problem is that I need to create not only one ArrayList , but I need to create many ArrayList instead of many static arrays.
Problem expectation: since on addition of new element into ArrayList possibly the ArrayList object will be resizing the internal Array Structure.
My Question: Which technique will be Better
Either to create big static array Vs automatic resizing of Arraylist??
The static array will take fixed huge memory , while Arraylist can have resizing overhead when every time item is added.
I have used the ArrayList , but I want to confirm that can I be suffered from the ArrayList automatic resizing , or the big static ArrayCreation will take more memory /computational resources.
I hope you must have understood what I want to know, If you are still not clear then I can explain more here, or can call you easily any where in the world, or by voice conversations on messenger.
Waiting for your kind cooperation, if you really have such type of vision to answer my question.
Regards
Aijaz Soomro
aijazasoomro@hotmail.com
aijazasoomro@yahoo.com