Immutable 2D-array. Optionally, has a clear value that is used to clear out array.
Type parameters
- T
-
Type of the array element.
Value parameters
- height
-
Height of the array. Must be >= 0.
- width
-
Width of the array. Must be >= 0.
Attributes
- Note
-
If clear value is not set, the default clear value is
null
. - Companion
- object
- Source
- CPArray2D.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
Value members
Constructors
Creates 1x1 array with a given single value.
Creates 1x1 array with a given single value.
Value parameters
- t
-
Value to set at [0,0] coordinate.
Attributes
- Source
- CPArray2D.scala
Creates w
xh
array with specified clear value.
Creates w
xh
array with specified clear value.
Value parameters
- clearVal
-
Clear value.
- h
-
Array height.
- w
-
Array width.
Attributes
- Source
- CPArray2D.scala
Creates array with specified dimension and clear value.
Creates array with specified dimension and clear value.
Value parameters
- clearVal
-
Clear value.
- dim
-
Array dimension.
Attributes
- Source
- CPArray2D.scala
Creates array with specified dimension.
Creates array with specified dimension.
Value parameters
- dim
-
Array dimension.
Attributes
- Source
- CPArray2D.scala
Concrete methods
Clears this array with the clear value.
Clears this array with the clear value.
Attributes
- Note
-
If the clear value is not set, the default value is
null
. - Source
- CPArray2D.scala
Clears this array with given clear value.
Gets i-th column for this 2D array.
Checks whether this array contains at least one element satisfying given predicate.
Checks whether this array contains at least one element satisfying given predicate.
Value parameters
- p
-
Predicate to test.
Attributes
- Source
- CPArray2D.scala
Gets a deep copy of this array.
Copies a given frame into another 2D array.
Copies a given frame into another 2D array.
Value parameters
- frame
-
A frame to copy.
- other
-
Another array to copy to.
Attributes
- Source
- CPArray2D.scala
Counts how many elements in this array satisfying given predicate.
Counts how many elements in this array satisfying given predicate.
Value parameters
- p
-
Predicate to test.
Attributes
- Source
- CPArray2D.scala
Compares the receiver object (this
) with the argument object (that
) for equivalence.
Compares the receiver object (this
) with the argument object (that
) for equivalence.
Any implementation of this method should be an equivalence relation:
- It is reflexive: for any instance
x
of typeAny
,x.equals(x)
should returntrue
. - It is symmetric: for any instances
x
andy
of typeAny
,x.equals(y)
should returntrue
if and only ify.equals(x)
returnstrue
. - It is transitive: for any instances
x
,y
, andz
of typeAny
ifx.equals(y)
returnstrue
andy.equals(z)
returnstrue
, thenx.equals(z)
should returntrue
.
If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is usually necessary to override hashCode
to ensure that objects which are "equal" (o1.equals(o2)
returns true
) hash to the same scala.Int. (o1.hashCode.equals(o2.hashCode)
).
Value parameters
- that
-
the object to compare against this object for equality.
Attributes
- Returns
-
true
if the receiver object is equivalent to the argument;false
otherwise. - Definition Classes
-
Any
- Source
- CPArray2D.scala
Extracts deep copy sub-array with given shape.
Extracts deep copy sub-array with given shape.
Value parameters
- rect
-
A shape to extract as a deep copy.
Attributes
- Returns
-
Deep copy sub-array with given shape.
- Source
- CPArray2D.scala
Creates copy of this array with flipped X and Y coordinates.
Collapses given array into a single value given the initial value and associative binary operation acting as an accumulator. Folding over the elements in this 2D array will be horizontal first. In other words, given the 2D array with the following coordinates:
Collapses given array into a single value given the initial value and associative binary operation acting as an accumulator. Folding over the elements in this 2D array will be horizontal first. In other words, given the 2D array with the following coordinates:
+-----------------+
|(0,0) (1,0) (2,0)|
|(0,1) (1,1) (2,1)|
|(0,2) (1,2) (2,2)|
+-----------------+
this method will iterate in the following order:
(0,0) (1,0) (2,0) (0,1) (1,1) (2,1) (0,2) (1,2) (2,2)
Value parameters
- op
-
Accumulating binary operation.
- z
-
Initial value.
Attributes
- Source
- CPArray2D.scala
Collapses given array into a single value given the initial value and associative binary operation acting as an accumulator. Folding over the elements in this 2D array will be vertical first. In other words, given the 2D array with the following coordinates:
Collapses given array into a single value given the initial value and associative binary operation acting as an accumulator. Folding over the elements in this 2D array will be vertical first. In other words, given the 2D array with the following coordinates:
+-----------------+
|(0,0) (1,0) (2,0)|
|(0,1) (1,1) (2,1)|
|(0,2) (1,2) (2,2)|
+-----------------+
this method will iterate in the following order:
(0,0) (0,1) (0,2) (1,0) (1,1) (1,2) (2,0) (2,1) (2,2)
Value parameters
- op
-
Accumulating binary operation.
- z
-
Initial value.
Attributes
- Source
- CPArray2D.scala
Calls given function for each array element.
Calls given function for each array element.
Value parameters
- f
-
Function to call for each element.
Attributes
- Source
- CPArray2D.scala
Gets array value for given XY-coordinate.
Gets array value for given XY-coordinate.
Value parameters
- x
-
X-coordinate.
- y
-
Y-coordinate.
Attributes
- Source
- CPArray2D.scala
Checks whether given XY-coordinate is valid for this array.
Checks whether given XY-coordinate is valid for this array.
Value parameters
- x
-
X-coordinate to check.
- y
-
Y-coordinate to check.
Attributes
- Source
- CPArray2D.scala
Calls given function for each array element. Iteration over the elements in this 2D array will be horizontal first. In other words, given the 2D array with the following coordinates:
Calls given function for each array element. Iteration over the elements in this 2D array will be horizontal first. In other words, given the 2D array with the following coordinates:
+-----------------+
|(0,0) (1,0) (2,0)|
|(0,1) (1,1) (2,1)|
|(0,2) (1,2) (2,2)|
+-----------------+
this method will iterate in the following order:
(0,0) (1,0) (2,0) (0,1) (1,1) (2,1) (0,2) (1,2) (2,2)
Value parameters
- f
-
Function to call for each element. The function takes value and its XY-coordinate in the array.
Attributes
- See also
- Source
- CPArray2D.scala
Calls given function for each array element. Iteration over the elements in this 2D array will be horizontal first. In other words, given the 2D array with the following coordinates:
Calls given function for each array element. Iteration over the elements in this 2D array will be horizontal first. In other words, given the 2D array with the following coordinates:
+-----------------+
|(0,0) (1,0) (2,0)|
|(0,1) (1,1) (2,1)|
|(0,2) (1,2) (2,2)|
+-----------------+
this method will iterate in the following order:
(0,0) (1,0) (2,0) (0,1) (1,1) (2,1) (0,2) (1,2) (2,2)
Value parameters
- f
-
Function to call for each element. The function takes value and its XY-coordinate in the array.
Attributes
- See also
- Source
- CPArray2D.scala
Calls given function for each array element. Iteration over the elements in this 2D array will be vertical first. In other words, given the 2D array with the following coordinates:
Calls given function for each array element. Iteration over the elements in this 2D array will be vertical first. In other words, given the 2D array with the following coordinates:
+-----------------+
|(0,0) (1,0) (2,0)|
|(0,1) (1,1) (2,1)|
|(0,2) (1,2) (2,2)|
+-----------------+
this method will iterate in the following order:
(0,0) (0,1) (0,2) (1,0) (1,1) (1,2) (2,0) (2,1) (2,2)
Value parameters
- f
-
Function to call for each element. The function takes value and its XY-coordinate in the array.
Attributes
- See also
- Source
- CPArray2D.scala
Maps this array to an array of different type.
Maps this array to an array of different type.
Type parameters
- B
-
Type of the new array.
Value parameters
- f
-
Mapping function.
Attributes
- Source
- CPArray2D.scala
Map this array using extended mapping function.
Map this array using extended mapping function.
Type parameters
- B
-
Type of the new array.
Value parameters
- f
-
Mapping function that takes value and its XY-coordinate in the array.
Attributes
- Source
- CPArray2D.scala
Gets i-th row for this 2D array.
Sets array value at a given XY-coordinate.
Sets array value at a given XY-coordinate.
Value parameters
- t
-
Value to set.
- x
-
X-coordinate.
- y
-
Y-coordinate.
Attributes
- Source
- CPArray2D.scala
Splits this array into num
evenly split sub-arrays.
Splits this array into num
evenly split sub-arrays.
Value parameters
- num
-
Number of sub-arrays to split into.
Attributes
- Returns
-
Sequence of sub-arrays.
- Note
-
num
must be > 0. If this array is empty, an empty sequence will be returned. - Source
- CPArray2D.scala
Splits this array into a sequence of w
xh
arrays.
Splits this array into a sequence of w
xh
arrays.
Value parameters
- h
-
Height of the split.
- w
-
Width of the split.
Attributes
- Returns
-
Sequence of
w
xh
arrays. - Note
-
w
andh
must be > 0.Given
w
andh
must produce an even split. If this array is empty, an empty sequence will be returned. - Source
- CPArray2D.scala
Creates new trimmed array with a given blank value.
Creates new trimmed array with a given blank value.
Value parameters
- blank
-
Blank value to use for trimming.
Attributes
- Note
-
If trimming is not possible, returns this array.
- Source
- CPArray2D.scala
Creates new trimmed array. Rows and columns are trimmed if all their values satisfy given predicate.
Creates new trimmed array. Rows and columns are trimmed if all their values satisfy given predicate.
Value parameters
- f
-
Trimming predicate. If
true
the value will be considered blank.
Attributes
- Returns
-
Trimmed out (smaller) copy of this array.
- Note
-
If trimming is not possible, returns this array.
- Source
- CPArray2D.scala
Concrete fields
Dimension of this array.
Attributes
- Source
- CPArray2D.scala
Checks whether or not this array is empty, i.e. it's size == 0.
Checks whether or not this array is not empty, i.e. it's size != 0.
Checks whether or not this array is not empty, i.e. it's size != 0.
Attributes
- Source
- CPArray2D.scala
Shape of this array as a rectangle.
Number of cells in this 2D array.
Attributes
- Source
- CPArray2D.scala
Maximum X-coordinate. If width is zero this will equal to -1
.
Maximum Y-coordinate. If height is zero this will equal to -1
.