Ejemplo n.º 1
0
		public static string GetStringRepresentation(Cell[] cells)
		{
			System.Text.StringBuilder builder = new System.Text.StringBuilder(cells.Length);
			foreach(Cell cell in cells)
			{
				builder.Append((cell.State == CellStateEnum.Filled) ? Cell.FILLED_CHAR : Cell.SPACE_CHAR);
			}
			return builder.ToString();
		}
Ejemplo n.º 2
0
		public Map(int width, int height)
		{
			Width = width;
			Height = height;
			cells = new Cell[Height, Width];
			rows = new Cell[Height][];
			columns = new Cell[Width][];
			for(int i = 0; i < Height; i++)
				rows[i] = new Cell[Width];
			for(int i = 0; i < Width; i++)
				columns[i] = new Cell[Height];
			for(int i = 0; i < Height; i++)
				for(int j = 0; j < Width; j++)
					columns[j][i] = rows[i][j] = cells[i, j] = new Cell();
		}
Ejemplo n.º 3
0
		public static Cell[] TrimNotFilledCells(Cell[] originalArray)
		{
			Cell[] result;
			int start = 0;
			int end = originalArray.Length - 1;
			bool startFound = false;
			bool endFound = false;
			for(int i = 0; i < originalArray.Length; i++)
			{
				if(!startFound)
				{
					start = i;
					if(originalArray[i].State == CellStateEnum.Filled)
					{
						startFound = true;
					}
				}
			}
			for(int i = originalArray.Length - 1; i >= 0; i--)
			{
				if(!endFound)
				{
					end = i;
					if(originalArray[i].State == CellStateEnum.Filled)
					{
						endFound = true;
					}
				}
			}
			if(start > end)
			{
				result = new Cell[]{};
			} else {
				result = new Cell[end - start + 1];
				for(int i = start; i <= end; i++)
				{
					result[i - start] = originalArray[i];
				}
			}
			return result;
		}