Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Complex two dimensional array and reference pointers - very difficult problem

Reply
Thread Tools

Complex two dimensional array and reference pointers - very difficult problem

 
 
news.amnet.net.au
Guest
Posts: n/a
 
      04-08-2004
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][B]
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[B][E]
myArray[B][F]

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

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

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][B] 1
myArray[A][C] 1
myArray[A][D] 1

myArray[B][E] 2
myArray[B][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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
To convert a one dimensional array into a two dimensional array using C amrutha0303 Software 0 08-03-2010 10:02 PM
How do copy Strings from a single dimensional array to double dimensional array Venkat C++ 4 12-05-2003 09:23 AM
Re: Two dimensional pointers and Two dimensional arrays Icosahedron C++ 8 08-21-2003 05:15 AM
Re: Two dimensional pointers and Two dimensional arrays John Harrison C++ 4 08-19-2003 04:00 PM
Re: Two dimensional pointers and Two dimensional arrays Alf P. Steinbach C++ 0 08-18-2003 08:25 AM



Advertisments