-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A agpl-containers-bulk-utils.adb A agpl-containers-bulk-utils.ads A agpl-generic_dense_matrix.adb A agpl-generic_dense_matrix.ads A agpl-htn-tasks-containers.ads A agpl-cr-agent-containers.ads A agpl-htn-tasks-utils.ads
- Loading branch information
Showing
8 changed files
with
482 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package body Agpl.Containers.Bulk.Utils is | ||
|
||
----------------- | ||
-- Concatenate -- | ||
----------------- | ||
|
||
procedure Concatenate (Dest : in out Lists.List; Src : in Lists.List) is | ||
|
||
use Lists; | ||
|
||
procedure Append (X : in Cursor) is | ||
begin | ||
Dest.Append (Element (X)); | ||
end Append; | ||
|
||
begin | ||
Iterate (Src, Append'Access); | ||
end Concatenate; | ||
|
||
------------- | ||
-- To_List -- | ||
------------- | ||
|
||
function To_List (Src : in Vectors.Vector) return Lists.List is | ||
Dst : Lists.List; | ||
|
||
procedure Add (I : Vectors.Cursor) is | ||
begin | ||
Dst.Append (Vectors.Element (I)); | ||
end Add; | ||
begin | ||
Src.Iterate (Add'Access); | ||
return Dst; | ||
end To_List; | ||
|
||
--------------- | ||
-- To_Vector -- | ||
--------------- | ||
|
||
function To_Vector (Src : in Lists.List) return Vectors.Vector is | ||
Dst : Vectors.Vector; | ||
|
||
procedure Add (I : Lists.Cursor) is | ||
begin | ||
Dst.Append (Lists.Element (I)); | ||
end Add; | ||
begin | ||
Src.Iterate (Add'Access); | ||
return Dst; | ||
end To_Vector; | ||
|
||
end Agpl.Containers.Bulk.Utils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
------------------------------------------------------------------------------ | ||
-- AGPL -- | ||
-- -- | ||
-- Copyright (C) 2003 -- | ||
-- A. Mosteo. -- | ||
-- -- | ||
-- Authors: A. Mosteo. (public@mosteo.com) -- | ||
-- -- | ||
-- If you have any questions in regard to this software, please address -- | ||
-- them to the above email. -- | ||
-- -- | ||
-- This program is free software; you can redistribute it and/or modify -- | ||
-- it under the terms of the GNU General Public License as published by -- | ||
-- the Free Software Foundation; either version 2 of the License, or (at -- | ||
-- your option) any later version. -- | ||
-- -- | ||
-- This program is distributed in the hope that it will be useful, but -- | ||
-- WITHOUT ANY WARRANTY; without even the implied warranty of -- | ||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- | ||
-- General Public License for more details. -- | ||
-- -- | ||
-- You should have received a copy of the GNU General Public License -- | ||
-- along with this library; if not, write to the Free Software Foundation, -- | ||
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- | ||
------------------------------------------------------------------------------ | ||
|
||
-- Conversions for containers | ||
|
||
generic | ||
package Agpl.Containers.Bulk.Utils is | ||
|
||
pragma Preelaborate; | ||
|
||
procedure Concatenate (Dest : in out Lists.List; Src : in Lists.List); | ||
|
||
function To_List (Src : in Vectors.Vector) return Lists.List; | ||
|
||
function To_Vector (Src : in Lists.List) return Vectors.Vector; | ||
|
||
end Agpl.Containers.Bulk.Utils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
------------------------------------------------------------------------------ | ||
-- AGPL -- | ||
-- -- | ||
-- Copyright (C) 2003 -- | ||
-- A. Mosteo. -- | ||
-- -- | ||
-- Authors: A. Mosteo. (public@mosteo.com) -- | ||
-- -- | ||
-- If you have any questions in regard to this software, please address -- | ||
-- them to the above email. -- | ||
-- -- | ||
-- This program is free software; you can redistribute it and/or modify -- | ||
-- it under the terms of the GNU General Public License as published by -- | ||
-- the Free Software Foundation; either version 2 of the License, or (at -- | ||
-- your option) any later version. -- | ||
-- -- | ||
-- This program is distributed in the hope that it will be useful, but -- | ||
-- WITHOUT ANY WARRANTY; without even the implied warranty of -- | ||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- | ||
-- General Public License for more details. -- | ||
-- -- | ||
-- You should have received a copy of the GNU General Public License -- | ||
-- along with this library; if not, write to the Free Software Foundation, -- | ||
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- | ||
------------------------------------------------------------------------------ | ||
|
||
-- Massive instantiation of containers | ||
|
||
with Agpl.Containers.Bulk; | ||
|
||
package Agpl.Cr.Agent.Containers is | ||
new Agpl.Containers.Bulk (Object'Class, | ||
"=", | ||
Positive); | ||
|
||
pragma Preelaborate (Agpl.Cr.Agent.Containers); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
------------------------------------------------------------------------------ | ||
-- AGPL -- | ||
-- -- | ||
-- Copyright (C) 2003 -- | ||
-- A. Mosteo. -- | ||
-- -- | ||
-- Authors: A. Mosteo. (public@mosteo.com) -- | ||
-- -- | ||
-- If you have any questions in regard to this software, please address -- | ||
-- them to the above email. -- | ||
-- -- | ||
-- This program is free software; you can redistribute it and/or modify -- | ||
-- it under the terms of the GNU General Public License as published by -- | ||
-- the Free Software Foundation; either version 2 of the License, or (at -- | ||
-- your option) any later version. -- | ||
-- -- | ||
-- This program is distributed in the hope that it will be useful, but -- | ||
-- WITHOUT ANY WARRANTY; without even the implied warranty of -- | ||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- | ||
-- General Public License for more details. -- | ||
-- -- | ||
-- You should have received a copy of the GNU General Public License -- | ||
-- along with this library; if not, write to the Free Software Foundation, -- | ||
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- | ||
------------------------------------------------------------------------------ | ||
|
||
with Agpl.Containers.Bulk.Utils; | ||
with Agpl.Cr.Agent.Containers; | ||
|
||
package Agpl.Cr.Agent.Utils is | ||
new Agpl.Cr.Agent.Containers.Utils; | ||
|
||
pragma Preelaborate (Agpl.Cr.Agent.Utils); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
with Ada.Unchecked_Deallocation; | ||
with Agpl.Text_Io; use Agpl.Text_Io; | ||
|
||
package body Agpl.Generic_Dense_Matrix is | ||
|
||
use Ada.Finalization; | ||
|
||
------------ | ||
-- Create -- | ||
------------ | ||
|
||
function Create | ||
(Last_Row, | ||
Last_Col : Index_Type; | ||
First_Row, | ||
First_Col : Index_Type := Index_Type'First) | ||
return Matrix | ||
is | ||
begin | ||
return (Controlled with new Inner_Matrix (First_Row .. Last_Row, | ||
First_Col .. Last_Col)); | ||
end Create; | ||
|
||
--------------- | ||
-- First_Row -- | ||
--------------- | ||
|
||
function First_Row (This : in Matrix) return Index_Type is | ||
begin | ||
return This.Ptr.all'First (1); | ||
end First_Row; | ||
|
||
-------------- | ||
-- Last_Row -- | ||
-------------- | ||
|
||
function Last_Row (This : in Matrix) return Index_Type is | ||
begin | ||
return This.Ptr.all'Last (1); | ||
end Last_Row; | ||
|
||
--------------- | ||
-- First_Col -- | ||
--------------- | ||
|
||
function First_Col (This : in Matrix) return Index_Type is | ||
begin | ||
return This.Ptr.all'First (2); | ||
end First_Col; | ||
|
||
-------------- | ||
-- Last_Col -- | ||
-------------- | ||
|
||
function Last_Col (This : in Matrix) return Index_Type is | ||
begin | ||
return This.Ptr.all'Last (2); | ||
end Last_Col; | ||
|
||
--------- | ||
-- Get -- | ||
--------- | ||
|
||
function Get | ||
(This : in Matrix; | ||
Row, Col : in Index_Type) | ||
return Cell_Type | ||
is | ||
begin | ||
return This.Ptr (Row, Col); | ||
exception | ||
when others => | ||
Put_Line ("Out of bounds:" & Row'Img & Col'Img & " -- " & | ||
This.Ptr'First'Img & This.Ptr'Last'Img & | ||
This.Ptr'First (2)'Img & This.Ptr'Last (2)'Img); | ||
raise; | ||
end Get; | ||
|
||
--------- | ||
-- Ref -- | ||
--------- | ||
|
||
function Ref | ||
(This : in Matrix; | ||
Row, Col : in Index_Type) | ||
return access Cell_Type | ||
is | ||
begin | ||
return This.Ptr (Row, Col)'Access; | ||
end Ref; | ||
|
||
--------- | ||
-- Set -- | ||
--------- | ||
|
||
procedure Set | ||
(This : in out Matrix; | ||
Row, | ||
Col : in Index_Type; | ||
Data : in Cell_Type) | ||
is | ||
begin | ||
This.Ptr (Row, Col) := Data; | ||
end Set; | ||
|
||
procedure Free is new Ada.Unchecked_Deallocation (Inner_Matrix, Inner_Access); | ||
|
||
------------ | ||
-- Adjust -- | ||
------------ | ||
|
||
procedure Adjust (This : in out Matrix) is | ||
begin | ||
This.Ptr := new Inner_Matrix'(This.Ptr.all); | ||
end Adjust; | ||
|
||
-------------- | ||
-- Finalize -- | ||
-------------- | ||
|
||
procedure Finalize (This : in out Matrix) is | ||
begin | ||
Free (This.Ptr); | ||
end Finalize; | ||
|
||
---------- | ||
-- Read -- | ||
---------- | ||
|
||
procedure Read (Stream : not null access Root_Stream_Type'Class; | ||
This : out Matrix) | ||
is | ||
Fr : constant Index_Type := Index_Type'Input (Stream); | ||
Lr : constant Index_Type := Index_Type'Input (Stream); | ||
Fc : constant Index_Type := Index_Type'Input (Stream); | ||
Lc : constant Index_Type := Index_Type'Input (Stream); | ||
begin | ||
This := Create (First_Row => Fr, | ||
Last_Row => Lr, | ||
First_Col => Fc, | ||
Last_Col => Lc); | ||
Inner_Matrix'Read (Stream, This.Ptr.all); | ||
end Read; | ||
|
||
----------- | ||
-- Write -- | ||
----------- | ||
|
||
procedure Write (Stream : not null access Root_Stream_Type'Class; | ||
This : Matrix) | ||
is | ||
begin | ||
Index_Type'Output (Stream, This.Ptr'First (1)); | ||
Index_Type'Output (Stream, This.Ptr'Last (1)); | ||
Index_Type'Output (Stream, This.Ptr'First (2)); | ||
Index_Type'Output (Stream, This.Ptr'Last (2)); | ||
Inner_Matrix'Write (Stream, This.Ptr.all); | ||
end Write; | ||
|
||
end Agpl.Generic_Dense_Matrix; |
Oops, something went wrong.