fi.helsinki.cs.ohtu.mpeg2.util
Class ArrayRoller

java.lang.Object
  extended by fi.helsinki.cs.ohtu.mpeg2.util.ArrayRoller

public class ArrayRoller
extends java.lang.Object

Utility class for changing arrays from 2d -> 1d and 1d -> 2d.


Constructor Summary
private ArrayRoller()
          ArrayRoller constructor.
 
Method Summary
static int[] as1D(int[][] values)
          Changes 2d array to one dimensional array.
static int[][] as2D(int[] values, int height, int width)
          Changes one dimensional array to two dimensional array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayRoller

private ArrayRoller()
ArrayRoller constructor.

Method Detail

as2D

public static int[][] as2D(int[] values,
                           int height,
                           int width)
Changes one dimensional array to two dimensional array.

Parameters:
values - -> one dimensional array to be changed
height - -> length of column in resulting 2d array
width - -> length of row in resulting 2d array
Returns:
two dimensional array "as2D", wich contains all elements from "values" array. Element ordering is following: as2D[i][j] = values[i*(length of row) + j]

as1D

public static int[] as1D(int[][] values)
Changes 2d array to one dimensional array.

Parameters:
values - -> 2d array to be changed
Returns:
one dimensional array "as1D", wich contains all elements from "values" array. Element ordering is following: values[i][j] = as1D[i*(length of row) + j]