From: "Nick Roberts" <nick.roberts@acm.org>
Subject: Re: [newbie] simple(?) data structures
Date: Thu, 24 Jun 2004 15:50:26 +0100
Date: 2004-06-24T15:50:26+01:00 [thread overview]
Message-ID: <2k081iF16pb3qU1@uni-berlin.de> (raw)
In-Reply-To: 1ec946d1.0406231609.11a051cb@posting.google.com
"Matthew Heaney" <mheaney@on2.com> wrote in message
news:1ec946d1.0406231609.11a051cb@posting.google.com...
> package Go_Boards is
>
> type Board_Type (Size : Positive) is private;
>
> type Stone_Type is (Empty, Black, White);
>
> function Stone (Board : Board_Type) return Stone_Type;
>
> --function Width (B : BT) return Positive; --same as B.Size?
>
> private
>
> type Data_Type is
> array (Positive range <>, Positive range <>) of Stone_Type;
>
> type Board_Type (Size : Positive) is record
> Data : Data_Type (1 .. Size, 1 .. Size);
> end record;
>
> end Go_Boards;
(I can't resist improving on this a tad ;-)
package Nicks_Go is
type Board_Size is range 7..19; -- or whatever
type Coordinate is range 0..Board_Size'Last;
type Go_Board (Size : Board_Size) is private;
type Cell_Content is (Empty, Black, White);
subtype Stone_Color is Cell_Content range Black..White;
function Cell (
Board : Go_Board;
Row, Col: Coordinate) return Cell_Content;
procedure Set_Cell (
Board : in out Go_Board;
Row, Col: in Coordinate;
Cell: in Cell_Content);
private
type Matrix_Array is array (
Coordinate range <>,
Coordinate range <>) of Cell_Content;
type Go_Board_Type (Size : Board_Size) is
record
Matrix: Matrix_Array(1..Size, 1..Size); -- row, col
-- probably a lot of other stuff too
end record;
end Nicks_Go;
package body Nicks_Go is
function Cell (
Board : Go_Board;
Row, Col: Coordinate) return Cell_Content is
begin
return Board.Matrix(Row,Col);
end;
procedure Set_Cell (
Board : in out Go_Board;
Row, Col: in Coordinate;
Cell: in Cell_Content) is
begin
Board.Matrix(Row,Col) := Cell;
end;
end Nicks_Go;
Just for fun!
--
Nick Roberts
prev parent reply other threads:[~2004-06-24 14:50 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-12 22:23 [newbie] simple(?) data structures Roland Illig
2004-06-12 22:52 ` Frank
2004-06-13 0:10 ` Ludovic Brenta
2004-06-13 3:13 ` Roland Illig
2004-06-13 7:59 ` Marius Amado Alves
2004-06-13 11:56 ` Ludovic Brenta
2004-06-13 14:47 ` Stephen Leake
2004-06-13 18:24 ` Jeffrey Carter
2004-06-13 0:31 ` Jeffrey Carter
2004-06-13 1:26 ` tmoran
2004-06-13 2:47 ` tmoran
2004-06-13 3:53 ` Roland Illig
2004-06-13 10:12 ` Georg Bauhaus
2004-06-13 23:32 ` Robert I. Eachus
2004-06-14 12:29 ` Georg Bauhaus
2004-06-13 4:46 ` Steve
2004-06-13 4:59 ` tmoran
2004-06-13 17:58 ` Jeffrey Carter
2004-06-16 11:08 ` Roland Illig
2004-06-16 21:05 ` Georg Bauhaus
2004-06-16 23:23 ` Roland Illig
2004-06-17 0:44 ` Jeffrey Carter
2004-06-17 12:37 ` Hyman Rosen
2004-06-17 13:11 ` Björn Persson
2004-06-18 9:55 ` Ole-Hjalmar Kristensen
2004-06-18 11:03 ` Björn Persson
2004-06-18 12:04 ` Hyman Rosen
2004-06-22 8:11 ` Ole-Hjalmar Kristensen
2004-06-18 0:20 ` David Starner
2004-06-18 5:06 ` Hyman Rosen
2004-06-18 5:47 ` Martin Krischik
2004-06-18 7:30 ` Brian May
2004-06-18 14:21 ` Larry Kilgallen
2004-06-19 19:51 ` Robert I. Eachus
2004-06-18 15:04 ` Georg Bauhaus
2004-06-19 2:02 ` James Rogers
2004-06-18 9:51 ` Ole-Hjalmar Kristensen
2004-06-27 13:12 ` Jacob Sparre Andersen
2004-06-24 0:09 ` Matthew Heaney
2004-06-24 14:50 ` Nick Roberts [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox