Generic package: Ada.Containers.Indefinite_Ordered_Sets

Dependencies

with Ada.Containers.Red_Black_Trees;
with Ada.Finalization;
with Ada.Streams;

Description

AI-302 Reference Implementation

Copyright (C) 2003-2004 Matthew J Heaney

The AI-302 Reference Implementation is free software; you can redistribute it and/or modify it under terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. AI-302 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 distributed with AI-302; see file COPYING.TXT. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

As a special exception, if other files instantiate generics from this unit, or you link this unit with other files to produce an executable, this unit does not by itself cause the resulting executable to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the executable file might be covered by the GNU Public License.

The AI-302 Reference Implementation is maintained by Matthew J Heaney.

mailto:matthewjheaney@earthlink.net http://home.earthlink.net/~matthewjheaney/index.html


Header

generic

   type Element_Type (<>) is private;

   with function "<" (Left, Right : Element_Type)
      return Boolean is <>;

   with function "=" (Left, Right : Element_Type)
      return Boolean is <>;

package Ada.Containers.Indefinite_Ordered_Sets is
 
pragma Preelaborate (Indefinite_Ordered_Sets);
For description, See Ada.Containers.Ordered_Sets

Type Summary

Cursor
Primitive Operations:  "<", "<", "<", ">", ">", ">", Ceiling, Delete, Element, Find, First, Floor, Has_Element, Insert, Last, Next, Next, Previous, Previous
Iterate_Process
Reverse_Iterate_Process derived from Iterate_Process
Set
Primitive Operations:  "-", "=", "and", "or", "xor", Ceiling, Clear, Delete, Delete, Delete_First, Delete_Last, Difference, Difference, Find, First, First_Element, Floor, Insert, Intersection, Intersection, Is_Disjoint, Is_Empty, Is_In, Is_Subset, Iterate, Last, Last_Element, Length, Move, Reverse_Iterate, Symmetric_Difference, Symmetric_Difference, Union, Union

Constants and Named Numbers

Empty_Set : constant Set;
No_Element : constant Cursor;

Other Items:

type Set is tagged private;

type Cursor is private;

function "=" (Left, Right : Set) return Boolean;

function Length (Container : Set) return Count_Type;

function Is_Empty (Container : Set) return Boolean;

procedure Clear (Container : in out Set);

function Element (Position : Cursor) return Element_Type;

procedure Move (Target : in out Set;
                Source : in out Set);

procedure Insert (Container : in out Set;
                  New_Item  : in     Element_Type;
                  Position  :    out Cursor;
                  Success   :    out Boolean);
NOTE: A nice function might be: procedure Insert (Container : in out Set; New_Item : in Element_Type); This is a convenience function that omits the last two params. END NOTE.

procedure Delete (Container : in out Set;
                  Item      : in     Element_Type);

procedure Delete (Container : in out Set;
                  Position  : in out Cursor);

procedure Delete_First (Container : in out Set);

procedure Delete_Last (Container : in out Set);

procedure Union (Target : in out Set;
                 Source : in     Set);

function Union (Left, Right : Set) return Set;

function "or" (Left, Right : Set) return Set renames Union;

procedure Intersection (Target : in out Set;
                        Source : in     Set);

function Intersection (Left, Right : Set) return Set;

function "and" (Left, Right : Set) return Set renames Intersection;

procedure Difference (Target : in out Set;
                      Source : in     Set);

function Difference (Left, Right : Set) return Set;

function "-" (Left, Right : Set) return Set renames Difference;

procedure Symmetric_Difference (Target : in out Set;
                                Source : in     Set);

function Symmetric_Difference (Left, Right : Set) return Set;

function "xor" (Left, Right : Set) return Set renames Symmetric_Difference;

function Is_Subset (Item      : Set;
                    Container : Set)
   return Boolean;

function Is_Disjoint (Item      : Set;
                      Container : Set)
   return Boolean;

function Is_In (Item      : Element_Type;
                Container : Set) return Boolean;

function Find (Container : Set;
               Item      : Element_Type)
   return Cursor;

function Ceiling (Container : Set;
                  Item      : Element_Type)
   return Cursor;

function Floor (Container : Set;
                Item      : Element_Type)
   return Cursor;

function First (Container : Set) return Cursor;

function First_Element (Container : Set) return Element_Type;

function Last (Container : Set) return Cursor;

function Last_Element (Container : Set) return Element_Type;

function Next (Position : Cursor) return Cursor;

function Previous (Position : Cursor) return Cursor;

procedure Next (Position : in out Cursor);

procedure Previous (Position : in out Cursor);

function Has_Element (Position : Cursor) return Boolean;

function "<" (Left, Right : Cursor) return Boolean;

function ">" (Left, Right : Cursor) return Boolean;

function "<" (Left : Cursor; Right : Element_Type)
   return Boolean;

function ">" (Left : Cursor; Right : Element_Type)
   return Boolean;

function "<" (Left : Element_Type; Right : Cursor)
   return Boolean;

function ">" (Left : Element_Type; Right : Cursor)
   return Boolean;

type Iterate_Process is
   access procedure (Position : in Cursor);

procedure Iterate
  (Container : in Set;
   Process   :    Iterate_Process);
Ada0Y not null access procedure (Position : in Cursor));

The best we can do in Ada95 is to generate a run-time error, so if Process is null a Program_Error is raised.


type Reverse_Iterate_Process is
   new Iterate_Process;

procedure Reverse_Iterate
  (Container : in Set;
   Process   :    Reverse_Iterate_Process);
Ada0Y not null access procedure (Position : in Cursor));

The best we can do in Ada95 is to generate a run-time error, so if Process is null a Program_Error is raised.


generic

   type Key_Type (<>) is limited private;

   with function Key (Element : Element_Type) return Key_Type;

   with function "<" (Left : Key_Type; Right : Element_Type)
       return Boolean is <>;

   with function ">" (Left : Key_Type; Right : Element_Type)
       return Boolean is <>;

package Generic_Keys is
 

Type Summary

Update_Element_Process

Other Items:

function Is_In (Container : Set;
                Key       : Key_Type)
   return Boolean;

function Find (Container : Set;
               Key       : Key_Type)
  return Cursor;

function Element (Container : Set;
                  Key       : Key_Type)
  return Element_Type;

function Ceiling (Container : Set;
                  Key       : Key_Type)
  return Cursor;

function Floor (Container : Set;
                Key       : Key_Type)
  return Cursor;

procedure Delete (Container : in out Set;
                  Key       : in     Key_Type);

function "<" (Left : Cursor; Right : Key_Type)
  return Boolean;

function ">" (Left : Cursor; Right : Key_Type)
  return Boolean;

function "<" (Left : Key_Type; Right : Cursor)
  return Boolean;

function ">" (Left : Key_Type; Right : Cursor)
  return Boolean;

type Update_Element_Process is
   access procedure (Element : in out Element_Type);

procedure Update_Element
  (Container : in out Set;
   Position  : in     Cursor;
   Process   :        Update_Element_Process);
Ada0Y not null access procedure (Element : in out Element_Type));

The best we can do in Ada95 is to generate a run-time error, so if Process is null a Program_Error is raised.

end Generic_Keys;

private

   --  Implementation-defined ...
end Ada.Containers.Indefinite_Ordered_Sets;