Complex two dimensional array and reference pointers - very difficult problem

  • Thread starter news.amnet.net.au
  • Start date
N

news.amnet.net.au

Hi

I am struggling with a complex problem and I don't seem to get out of it.

I have a series of values I am getting from an Oracle table. Let's call some
of them "left values" (from the left column) and other "right values" (from
the right column). For every left value, the table finds one or more (most
likely more) right values. After this has been done, each right value
becomes the left value, for which then more right values are found.

The left values should go into the first dimension of my 2D array, the right
values in the second dimension.

So if I do a query for left value A and find right values B,C and D then my
array will contain:

myArray[A]
myArray[A][C]
myArray[A][D]

However, in the second query to my table, B becomes the "left value" so that
then I will need to put B in my the first dimension of my array. Suppose B
finds the following right values: E and F, I have to place the following
values into my array:

myArray[E]
myArray[F]

Then on for C -> finds right values G, H and I:

myArray[C][G]
myArray[C][H]
myArray[C]

and so on...

I am not sure what kind of complex loop I have to create to make this
happen. Any help with this will be greatly appreciated. The other problem is
that I do not know in advance how many values there will be, so an ArrayList
may be better than an Array. However, I can find no information on 2
dimensional ArrayLists - how are they initialized and declared?

However, there is an added complication: I need to preserve the left ->
right relationships for future use so that I can display the array values in
a web page in such a way that it is clear that A has rightward relationships
to B, C and D, B has rightward relationships to E and F etc.

So if the relationships are indicated by identical numbers I need something
like this:


myArray[A] 1
myArray[A][C] 1
myArray[A][D] 1

myArray[E] 2
myArray[F] 2

etc..

However the number should be individually associated with the left value AND
with the right values, so that if I display the value of myArray[A] once
only i.e.

A

then the values for the right relationships:

B
C
D

I should have a reference pointer in each dimension i.e.

A -> ref 1

then the values for the right relationships:

B -> ref 1
C -> ref 1
D -> ref 1

(otherwise I will have to always display the linked values together).

So I need some sort of a hash table to be incorporated into the 2
dimensional array.

A tall order, but perhaps there is someone out there who has experience with
this?

Any help will be greatly appreciated.

Thanks very much

Hugo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top