Map for Vectors

Discussion in 'Java' started by Marcelo, Jan 30, 2006.

  1. Marcelo

    Marcelo Guest

    Just a little question from a begginner,

    I would like to know if there is something like a "table" or a matrix of Vectors.

    I am actually looking for something similar of a "Vector of Vectors", does Java
    has a class that implements this?

    thanks a lot,

    Marcelo
     
    Marcelo, Jan 30, 2006
    #1
    1. Advertising

  2. Hi Marcelo,

    Marcelo wrote:
    > Just a little question from a begginner,
    >
    > I would like to know if there is something like a "table" or a matrix of
    > Vectors.
    >
    > I am actually looking for something similar of a "Vector of Vectors",
    > does Java has a class that implements this?


    Yes, nearly exactly that:

    List<List<MyContentType>> matrix=new ArrayList<List<MyContentType>>();

    You may encapsulate this in your own class.

    Ciao,
    Ingo
     
    Ingo R. Homann, Jan 30, 2006
    #2
    1. Advertising

  3. Marcelo

    Roedy Green Guest

    On Mon, 30 Jan 2006 11:24:08 +0100, Marcelo <>
    wrote, quoted or indirectly quoted someone who said :

    >I am actually looking for something similar of a "Vector of Vectors", does Java
    >has a class that implements this?


    You implement it literally with e Vector of Vectors, or more commonly
    ArrayList of ArrayLists.

    the generics to define the types get rather unwieldy.
    e.g.

    ArrayList<ArrayList<Dog>> matrix = new ArrayList< ArrayList<Dog>>(
    500);
    Now you must go and create the inner arraylists and within that the
    Dog objects.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Jan 30, 2006
    #3
    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. Juicer_X

    Re: Map of vectors how? <Long>

    Juicer_X, Nov 25, 2004, in forum: C++
    Replies:
    0
    Views:
    409
    Juicer_X
    Nov 25, 2004
  2. Dekker

    A map of varying vectors

    Dekker, Mar 21, 2006, in forum: C++
    Replies:
    1
    Views:
    287
  3. Replies:
    3
    Views:
    270
    Daniel T.
    Aug 15, 2006
  4. Replies:
    3
    Views:
    702
    Shadowman
    Mar 26, 2008
  5. Guest
    Replies:
    0
    Views:
    448
    Guest
    Sep 14, 2005
Loading...

Share This Page