Shifting positions of values in arrays

I need to replicate some functionality in existing IDL (Interactive Data Language) code. This language has some very high level constructs for moving values in arrays. This statement:

shifted_array = shift(my_array, xshift, yshift)

shift all the values in my_array in the x direction by xshift and all the values in the y direction by yshift (and wraps the values around) and puts them in shifted_array.

How would I best implement this in Java? That is, do it row-by-row / column-by-column / element-element? If so, does anybody have such code already? If not, is there some 'higher-level' way to do this? or use some other data structure?

Message was edited by:

allelopath

[713 byte] By [allelopatha] at [2007-11-26 19:52:48]
# 1

Most of the functionality you describe is in

arraycopy(Object, int, Object, int, int) - Static method in class java.lang.System

Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination array.

You need to handle the wraparound.

ChuckBinga at 2007-7-9 22:44:00 > top of Java-index,Java Essentials,Java Programming...
# 2
Does arraycopy() work only on 1-dimensional arrays?
allelopatha at 2007-7-9 22:44:00 > top of Java-index,Java Essentials,Java Programming...
# 3
> Does arraycopy() work only on 1-dimensional arrays?In Java, all arrays are one-dimensional.
DrLaszloJamfa at 2007-7-9 22:44:00 > top of Java-index,Java Essentials,Java Programming...