BGrid

Kind of class:class
Inherits from:AbstractGrid
Version:1.0
Author:Francis Bourre
Classpath:com.bourre.structures.BGrid
File last modified:Wednesday, 31 October 2007, 07:35:30
BGrid defines Boolean grid structure.

Based on AbstractGrid class, this data's structure only accept
Boolean element for content.

Constructor

BGrid

function BGrid (
nX:Number, nY:Number)
Constructs a new BGrid instance.

Example

var b : BGrid = new BGrid(10, 10);
Parameters:
nX:
grid width
nY:
grid height

Instance methods

deserialize

function deserialize (
s:String) : Void
Deserializes passed-in String content and
loads it into grid.

Useful to load grid content.

Use serialize to save content.

Example

var b : BGrid = new BGrid(2, 2);
var sContent : String = "0101";

b.deserialize(sContent);
Parameters:
s:
Content String representation

getColumnVal

function getColumnVal (
n:Number) : Boolean
Calculates and returns Boolean addition's result of
column's elements.
Parameters:
n:
Column Number index
Returns:
Boolean value

getRowVal

function getRowVal (
n:Number) : Boolean
Calculates and returns Boolean addition's result of
row's elements.
Parameters:
n:
Row Number index
Returns:
Boolean value

getVal

function getVal (
v:Point) : Boolean
Returns value stored in grid cell defining by
passed-in Point coordinate.

Concrete implementation of AbstractGrid.getVal method.

Example

var b : BGrid = new BGrid(2, 2);
var aElements : Array = new Array(false, true, false, true);
b.setContent(aElements};

var r : Boolean = b.getVal( new Point(0,1) ); //return false
Parameters:
v:
Cell Point position
Returns:
Boolean value

serialize

function serialize (
) : String
Serializes grid content.

Useful to save grid content.

Use deserialize to load content.

Example

var b : BGrid = new BGrid(2, 2);
 var aElements : Array = new Array(false, true, false, true);
 b.setContent(aElements};

var sContent : String = b.serialize(); //return "0101";
Returns:
Serialization String

setContent

function setContent (
a:Array) : Void
Sets content of grid with passed-in Array of String objects.

Can use deserialize method to define content directly with a
String representation content like "0101"

Used by deserialize to load content after deserialization process.

Example

var b : BGrid = new BGrid(2, 2);
var aContent : Array = new Array("0","1","0","1");
b.setContent(aContent);
Parameters:
a:
Array structure of String elements.

setVal

function setVal (
v:Point, b:Boolean) : Void
Defines value of grid cell defining by passed-in Point
coordinate.

Concrete implementation of AbstractGrid.setVal method.

Example

var b : BGrid = new BGrid(2, 2);
var aElements : Array = new Array(false, true, false, true);
b.setContent(aElements};
b.setVal( new Point(0,1), true);

var r : Boolean = b.getVal( new Point(0,1) ); //return true
Parameters:
v:
Cell Point position

toString

function toString (
) : String
Returns the string representation of this instance.
Returns:
the string representation of this instance