GODPAPER | All Packages | All Classes | Index | Frames No Frames |
Array3

Package | de.polygonal.ds
Class | public class Array3
Inheritance | Array3 Object
Implements | Collection

A three-dimensional array.

Public Properties

| Property | Defined By
--- | --- | ---
|  | depth : int Indicates the depth (layers). | Array3
|  | height : int Indicates the height (rows). | Array3
|  | size : int [read-only] The total number of items. | Array3
|  | width : int Indicates the width (columns). | Array3

Public Methods

| Method | Defined By
--- | --- | ---
|  | Array3(w:int, h:int, d:int) Initializes a three-dimensional array to match the given width, height and depth. | Array3
|  | clear():void Clears all items. | Array3
|  | contains(obj:*):Boolean Determines if the collection contains a given item. | Array3
|  | dump(z:int):String Prints out all elements (for debug/demo purposes). | Array3
|  | fill(obj:*):void Writes a given value into each cell of the three-dimensional array. | Array3
|  | get(x:int, y:int, z:int):* Reads a value from a given x/y/z index. | Array3
|  | getCol(z:int, x:int):Array Extracts a colum from a given index and depth (layer). | Array3
|  | getIterator():Iterator Initializes an iterator object pointing to the first item in the collection. | Array3
|  | getLayer(z:int):Array2 Copies the data from a given depth (layer) into a two-dimensional array. | Array3
|  | getPile(x:int, y:int):Array Extracts a pile going through the given x,y index. | Array3
|  | getRow(z:int, y:int):Array Extracts a row from a given y index and depth (layer). | Array3
|  | isEmpty():Boolean Checks if the collection is empty. | Array3
|  | resize(w:int, h:int, d:int):void Resizes the array to match the given width, height and depth. | Array3
|  | set(x:int, y:int, z:int, obj:*):void Writes a value into a cell at the given x/y/z index. | Array3
|  | setCol(z:int, x:int, a:Array):void Inserts new values into a complete column at a given depth into the three-dimensional array. | Array3
|  | setPile(x:int, y:int, a:Array):void Inserts new values into a complete pile of the three-dimensional array going through the given x, y index. | Array3
|  | setRow(z:int, y:int, a:Array):void Inserts new values into a complete row at a given depth into the three-dimensional array. | Array3
|  | toArray():Array Converts the collection into an array. | Array3
|  | toString():String Prints out a string representing the current object. | Array3

Property Detail

depth | property

`depth:int`

Indicates the depth (layers). If a new depth is set, the three-dimensional array is resized accordingly.

Implementation
`public function get depth():int`
`public function set depth(value:int):void`

height | property |

`height:int`

Indicates the height (rows). If a new height is set, the three-dimensional array is resized accordingly.

Implementation
`public function get height():int`
`public function set height(value:int):void`

size | property |

`size:int` [read-only]

The total number of items.

Implementation
`public function get size():int`

width | property |

`width:int`

Indicates the width (columns). If a new width is set, the three-dimensional array is resized accordingly.

Implementation
`public function get width():int`
`public function set width(value:int):void`
Constructor Detail

Array3 | () | Constructor

`public function Array3(w:int, h:int, d:int)`

Initializes a three-dimensional array to match the given width, height and depth. The smallest possible size is a 1x1x1 matrix. The initial value of all items is null.

Parameters

| `w:int` — The width (equals number of columns).
| `h:int` — The height (equals number of rows).
| `d:int` — The depth (equals number of layers).

Method Detail

clear | () | method

`public function clear():void`

Clears all items.

contains | () | method |

`public function contains(obj:*):Boolean`

Determines if the collection contains a given item.

Parameters

| `obj:*` — The item to search for.

Returns

| `Boolean` — True if the item exists, otherwise false.

dump | () | method |

`public function dump(z:int):String`

Prints out all elements (for debug/demo purposes).

Parameters

| `z:int` — The layer to dump.

Returns

