| Package | de.polygonal.ds |
| Class | public class Array2 |
| Inheritance | Array2 Object |
| Implements | Collection |
| Property | Defined By | ||
|---|---|---|---|
| celled : int [read-only]
| Array2 | ||
| height : int
Indicates the height (rows). | Array2 | ||
| size : int [read-only]
The total number of items. | Array2 | ||
| width : int
Indicates the width (colums). | Array2 | ||
| Method | Defined By | ||
|---|---|---|---|
Array2(w:int, h:int)
Initializes a two-dimensional array to match a given width and
height. | Array2 | ||
appendCol(a:Array):void
Appends a new column. | Array2 | ||
appendRow(a:Array):void
Appends a new row. | Array2 | ||
clear():void
Clears all items. | Array2 | ||
contains(obj:*):Boolean
Determines if the collection contains a given item. | Array2 | ||
dump():String
Prints out all elements (for debug/demo purposes). | Array2 | ||
fill(obj:*):void
Writes a given value into each cell of the two-dimensional array. | Array2 | ||
getArray():Array
Grants access to the the linear array which is used internally to
store the data in the two-dimensional array. | Array2 | ||
getCol(x:int):Array
Extracts a column from a given index. | Array2 | ||
Initializes an iterator object pointing to the first item in the
collection. | Array2 | ||
getRow(y:int):Array
Extracts a row from a given index. | Array2 | ||
gett(x:int, y:int):*
Reads a value from a given x/y index. | Array2 | ||
isEmpty():Boolean
Checks if the collection is empty. | Array2 | ||
prependCol(a:Array):void
Prepends a new column. | Array2 | ||
prependRow(a:Array):void
Prepends a new row. | Array2 | ||
resize(w:int, h:int):void
Resizes the array to match the given width and height. | Array2 | ||
setCol(x:int, a:Array):void
Inserts new values into a complete column of the two-dimensional
array. | Array2 | ||
setRow(y:uint, a:Array):void
Inserts new values into a complete row of the two-dimensional array. | Array2 | ||
sett(x:int, y:int, obj:*):void
Writes a value into a cell at the given x/y index. | Array2 | ||
setXs(y:int, objs:Array):void
Writes values horiztontally. | Array2 | ||
setYs(x:int, objs:Array):void
Writes values vertically. | Array2 | ||
shiftDown():void
Shifts all rows down by one row. | Array2 | ||
shiftLeft():void
Shifts all columns by one column to the left. | Array2 | ||
shiftRight():void
Shifts all columns by one column to the right. | Array2 | ||
shiftUp():void
Shifts all rows up by one row. | Array2 | ||
toArray():Array
Converts the collection into an array. | Array2 | ||
toString():String
Prints out a string representing the current object. | Array2 | ||
transpose():void
Flips rows with cols and vice versa. | Array2 | ||
| celled | property |
celled:int [read-only]
public function get celled():int| height | property |
height:intIndicates the height (rows). If a new height is set, the two-dimensional array is resized accordingly. The minimum value is 2.
public function get height():int public function set height(value:int):void| size | property |
size:int [read-only] The total number of items.
public function get size():int| width | property |
width:intIndicates the width (colums). If a new width is set, the two-dimensional array is resized accordingly. The minimum value is 2.
public function get width():int public function set width(value:int):void| Array2 | () | Constructor |
public function Array2(w:int, h:int)Initializes a two-dimensional array to match a given width and height. The smallest possible size is a 1x1 matrix. The initial value of all elements is null.
Parametersw:int — The width (equals number of colums).
| |
h:int — The height (equals number of rows).
|
| appendCol | () | method |
public function appendCol(a:Array):voidAppends a new column. If the new column doesn't match the current height, the inserted column gets truncated or widened to match the existing height.
Parameters
a:Array — The column to append.
|
| appendRow | () | method |
public function appendRow(a:Array):voidAppends a new row. If the new row doesn't match the current width, the inserted row gets truncated or widened to match the existing width.
Parameters
a:Array — The row to append.
|
| clear | () | method |
public function clear():voidClears all items.
| contains | () | method |
public function contains(obj:*):BooleanDetermines if the collection contains a given item.
Parameters
obj:* — The item to search for.
|
Boolean — True if the item exists, otherwise false.
|
| dump | () | method |
public function dump():StringPrints out all elements (for debug/demo purposes).
ReturnsString — A human-readable representation of the structure.
|
| fill | () | method |
public function fill(obj:*):voidWrites a given value into each cell of the two-dimensional array. If the obj parameter if of type Class, the method creates individual instances of this class for all array cells.
Parameters
obj:* — The item to be written into each cell.
|
| getArray | () | method |
public function getArray():ArrayGrants access to the the linear array which is used internally to store the data in the two-dimensional array. Use with care for advanced operations.
ReturnsArray |
| getCol | () | method |
public function getCol(x:int):ArrayExtracts a column from a given index.
Parameters
x:int — The column index.
|
Array — An array storing the values of the column.
|
| getIterator | () | method |
public function getIterator():IteratorInitializes an iterator object pointing to the first item in the collection.
ReturnsIterator — An iterator object.
|
| getRow | () | method |
public function getRow(y:int):ArrayExtracts a row from a given index.
Parameters
y:int — The row index.
|
Array — An array storing the values of the row.
|
| gett | () | method |
public function gett(x:int, y:int):*Reads a value from a given x/y index. No boundary check is done, so you have to make sure that the input coordinates do not exceed the width or height of the two-dimensional array.
Parameters
x:int — The x index (column).
| |
y:int — The y index (row).
|
* — The value at the given x/y index.
|
| isEmpty | () | method |
public function isEmpty():BooleanChecks if the collection is empty.
ReturnsBoolean — True if empty, otherwise false.
|
| prependCol | () | method |
public function prependCol(a:Array):voidPrepends a new column. If the new column doesn't match the current height, the inserted column gets truncated or widened to match the existing height.
Parameters
a:Array — The column to prepend.
|
| prependRow | () | method |
public function prependRow(a:Array):voidPrepends a new row. If the new row doesn't match the current width, the inserted row gets truncated or widened to match the existing width.
Parameters
a:Array — The row to prepend.
|
| resize | () | method |
public function resize(w:int, h:int):voidResizes the array to match the given width and height. If the new size is smaller than the existing size, values are lost because of truncation, otherwise all values are preserved. The minimum size is a 1x1 matrix.
Parameters
w:int — The new width (cols).
| |
h:int — The new height (rows).
|
| setCol | () | method |
public function setCol(x:int, a:Array):voidInserts new values into a complete column of the two-dimensional array. The new column is truncated if it exceeds the existing height.
Parameters
x:int — The column index.
| |
a:Array — The column's new values.
|
| setRow | () | method |
public function setRow(y:uint, a:Array):voidInserts new values into a complete row of the two-dimensional array. The new row is truncated if it exceeds the existing width.
Parameters
y:uint — The row index.
| |
a:Array — The row's new values.
|
| sett | () | method |
public function sett(x:int, y:int, obj:*):voidWrites a value into a cell at the given x/y index. Because of performance reasons no boundary check is done, so you have to make sure that the input coordinates do not exceed the width or height of the two-dimensional array.
Parameters
x:int — The x index (column).
| |
y:int — The y index (row).
| |
obj:* — The item to be written into the cell.
|
| setXs | () | method |
public function setXs(y:int, objs:Array):voidWrites values horiztontally.
Parameters
y:int — The y index (row).
| |
objs:Array — The items to be writtten into the cell.
|
| setYs | () | method |
public function setYs(x:int, objs:Array):voidWrites values vertically.
Parameters
x:int — x index (column).
| |
objs:Array — The items to be writtten into the cell.
|
| shiftDown | () | method |
public function shiftDown():voidShifts all rows down by one row. Rows are wrapped, so the last row is not lost but appended to the topmost row.
| shiftLeft | () | method |
public function shiftLeft():voidShifts all columns by one column to the left. Columns are wrapped, so the column at index 0 is not lost but appended to the rightmost column.
| shiftRight | () | method |
public function shiftRight():voidShifts all columns by one column to the right. Columns are wrapped, so the column at the last index is not lost but appended to the leftmost column.
| shiftUp | () | method |
public function shiftUp():voidShifts all rows up by one row. Rows are wrapped, so the first row is not lost but appended to bottommost row.
| toArray | () | method |
public function toArray():ArrayConverts the collection into an array.
ReturnsArray — An array.
|
| toString | () | method |
public function toString():StringPrints out a string representing the current object.
ReturnsString — A string representing the current object.
|
| transpose | () | method |
public function transpose():voidFlips rows with cols and vice versa.