< Ada Programming < Libraries 
 
 
      
Ada. Time-tested, safe and secure.
This language feature is only available from Ada 2005 on. Ada.Containers.Vectors is a unit of the Predefined Language Environment since Ada 2005.
This generic package supplies a container (Vector) which can store any definite subtype in a consecutive list. This makes an Ada.Containers.Vectors.Vector similar to an array — however a Vector can change size after it has been declared, which an array can't do.
Specification
-- Standard Ada library specification -- Copyright (c) 2003-2018 Maxim Reznik <[email protected]> -- Copyright (c) 2004-2016 AXE Consultants -- Copyright (c) 2004, 2005, 2006 Ada-Europe -- Copyright (c) 2000 The MITRE Corporation, Inc. -- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc. -- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual -- -------------------------------------------------------------------------generictypeIndex_Typeisrange<>;typeElement_Typeisprivate;withfunction"=" (Left :inElement_Type; Right :inElement_Type)returnBooleanis<>;packageAda.Containers.VectorsispragmaPreelaborate (Vectors);subtypeExtended_IndexisIndex_Type'BaserangeIndex_Type'First - 1 .. Index_Type'Min (Index_Type'Base'Last - 1, Index_Type'Last) + 1; No_Index :constantExtended_Index := Extended_Index'First;typeVectoristaggedprivate;pragmaPreelaborable_Initialization (Vector);typeCursorisprivate;pragmaPreelaborable_Initialization (Cursor); Empty_Vector :constantVector; No_Element :constantCursor;function"=" (Left :inVector; Right :inVector)returnBoolean;functionTo_Vector (Length :inCount_Type)returnVector;functionTo_Vector (New_Item :inElement_Type; Length :inCount_Type)returnVector;function"&" (Left :inVector; Right :inVector)returnVector;function"&" (Left :inVector; Right :inElement_Type)returnVector;function"&" (Left :inElement_Type; Right :inVector)returnVector;function"&" (Left :inElement_Type; Right :inElement_Type)returnVector;functionCapacity (Container :inVector)returnCount_Type;procedureReserve_Capacity (Container :inoutVector; Capacity :inCount_Type);functionLength (Container :inVector)returnCount_Type;procedureSet_Length (Container :inoutVector; Length :inCount_Type);functionIs_Empty (Container :inVector)returnBoolean;procedureClear (Container :inoutVector);functionTo_Cursor (Container : Vector; Index : Extended_Index)returnCursor;functionTo_Index (Position :inCursor)returnExtended_Index;functionElement (Container :inVector; Index :inIndex_Type)returnElement_Type;functionElement (Position :inCursor)returnElement_Type;procedureReplace_Element (Container :inoutVector; Index :inIndex_Type; New_Item :inElement_Type);procedureReplace_Element (Container :inoutVector; Position :inCursor; New_item :inElement_Type);procedureQuery_Element (Container :inVector; Index :inIndex_Type; Process :notnullaccessprocedure(Element :inElement_Type));procedureQuery_Element (Position :inCursor; Process :notnullaccessprocedure(Element :inElement_Type));procedureUpdate_Element (Container :inoutVector; Index :inIndex_Type; Process :notnullaccessprocedure(Element :inoutElement_Type));procedureUpdate_Element (Container :inoutVector; Position :inCursor; Process :notnullaccessprocedure(Element :inoutElement_Type));procedureMove (Target :inoutVector; Source :inoutVector);procedureInsert (Container :inoutVector; Before :inExtended_Index; New_Item :inVector);procedureInsert (Container :inoutVector; Before :inCursor; New_Item :inVector);procedureInsert (Container :inoutVector; Before :inCursor; New_Item :inVector; Position :outCursor);procedureInsert (Container :inoutVector; Before :inExtended_Index; New_Item :inElement_Type; Count :inCount_Type := 1);procedureInsert (Container :inoutVector; Before :inCursor; New_Item :inElement_Type; Count :inCount_Type := 1);procedureInsert (Container :inoutVector; Before :inCursor; New_Item :inElement_Type; Position :outCursor; Count :inCount_Type := 1);procedureInsert (Container :inoutVector; Before :inExtended_Index; Count :inCount_Type := 1);procedureInsert (Container :inoutVector; Before :inCursor; Position :outCursor; Count :inCount_Type := 1);procedurePrepend (Container :inoutVector; New_Item :inVector);procedurePrepend (Container :inoutVector; New_Item :inElement_Type; Count :inCount_Type := 1);procedureAppend (Container :inoutVector; New_Item :inVector);procedureAppend (Container :inoutVector; New_Item :inElement_Type; Count :inCount_Type := 1);procedureInsert_Space (Container :inoutVector; Before :inExtended_Index; Count :inCount_Type := 1);procedureInsert_Space (Container :inoutVector; Before :inCursor; Position :outCursor; Count :inCount_Type := 1);procedureDelete (Container :inoutVector; Index :inExtended_Index; Count :inCount_Type := 1);procedureDelete (Container :inoutVector; Position :inoutCursor; Count :inCount_Type := 1);procedureDelete_First (Container :inoutVector; Count :inCount_Type := 1);procedureDelete_Last (Container :inoutVector; Count :inCount_Type := 1);procedureReverse_Elements (Container :inoutVector);procedureSwap (Container :inoutVector; I :inIndex_Type; J :inIndex_Type);procedureSwap (Container :inoutVector; I :inCursor; J :inCursor);functionFirst_Index (Container :inVector)returnIndex_Type;functionFirst (Container :inVector)returnCursor;functionFirst_Element (Container :inVector)returnElement_Type;functionLast_Index (Container :inVector)returnExtended_Index;functionLast (Container :inVector)returnCursor;functionLast_Element (Container :inVector)returnElement_Type;functionNext (Position :inCursor)returnCursor;procedureNext (Position :inoutCursor);functionPrevious (Position :inCursor)returnCursor;procedurePrevious (Position :inoutCursor);functionFind_Index (Container :inVector; Item :inElement_Type; Index :inIndex_Type := Index_Type'First)returnExtended_Index;functionFind (Container :inVector; Item :inElement_Type; Position :inCursor := No_Element)returnCursor;functionReverse_Find_Index (Container :inVector; Item :inElement_Type; Index :inIndex_Type := Index_Type'Last)returnExtended_Index;functionReverse_Find (Container :inVector; Item :inElement_Type; Position :inCursor := No_Element)returnCursor;functionContains (Container :inVector; Item :inElement_Type)returnBoolean;functionHas_Element (Position :inCursor)returnBoolean;procedureIterate (Container :inVector; Process :notnullaccessprocedure(Position :inCursor));procedureReverse_Iterate (Container :inVector; Process :notnullaccessprocedure(Position :inCursor));genericwithfunction"<" (Left :inElement_Type; Right :inElement_Type)returnBooleanis<>;packageGeneric_SortingisfunctionIs_Sorted (Container :inVector)returnBoolean;procedureSort (Container :inoutVector);procedureMerge (Target :inoutVector; Source :inoutVector);endGeneric_Sorting;privatetypeVectoristaggednullrecord; Empty_Vector :constantVector := (nullrecord);typeCursorisnullrecord; No_Element :constantCursor := (nullrecord);endAda.Containers.Vectors;
See also
Wikibook
External examples
- Search for examples of Ada.Containers.Vectorsin: Rosetta Code, GitHub or this Wikibook.
- Search for any post related to Ada.Containers.Vectorsin: Stack Overflow, comp.lang.ada or any Ada related page.
Tutorials
Ada Reference Manual
Ada 2005
Ada 2012
Open-Source Implementations
FSF GNAT
- Specification: a-convec.ads
- Body: a-convec.adb
drake
- Specification: containers/a-convec.ads
- Body: containers/a-convec.adb
    This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.