11/**
2- * width: width of the array
3- * height: height of the array
4- * defaultValue: the default value for the array
2+ * An array with a fixed height and width.
3+ *
4+ * @param width {number} width of the array
5+ * @param height {number} height of the array
6+ * @param defaultValue the initial value for the array elements
7+ * @class
58 */
69var Fixed2DArray = function Fixed2DArray ( width , height , defaultValue ) {
710 this . _width = width ;
@@ -16,7 +19,10 @@ var Fixed2DArray = function Fixed2DArray(width,height,defaultValue) {
1619} ;
1720
1821/**
19- * Throws an Error if the given coordinate is invalid
22+ * Throws an Error if the given coordinate is invalid.
23+ *
24+ * @param x {number} x coordinate
25+ * @param y {number} y coordinate
2026 */
2127Fixed2DArray . prototype . validateCoords = function ( x , y ) {
2228 if ( x < 0 || y < 0 || x >= this . _width || y >= this . _height ) {
@@ -27,15 +33,22 @@ Fixed2DArray.prototype.validateCoords = function(x,y) {
2733} ;
2834
2935/**
30- * Returns the coresponding value for the coordinate
36+ * Returns the value for the coordinate.
37+ *
38+ * @param x {number} x coordinate
39+ * @param y {number} y coordinate
3140 */
3241Fixed2DArray . prototype . get = function ( x , y ) {
3342 this . validateCoords ( x , y ) ;
3443 return this . _grid [ x ] [ y ] ;
3544} ;
3645
3746/**
38- * Sets the value for the coresponding coorinate
47+ * Sets the value for the coordinate.
48+ *
49+ * @param x {number} x coordinate
50+ * @param y {number} y coordinate
51+ * @param val new value
3952 */
4053Fixed2DArray . prototype . set = function ( x , y , val ) {
4154 this . validateCoords ( x , y ) ;
@@ -46,15 +59,20 @@ Fixed2DArray.prototype.set = function(x,y,val) {
4659 * Returns all neighbours of the given coordinate.
4760 *
4861 * For example:
62+ * <pre>
4963 * [ ][ ][ ][ ][ ]
5064 * [ ][*][*][*][ ]
5165 * [ ][*][X][*][ ]
5266 * [ ][*][*][*][ ]
5367 * [ ][ ][ ][ ][ ]
68+ * </pre>
69+ *
70+ * The given coordinate is marked with an `X`.
71+ * The function will return an array containing
72+ * the values for the fields maked with an `*`.
5473 *
55- * the given coordinate is marked with an `X`
56- * the function will return an array containing
57- * the values for the fields maked with an `*`
74+ * @param x {number} x coordinate
75+ * @param y {number} y coordinate
5876 */
5977Fixed2DArray . prototype . getNeighbours = function ( x , y ) {
6078 this . validateCoords ( x , y ) ;
0 commit comments