Complex two dimensional array and reference pointers - very difficult problem

Discussion in 'Java' started by news.amnet.net.au, Apr 8, 2004.

  1. 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
    news.amnet.net.au, Apr 8, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alf P. Steinbach
    Replies:
    0
    Views:
    435
    Alf P. Steinbach
    Aug 18, 2003
  2. John Harrison
    Replies:
    4
    Views:
    6,923
    Default User
    Aug 19, 2003
  3. Icosahedron
    Replies:
    8
    Views:
    653
    Vivek
    Aug 21, 2003
  4. Venkat
    Replies:
    4
    Views:
    972
    Venkat
    Dec 5, 2003
  5. Peter Olcott
    Replies:
    9
    Views:
    333
    Axter
    Nov 28, 2005
Loading...

Share This Page