Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-02

Dynamic array and dimensions

2 messages · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

ik

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

Reply by email

ik
to ik

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

ik wrote 20 lines
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

Reply by email