| `String` — A human-readable representation of the structure.

fill | () | method |

`public function fill(obj:*):void`

Writes a given value into each cell of the three-dimensional array.

Parameters

| `obj:*` — The item to be written into each cell.

get | () | method |

`public function get(x:int, y:int, z:int):*`

Reads a value from a given x/y/z index. No boundary check is done, so you have to make sure that the input coordinates do not exceed the width, height or depth of the three-dimensional array.

Parameters

| `x:int` — The x index (column).
| `y:int` — The y index (row).
| `z:int` — The z index (layer).

Returns

| `*` — The value at the given x/y/z index.

getCol | () | method |

`public function getCol(z:int, x:int):Array`

Extracts a colum from a given index and depth (layer).

Parameters

| `z:int` — The layer containing the column.
| `x:int` — The column index.

Returns

| `Array` — An array storing the values of the column.

getIterator | () | method |

`public function getIterator():Iterator`

Initializes an iterator object pointing to the first item in the collection.

Returns

| `Iterator` — An iterator object.

getLayer | () | method |

`public function getLayer(z:int):Array2`

Copies the data from a given depth (layer) into a two-dimensional array.

Parameters

| `z:int` — The layer to extract.

Returns

| `Array2` — The layer's data.

getPile | () | method |

`public function getPile(x:int, y:int):Array`

Extracts a pile going through the given x,y index. The order is from bottom to top (lowest to highest layer).

Parameters

| `x:int` — The column index.
| `y:int` — The row index.

Returns

| `Array` — An array storing the values of the pile.

getRow | () | method |

`public function getRow(z:int, y:int):Array`

Extracts a row from a given y index and depth (layer).

Parameters

| `z:int` — The layer containing the row
| `y:int` — The row index.

Returns

| `Array` — An array storing the values of the row.

isEmpty | () | method |

`public function isEmpty():Boolean`

Checks if the collection is empty.

Returns

| `Boolean` — True if empty, otherwise false.

resize | () | method |

`public function resize(w:int, h:int, d:int):void`

Resizes the array to match the given width, height and depth. If the new size is smaller than the existing size, values are lost because of truncation, otherwise all values are preserved.

Parameters

| `w:int` — The new width (cols).
| `h:int` — The new height (rows).
| `d:int` — The new depth (layers).

set | () | method |

`public function set(x:int, y:int, z:int, obj:*):void`

Writes a value into a cell at the given x/y/z index. No boundary check is done, so you have to make sure that the input coordinates do not exceed the width, height or depth of the two-dimensional array.

Parameters

| `x:int` — The x index (column).
| `y:int` — The y index (row).
| `z:int` — The z index (layer).
| `obj:*` — The item to be written into the cell.

setCol | () | method |

`public function setCol(z:int, x:int, a:Array):void`

Inserts new values into a complete column at a given depth into the three-dimensional array. The new column is truncated if it exceeds the existing height.

Parameters

| `z:int` — The layer containing the existing column.
| `x:int` — The column index.
| `a:Array` — The column's new values.

setPile | () | method |

`public function setPile(x:int, y:int, a:Array):void`

Inserts new values into a complete pile of the three-dimensional array going through the given x, y index. The pile is truncated if it exceeds the existing depth.

Parameters

| `x:int` — The column index.
| `y:int` — The row index.
| `a:Array` — The pile's new values.

setRow | () | method |

`public function setRow(z:int, y:int, a:Array):void`

Inserts new values into a complete row at a given depth into the three-dimensional array. The new row is truncated if it exceeds the existing width.

Parameters

| `z:int` — The layer containing the existing row.
| `y:int` — The row index.
| `a:Array` — The row's new values.

toArray | () | method |

`public function toArray():Array`

Converts the collection into an array.

Returns

| `Array` — An array.

toString | () | method |

`public function toString():String`

Prints out a string representing the current object.

Returns

| `String` — A string representing the current object.

Thu Jan 16 2014, 01:11 PM +08:00