Predefined Ada Data Types from Package Standard
Die folgenden Datentypen sind im Ada Paket Standard definiert und sind in jeder Ada-Kompiliereinheit sichtbar.
Diese Datentypen sind die Basis für den Aufbau von Ada-Datenstrukturen.
Predefined Integer Types
type Integer is range implementation-defined;
subtype Natural is Integer range 0 .. Integer'Last;
subtype Positive is Integer range 1 .. Integer'Last;
Predefined Float Types
type Float is digits implementation-defined;
Predefined Enumeration Type
type Boolean is (False, True);
Predefined Character Types
type Character is (...);
type Wide_Character is (...);
Predefined String Types
type String is array (Positive range <>) of Character;
type Wide_String is array (Positive range <>) of Wide_Character;
Predefined Fixed Point Type
type Duration is delta implementation-defined range implementation-defined;
Predefined Exceptions
Constraint_Error : exception;
Program_Error : exception;
Storage_Error : exception;
Tasking_Error : exception;
ASCII
The package ASCII is part of the package Standard. See also Ada.Characters.Latin_1 (since Ada95).
The package Ada.Characters.Latin_1 declares constants for characters defined by ISO 8859-1.
Package System
The package System contains implementation specific data structures.
generic
type Number is range <>;
package Generic_Rational is
type Rational is private;
function "abs" (A : Rational) return Rational;
function "+" (A : Rational) return Rational;
function "-" (A : Rational) return Rational;
function Inverse (A : Rational) return Rational;
function "+" (A : Rational; B : Rational) return Rational;
function "+" (A : Rational; B : Number ) return Rational;
function "+" (A : Number; B : Rational) return Rational;
function "-" (A : Rational; B : Rational) return Rational;
function "-" (A : Rational; B : Number ) return Rational;
function "-" (A : Number; B : Rational) return Rational;
function "*" (A : Rational; B : Rational) return Rational;
function "*" (A : Rational; B : Number ) return Rational;
function "*" (A : Number; B : Rational) return Rational;
function "/" (A : Rational; B : Rational) return Rational;
function "/" (A : Rational; B : Number ) return Rational;
function "/" (A : Number; B : Rational) return Rational;
function "/" (A : Number; B : Number) return Rational;
function ">" (A : Rational; B : Rational) return Boolean;
function ">" (A : Number; B : Rational) return Boolean;
function ">" (A : Rational; B : Number) return Boolean;
function "<" (A : Rational; B : Rational) return Boolean;
function "<" (A : Number; B : Rational) return Boolean;
function "<" (A : Rational; B : Number) return Boolean;
function ">=" (A : Rational; B : Rational) return Boolean;
function ">=" (A : Number; B : Rational) return Boolean;
function ">=" (A : Rational; B : Number) return Boolean;
function "<=" (A : Rational; B : Rational) return Boolean;
function "<=" (A : Number; B : Rational) return Boolean;
function "<=" (A : Rational; B : Number) return Boolean;
function "=" (A : Number; B : Rational) return Boolean;
function "=" (A : Rational; B : Number) return Boolean;
function Numerator (A : Rational) return Number;
function Denominator (A : Rational) return Number;
Zero : constant Rational;
One : constant Rational;
private
type Rational is record
Numerator : Number;
Denominator : Number;
end record;
Zero : constant Rational := (0, 1);
One : constant Rational := (1, 1);
end Generic_Rational;
package body Generic_Rational is
function GCD (A, B : Number) return Number is
begin
if A = 0 then
return B;
end if;
if B = 0 then
return A;
end if;
if A > B then
return GCD (B, A mod B);
else
return GCD (A, B mod A);
end if;
end GCD;
function Inverse (A : Rational) return Rational is
begin
if A.Numerator > 0 then
return (A.Denominator, A.Numerator);
elsif A.Numerator < 0 then
return (-A.Denominator, -A.Numerator);
else
raise Constraint_Error;
end if;
end Inverse;
function "abs" (A : Rational) return Rational is
begin
return (abs A.Numerator, A.Denominator);
end "abs";
function "+" (A : Rational) return Rational is
begin
return A;
end "+";
function "-" (A : Rational) return Rational is
begin
return (-A.Numerator, A.Denominator);
end "-";
function "+" (A : Rational; B : Rational) return Rational is
Common : constant Number := GCD (A.Denominator, B.Denominator);
A_Denominator : constant Number := A.Denominator / Common;
B_Denominator : constant Number := B.Denominator / Common;
begin
return (A.Numerator * B_Denominator + B.Numerator * A_Denominator) /
(A_Denominator * B.Denominator);
end "+";
function "+" (A : Rational; B : Number) return Rational is
begin
return (A.Numerator + B * A.Denominator) / A.Denominator;
end "+";
function "+" (A : Number; B : Rational) return Rational is
begin
return B + A;
end "+";
function "-" (A : Rational; B : Rational) return Rational is
begin
return A + (-B);
end "-";
function "-" (A : Rational; B : Number) return Rational is
begin
return A + (-B);
end "-";
function "-" (A : Number; B : Rational) return Rational is
begin
return A + (-B);
end "-";
function "*" (A : Rational; B : Rational) return Rational is
begin
return (A.Numerator * B.Numerator) / (A.Denominator * B.Denominator);
end "*";
function "*" (A : Rational; B : Number) return Rational is
Common : constant Number := GCD (A.Denominator, abs B);
begin
return (A.Numerator * B / Common, A.Denominator / Common);
end "*";
function "*" (A : Number; B : Rational) return Rational is
begin
return B * A;
end "*";
function "/" (A : Rational; B : Rational) return Rational is
begin
return A * Inverse (B);
end "/";
function "/" (A : Rational; B : Number) return Rational is
Common : constant Number := GCD (abs A.Numerator, abs B);
begin
if B > 0 then
return (A.Numerator / Common, A.Denominator * (B / Common));
else
return ((-A.Numerator) / Common, A.Denominator * ((-B) / Common));
end if;
end "/";
function "/" (A : Number; B : Rational) return Rational is
begin
return Inverse (B) * A;
end "/";
function "/" (A : Number; B : Number) return Rational is
Common : constant Number := GCD (abs A, abs B);
begin
if B = 0 then
raise Constraint_Error;
elsif A = 0 then
return (0, 1);
elsif A > 0 xor B > 0 then
return (-(abs A / Common), abs B / Common);
else
return (abs A / Common, abs B / Common);
end if;
end "/";
function ">" (A, B : Rational) return Boolean is
Diff : constant Rational := A - B;
begin
return Diff.Numerator > 0;
end ">";
function ">" (A : Number; B : Rational) return Boolean is
Diff : constant Rational := A - B;
begin
return Diff.Numerator > 0;
end ">";
function ">" (A : Rational; B : Number) return Boolean is
Diff : constant Rational := A - B;
begin
return Diff.Numerator > 0;
end ">";
function "<" (A, B : Rational) return Boolean is
Diff : constant Rational := A - B;
begin
return Diff.Numerator < 0;
end "<";
function "<" (A : Number; B : Rational) return Boolean is
Diff : constant Rational := A - B;
begin
return Diff.Numerator < 0;
end "<";
function "<" (A : Rational; B : Number) return Boolean is
Diff : constant Rational := A - B;
begin
return Diff.Numerator < 0;
end "<";
function ">=" (A, B : Rational) return Boolean is
Diff : constant Rational := A - B;
begin
return Diff.Numerator >= 0;
end ">=";
function ">=" (A : Number; B : Rational) return Boolean is
Diff : constant Rational := A - B;
begin
return Diff.Numerator >= 0;
end ">=";
function ">=" (A : Rational; B : Number) return Boolean is
Diff : constant Rational := A - B;
begin
return Diff.Numerator >= 0;
end ">=";
function "<=" (A, B : Rational) return Boolean is
Diff : constant Rational := A - B;
begin
return Diff.Numerator <= 0;
end "<=";
function "<=" (A : Number; B : Rational) return Boolean is
Diff : constant Rational := A - B;
begin
return Diff.Numerator <= 0;
end "<=";
function "<=" (A : Rational; B : Number) return Boolean is
Diff : constant Rational := A - B;
begin
return Diff.Numerator <= 0;
end "<=";
function "=" (A : Number; B : Rational) return Boolean is
Diff : constant Rational := A - B;
begin
return Diff.Numerator = 0;
end "=";
function "=" (A : Rational; B : Number) return Boolean is
Diff : constant Rational := A - B;
begin
return Diff.Numerator = 0;
end "=";
function Numerator (A : Rational) return Number is
begin
return A.Numerator;
end Numerator;
function Denominator (A : Rational) return Number is
begin
return A.Denominator;
end Denominator;
end Generic_Rational;
Weitere Datenstrukturen und Methoden um diese zu manipulieren sind in den Paketen definiert die durch den Ada-Standard definiert sind:
Ada.Assertions (Ada 2005)
Ada.Asynchronous_Task_Control
Ada.Calendar
Ada.Calendar.Arithmetic (Ada 2005)
Ada.Calendar.Formatting (Ada 2005)
Ada.Calendar.Time_Zones (Ada 2005)
Ada.Characters
Ada.Characters.Conversions (Ada 2005)
Ada.Characters.Handling
Ada.Characters.Latin_1
Ada.Command_Line
Ada.Complex_Text_IO (Ada 2005)
Ada.Containers (Ada 2005)
Ada.Containers.Doubly_Linked_Lists (Ada 2005)
Ada.Containers.Generic_Array_Sort (Ada 2005 generic procedure)
Ada.Containers.Generic_Constrained_Array_Sort (Ada 2005 generic procedure)
Ada.Containers.Hashed_Maps (Ada 2005)
Ada.Containers.Hashed_Sets (Ada 2005)
Ada.Containers.Indefinite_Doubly_Linked_Lists (Ada 2005)
Ada.Containers.Indefinite_Hashed_Maps (Ada 2005)
Ada.Containers.Indefinite_Hashed_Sets (Ada 2005)
Ada.Containers.Indefinite_Ordered_Maps (Ada 2005)
Ada.Containers.Indefinite_Ordered_Sets (Ada 2005)
Ada.Containers.Indefinite_Vectors (Ada 2005)
Ada.Containers.Ordered_Maps (Ada 2005)
Ada.Containers.Ordered_Sets (Ada 2005)
Ada.Containers.Vectors (Ada 2005)
Ada.Decimal
Ada.Direct_IO
Ada.Directories (Ada 2005)
Ada.Directories.Information (Ada 2005)
Ada.Dispatching (Ada 2005)
Ada.Dispatching.EDF (Ada 2005)
Ada.Dispatching.Round_Robin (Ada 2005)
Ada.Dynamic_Priorities
Ada.Environment_Variables (Ada 2005)
Ada.Exceptions
Ada.Execution_Time (Ada 2005)
Ada.Execution_Time.Timers (Ada 2005)
Ada.Execution_Time.Group_Budgets (Ada 2005)
Ada.Finalization
Ada.Float_Text_IO
Ada.Float_Wide_Text_IO
Ada.Float_Wide_Wide_Text_IO (Ada 2005)
Ada.Integer_Text_IO
Ada.Integer_Wide_Text_IO
Ada.Integer_Wide_Wide_Text_IO (Ada 2005)
Ada.Interrupts
Ada.Interrupts.Names
Ada.IO_Exceptions
Ada.Numerics
Ada.Numerics.Complex_Arrays (Ada 2005)
Ada.Numerics.Complex_Elementary_Functions
Ada.Numerics.Complex_Types
Ada.Numerics.Discrete_Random
Ada.Numerics.Elementary_Functions
Ada.Numerics.Float_Random
Ada.Numerics.Generic_Complex_Arrays (Ada 2005)
Ada.Numerics.Generic_Complex_Elementary_Functions
Ada.Numerics.Generic_Complex_Types
Ada.Numerics.Generic_Elementary_Functions
Ada.Numerics.Generic_Real_Arrays (Ada 2005)
Ada.Numerics.Real_Arrays (Ada 2005)
Ada.Real_Time
Ada.Real_Time.Timing_Events (Ada 2005)
Ada.Sequential_IO
Ada.Storage_IO
Ada.Streams
Ada.Streams.Stream_IO
Ada.Strings
Ada.Strings.Bounded
Ada.Strings.Bounded.Hash (Ada 2005 generic function)
Ada.Strings.Fixed
Ada.Strings.Fixed.Hash (Ada 2005 generic function)
Ada.Strings.Hash (Ada 2005 generic function)
Ada.Strings.Maps
Ada.Strings.Maps.Constants
Ada.Strings.Unbounded
Ada.Strings.Unbounded.Hash (Ada 2005 generic function)
Ada.Strings.Wide_Bounded
Ada.Strings.Wide_Bounded.Wide_Hash (Ada 2005 generic function)
Ada.Strings.Wide_Fixed
Ada.Strings.Wide_Fixed.Wide_Hash (Ada 2005 generic function)
Ada.Strings.Wide_Hash (Ada 2005 generic function)
Ada.Strings.Wide_Maps
Ada.Strings.Wide_Maps.Wide_Constants
Ada.Strings.Wide_Unbounded
Ada.Strings.Wide_Unbounded.Wide_Hash (Ada 2005 generic function)
Ada.Strings.Wide_Wide_Bounded (Ada 2005)
Ada.Strings.Wide_Wide_Bounded.Wide_Wide_Hash (Ada 2005 generic function)
Ada.Strings.Wide_Wide_Fixed (Ada 2005)
Ada.Strings.Wide_Wide_Fixed.Wide_Wide_Hash (Ada 2005 generic function)
Ada.Strings.Wide_Wide_Hash (Ada 2005 generic function)
Ada.Strings.Wide_Wide_Maps (Ada 2005)
Ada.Strings.Wide_Wide_Maps.Wide_Wide_Constants (Ada 2005)
Ada.Strings.Wide_Wide_Unbounded (Ada 2005)
Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Hash (Ada 2005 generic function)
Ada.Synchronous_Task_Control
Ada.Tags
Ada.Tags.Generic_Dispatching_Constructor (generic function)
Ada.Task_Attributes
Ada.Task_Identification
Ada.Task_Termination (Ada 2005)
Ada.Text_IO
Ada.Text_IO.Bounded_IO (Ada 2005)
Ada.Text_IO.Complex_IO
Ada.Text_IO.Decimal_IO (Nested package of Ada.Text_IO)
Ada.Text_IO.Editing
Ada.Text_IO.Enumeration_IO (Nested package of Ada.Text_IO)
Ada.Text_IO.Fixed_IO (Nested package of Ada.Text_IO)
Ada.Text_IO.Float_IO (Nested package of Ada.Text_IO)
Ada.Text_IO.Integer_IO (Nested package of Ada.Text_IO)
Ada.Text_IO.Modular_IO (Nested package of Ada.Text_IO)
Ada.Text_IO.Text_Streams
Ada.Text_IO.Unbounded_IO (Ada 2005)
Ada.Unchecked_Conversion (generic function)
Ada.Unchecked_Deallocation (generic procedure)
Ada.Wide_Characters (Ada 2005)
Ada.Wide_Text_IO
Ada.Wide_Text_IO.Bounded_IO (Ada 2005)
Ada.Wide_Text_IO.Complex_IO
Ada.Wide_Text_IO.Decimal_IO (Nested package of Ada.Wide_Text_IO)
Ada.Wide_Text_IO.Editing
Ada.Wide_Text_IO.Enumeration_IO (Nested package of Ada.Wide_Text_IO)
Ada.Wide_Text_IO.Fixed_IO (Nested package of Ada.Wide_Text_IO)
Ada.Wide_Text_IO.Float_IO (Nested package of Ada.Wide_Text_IO)
Ada.Wide_Text_IO.Integer_IO (Nested package of Ada.Wide_Text_IO)
Ada.Wide_Text_IO.Modular_IO (Nested package of Ada.Wide_Text_IO)
Ada.Wide_Text_IO.Text_Streams
Ada.Wide_Text_IO.Unbounded_IO (Ada 2005)
Ada.Wide_Wide_Characters (Ada 2005)
Ada.Wide_Wide_Text_IO (Ada 2005)
Ada.Wide_Wide_Text_IO.Bounded_IO (Ada 2005)
Ada.Wide_Wide_Text_IO.Complex_IO (Ada 2005)
Ada.Wide_Wide_Text_IO.Decimal_IO (Nested package of Ada.Wide_Wide_Text_IO)
Ada.Wide_Wide_Text_IO.Editing (Ada 2005)
Ada.Wide_Wide_Text_IO.Enumeration_IO (Nested package of Ada.Wide_Wide_Text_IO)
Ada.Wide_Wide_Text_IO.Fixed_IO (Nested package of Ada.Wide_Wide_Text_IO)
Ada.Wide_Wide_Text_IO.Float_IO (Nested package of Ada.Wide_Wide_Text_IO)
Ada.Wide_Wide_Text_IO.Integer_IO (Nested package of Ada.Wide_Wide_Text_IO)
Ada.Wide_Wide_Text_IO.Modular_IO (Nested package of Ada.Wide_Wide_Text_IO)
Ada.Wide_Wide_Text_IO.Text_Streams (Ada 2005)
Ada.Wide_Wide_Text_IO.Unbounded_IO (Ada 2005)
29. Juni 2014 Version 1.0