[fpc-pascal] Re: Dynamic array and dimensions

ik idokan at gmail.com
Wed Feb 8 22:20:10 CET 2012


Let me explain better my problem.

Originally the protocol states that the data that I should get is:

      1) "CONFIG"
      2) "SET"
      3) "slowlog-log-slower-than"
      4) "1"

Now I wrote a function that on linear time add each element to a dynamic
array,
so the parsing itself also will be linear, and simple, rather then a
complex one.

However, I found a command that return undocumented result of:

1) 1) (integer) 0
   2) (integer) 1328734844
   3) (integer) 14
   4) 1) "CONFIG"
      2) "SET"
      3) "slowlog-log-slower-than"
      4) "1"


The most left 1), is a list containing inside another list. The second list
have element of 4)  that contain additional list of another 4 elements.
I need to rewrite the original function to be able to store this
information. I must save the exact order of things, and also save the
hierarchy
that is displayed here.

I'm looking not only for an elegant solution (I can think on at least 3
ways), but also for an efficient way, and little as
possible in memory consumption (I don't have idea how to do that), and if I
can do it in O(n) or better, then it's perfect.

How would you recommend me to solve this ?

Thanks,
Ido

On Wed, Feb 8, 2012 at 17:25, ik <idokan at gmail.com> wrote:

> Hello,
>
> I need to rewrite the way I split data today, after I found out that the
> specs and the reality of the content are different things.
> At the moment I'm using a dynamic array of single dimension to store each
> element of a list, however the actual data can arrive as a list inside a
> list.
> Can I use dynamic array that is defined like so:
>
> Array of String
>
> As Multi-dimension array, and if I can' how can I figure out how much
> dimension it has ?
>
> If not, is there a non balanced tree class that I can use instead to store
> information instead ?
>
> Thanks,
> Ido
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20120208/390043e0/attachment.html>


More information about the fpc-pascal mailing list