Ada Programming/Libraries/Ada.Containers.Doubly Linked Lists

is a unit of the Predefined Language Environment since Ada 2005.

Introduction
One of the major additions to Ada 2005 is the container library. This library enables the Ada developer to manipulate data structures such as doubly linked lists, maps, sets and vectors. This page will show how the library works.

A doubly linked list is merely a linked list where each element is not only linked to the next, but also the previous. For more information, see doubly linked list.

Example
This is example usage is from an existing project.

worm.ads

This file represents the specification of a worm.

Wormlevel Protocol Worm Wormlevel Protocol Worm_Position_Container  AdaContainersDoubly_Linked_ListsPosition Worm_Position_Container Worm_State AliveDeadObserving Worm_Type Worm_Body List Direction Course   North Points    Natural  0 Number    Positive State     Worm_State  Alive Full      Boolean  False Worm_Type_Access  Worm_Type Update_Worm Worm  Worm_Type_Access Lvl   Level_Access Turn_Left  Worm   Worm_Type_Access Turn_Right Worm   Worm_Type_Access Kill       Worm   Worm_Type_Access Worm

As you can see, Ada.Containers.Doubly_Linked_Lists is instantiated with a type called “Position”. This type represents a tile type in a 2-dimensional array. The worm body is now represented by a doubly linked list, meaning we can loop through each element in either direction, by using the Next and Previous functions.

For those interested, the game can be found at GitHub.

Specification
Element_Type "" Left   Element_Type Right  Element_Type Boolean Preelaborate Doubly_Linked_Lists List Preelaborable_Initialization List Cursor Preelaborable_Initialization Cursor Empty_List  List No_Element  Cursor "" Left   List Right  List Boolean Length Container  List  Count_Type Is_Empty Container  List  Boolean Clear Container   List Element Position  Cursor  Element_Type Replace_Element Container   List Position       Cursor New_Item       Element_Type Query_Element Position  Cursor Process      Element   Element_Type Update_Element Container   List Position       Cursor Process       Element    Element_Type Move Target   List Source   List Insert Container   List Before         Cursor New_Item       Element_Type Count          Count_Type  1 Insert Container   List Before         Cursor New_Item       Element_Type Position      Cursor Count          Count_Type  1 Insert Container   List Before         Cursor Position      Cursor Count          Count_Type  1 Prepend Container   List New_Item       Element_Type Count          Count_Type  1 Append Container   List New_Item       Element_Type Count          Count_Type  1 Delete Container   List Position    Cursor Count          Count_Type  1 Delete_First Container   List Count          Count_Type  1 Delete_Last Container   List Count          Count_Type  1 Reverse_Elements Container   List Swap Container   List I              Cursor J              Cursor Swap_Links Container   List I              Cursor J              Cursor Splice Target   List Before      Cursor Source   List Splice Target     List Before        Cursor Source     List Position   Cursor Splice Container   List Before         Cursor Position       Cursor First Container  List  Cursor First_Element Container  List  Element_Type Last Container  List  Cursor Last_Element Container  List  Element_Type Next Position  Cursor  Cursor Previous Position  Cursor  Cursor Next Position   Cursor Previous Position   Cursor Find Container  List Item       Element_Type Position   Cursor  No_Element Cursor Reverse_Find Container  List Item       Element_Type Position   Cursor  No_Element Cursor Contains Container  List Item       Element_Type Boolean Has_Element Position  Cursor  Boolean Iterate Container  List Process       Position   Cursor Reverse_Iterate Container  List Process       Position   Cursor "" Left   Element_Type Right  Element_Type Boolean Generic_Sorting Is_Sorted Container  List  Boolean Sort Container   List Merge Target   List Source   List Generic_Sorting List Empty_List  List Cursor No_Element  Cursor AdaContainersDoubly_Linked_Lists

Wikibook

 * Ada Programming/Libraries/Ada