dynamical dimensions

B

blabla

hey!
anybody any idea how it can be arranged to dynamically add dimensions to an array

this means i want to add an undefined (say n) number of dimensions to a boolean
e.g.
boolean[][][][][][].....[](n-times) = new boolean[1][1][1]....[1]

ok, i suppose its not possible?
anyway, i'ld like to implement a sort of factor analysation...

thanks,
brt
 
J

John Davison

blabla said:
hey!
anybody any idea how it can be arranged to dynamically add dimensions to an array

this means i want to add an undefined (say n) number of dimensions to a boolean
e.g.
boolean[][][][][][].....[](n-times) = new boolean[1][1][1]....[1]

ok, i suppose its not possible?
anyway, i'ld like to implement a sort of factor analysation...

thanks,
brt

Prepare for the OutOfMemoryError.

java.lang.reflect.Array.newInstance(
Class componentType,
int[] dimensions);

- john
 
R

Roedy Green

ok, i suppose its not possible?
anyway, i'ld like to implement a sort of factor analysation...

you can write DynaArray class that implements with a single vector and
takes arrays of indexs an parameters.

You do the multiplications to figure out where in the single vector to
look.

Watch out. Even tiny multidensional arrays can have huge numbers of
elements and you will run out of ram.
 
J

Jezuch

U¿ytkownik blabla napisa³:
this means i want to add an undefined (say n) number of dimensions to a boolean
e.g.
boolean[][][][][][].....[](n-times) = new boolean[1][1][1]....[1]

boolean[][][][][][][][] is on Object. So if you create Object[] and put all
boolean[][][][][][][][]'s in it, you'll have "virtual"
boolean[][][][][][][][][] :)
 
B

blabla

thanks a lot guys,
now i have to figure out, why i want to do this...;)

-always looking for problems-
 

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,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top