On this page
- Availability and ownership
- Import and instantiate
- Contract and lifecycle reading
- API 001
- API 002
- API 003
- API 004
- API 005
- API 006
- API 007
- API 008
- API 009
- API 010
- API 011
- API 012
- API 013
- API 014
- API 015
- API 016
- API 017
- API 018
- API 019
- API 020
- API 021
- API 022
- API 023
- API 024
- API 025
- API 026
- API 027
- API 028
- API 029
- API 030
- API 031
- API 032
- API 033
- API 034
Verada.Containers.Formal.Doubly_Linked_Lists
A fixed-capacity ordered sequence with node cursors.
Read the family guide for representation, selection and resource rules. The complete declaration page retains exact signatures/contracts; the source specification is the implementation baseline.
Availability and ownership
Capacity is positive, and mutation preconditions require room or presence. A cursor that survives other insertions and deletions keeps its node, while its sequence place may change. A cursor is a node number with no generation, so a deleted cursor must be discarded: a later insertion can reuse its slot. Use a cursor only with its own list.
A client proof uses these contracts without proving the body again (see library assurance). Global => null excludes package-global effects, not changes made through an in out argument.
Import and instantiate
Place the declaration in a declarative part, with the actuals your program needs.
with Verada.Containers.Formal.Doubly_Linked_Lists;
package Instance_Name is new Verada.Containers.Formal.Doubly_Linked_Lists (Integer, 8);import Verada.Containers.Formal.Doubly_Linked_Lists;
package Instance_Name = new Verada.Containers.Formal.Doubly_Linked_Lists<Integer, 8>;
A Vibe module imports this unit's names with from Verada.Containers.Formal.Doubly_Linked_Lists import Name; see library use across syntaxes. In Varc, keep each name's declared spelling and write & on arguments the call changes.
Contract and lifecycle reading
A Pre condition is the caller's obligation; a Post is what a normal return guarantees. What a postcondition does not state, a client cannot assume. Ghost functions are for contracts and ghost code. The family guide describes copying, lifetime, order and cost.
API 001
Generic formals (declaration) — Generic actuals establish this instance's nominal types and declared operations. Private formals require suitable definite nonlimited actuals; capacity/comparison/float restrictions are shown below. Defaulted comparison is resolved from the actual type, not an automatic proof of ordering laws.
Declared interface:
generic
type Element_Type is private;
Capacity : Positive;API 002
Count_Type (declaration) — Natural-based logical count domain bounded by this instance Capacity.
Declared interface:
subtype Count_Type is Natural range 0 .. Capacity;API 003
List (declaration) — Copyable bounded list state, initially empty, with inline node storage and a ghost sequence model.
Declared interface:
type List is private
with Default_Initial_Condition => Length (List) = 0;API 004
Cursor (declaration) — Node-slot token with Node initially zero. It has no container identity or generation protection against deleted-slot reuse.
Declared interface:
type Cursor is record
Node : Count_Type := 0;
end record;Public nested members: Node (Count_Type, default 0). Node is a slot token, not a generation or container identity. Retire deleted cursor values; later slot reuse can make their number present again.
API 005
No_Element (declaration) — Cursor(Node=>0) sentinel returned for an absent/end position.
Declared interface:
No_Element : constant Cursor := (Node => 0);API 006
Length (declaration) — Observe the logical length/cardinality, not backing capacity or physical allocation size.
API 007
Is_Empty (declaration) — Test whether logical length is zero; this is safe before an element selection.
API 008
Is_Full (declaration) — Test whether the bounded container has reached its generic Capacity.
API 009
Models (declaration) — The named functional-model generic instance used to state this concrete container's abstraction relation; use its own model operations and types.
API 010
Model (declaration) — Observe contents in the stated model type; a ghost functional model differs from an executable array-valued snapshot.
On normal return the declared contract establishes:
Models.Length (Model'Result) = Length (Container)Ghost: for contracts and ghost code, and left out of the program.
API 011
Node_At (declaration) — The node of the list's element at a place, from 1: the inverse of Node_Index, in which Node_Index's contract is stated.
Before this operation, establish:
Index <= Length (Container)Ghost: for contracts and ghost code, and left out of the program.
API 012
Node_Index (declaration) — Map a list node number to its current one-based sequence place, or zero when absent.
On normal return the declared contract establishes:
Node_Index'Result <= Length (Container)
and then (if Node = 0 then Node_Index'Result = 0)
and then (if Node_Index'Result /= 0 then Node_At (Container, Node_Index'Result) = Node)
and then (for all I in 1 .. Length (Container) => (Node_At (Container, I) = Node) = (I = Node_Index'Result))API 013
Index_Of (declaration) — Map a list cursor to its current logical position; positions can change while a surviving node remains present.
API 014
Has_Element (declaration) — Test whether a cursor currently designates an element of this list.
API 015
Element (declaration) — Read an existing logical element; the required index/cursor/presence condition is distinct from the index type's capacity bound.
Before this operation, establish:
Has_Element (Container, Position)On normal return the declared contract establishes:
Element'Result = Models.Get (Model (Container), Index_Of (Container, Position))API 016
Same_Places (declaration) — Ghost assertion that all list nodes have unchanged logical positions.
Ghost: for contracts and ghost code, and left out of the program.
API 017
Places_Shifted_Up (declaration) — Ghost relation tracking surviving list cursor positions after insertion.
Ghost: for contracts and ghost code, and left out of the program.
API 018
Places_Shifted_Down (declaration) — Ghost relation tracking surviving list cursor positions after removal.
Ghost: for contracts and ghost code, and left out of the program.
API 019
Inserted (declaration) — Ghost relation describing insertion into the model, including shifted suffix/preserved prefix.
Ghost: for contracts and ghost code, and left out of the program.
API 020
Removed (declaration) — Ghost relation describing a deleted model element and the shifted surviving suffix.
Ghost: for contracts and ghost code, and left out of the program.
API 021
First (declaration) — Return the first list cursor or No_Element on an empty list.
On normal return the declared contract establishes:
(if Is_Empty (Container) then First'Result = No_Element else Index_Of (Container, First'Result) = 1)API 022
Last (declaration) — Return the final sequence position or last list cursor according to its result type; check the family's empty sentinel.
On normal return the declared contract establishes:
(if Is_Empty (Container) then Last'Result = No_Element else Index_Of (Container, Last'Result) = Length (Container))API 023
Next (declaration) — Return the next list cursor, or No_Element beyond the end; the input cursor must be present.
Before this operation, establish:
Has_Element (Container, Position)On normal return the declared contract establishes:
(if Index_Of (Container, Position) = Length (Container) then Next'Result = No_Element
else Index_Of (Container, Next'Result) = Index_Of (Container, Position) + 1)API 024
Previous (declaration) — Return the previous list cursor, or No_Element before the beginning; input cursor must be present.
Before this operation, establish:
Has_Element (Container, Position)On normal return the declared contract establishes:
(if Index_Of (Container, Position) = 1 then Previous'Result = No_Element
else Index_Of (Container, Previous'Result) = Index_Of (Container, Position) - 1)API 025
Find (declaration) — Search for a key/item and return its position/cursor or the declared absent sentinel. The exact contract determines whether first-match/completeness is promised.
On normal return the declared contract establishes:
(if Find'Result = No_Element then
(for all I in 1 .. Length (Container) => Models.Get (Model (Container), I) /= Item)
else Has_Element (Container, Find'Result) and then Element (Container, Find'Result) = Item)API 026
Contains (declaration) — Test the family's declared membership/search relation; it is not a mutation or a guarantee of constant-time lookup.
API 027
Clear (declaration) — Make the logical container empty. Storage release, cursor validity and inactive-slot contents follow this family's lifecycle rules, not a universal secure-erasure contract.
On normal return the declared contract establishes:
Length (Container) = 0API 028
Insert (declaration) — Add a new element/pair at the family's specified position/order. Absence, room and cursor/index requirements are independent caller obligations.
Before this operation, establish:
not Is_Full (Container) and then (Before = No_Element or else Has_Element (Container, Before))On normal return the declared contract establishes:
Inserted (Model (Container'Old), Model (Container),
(if Before = No_Element then Length (Container'Old) + 1 else Index_Of (Container'Old, Before)), New_Item)
and then Index_Of (Container, Position) = (if Before = No_Element then Length (Container'Old) + 1 else Index_Of (Container'Old, Before))
and then Places_Shifted_Up (Container'Old, Container, Index_Of (Container, Position))API 029
Append (declaration) — Append the item(s), subject to the exact finite capacity/length guard; preserve old logical contents as stated by the postcondition.
Before this operation, establish:
not Is_Full (Container)On normal return the declared contract establishes:
Inserted (Model (Container'Old), Model (Container), Length (Container), New_Item)
and then Places_Shifted_Up (Container'Old, Container, Length (Container))API 030
Prepend (declaration) — Insert before all current list elements, requiring room.
Before this operation, establish:
not Is_Full (Container)On normal return the declared contract establishes:
Inserted (Model (Container'Old), Model (Container), 1, New_Item)
and then Places_Shifted_Up (Container'Old, Container, 1)API 031
Replace_Element (declaration) — Replace one present value while preserving logical length and the other values/positions specified by the contract.
Before this operation, establish:
Has_Element (Container, Position)On normal return the declared contract establishes:
Length (Container) = Length (Container'Old)
and then Element (Container, Position) = New_Item
and then Same_Places (Container'Old, Container)
and then (for all I in 1 .. Length (Container) =>
(if I /= Index_Of (Container, Position) then Models.Get (Model (Container), I) = Models.Get (Model (Container'Old), I)))API 032
Delete (declaration) — Remove the element designated by a mutable cursor and set that cursor to No_Element; discard other copies of the deleted cursor.
Before this operation, establish:
Has_Element (Container, Position)On normal return the declared contract establishes:
Removed (Model (Container'Old), Model (Container), Index_Of (Container'Old, Position'Old))
and then Position = No_Element
and then not Has_Element (Container, Position'Old)
and then Places_Shifted_Down (Container'Old, Container, Index_Of (Container'Old, Position'Old))API 033
Delete_First (declaration) — Remove the first element from a nonempty list, shifting surviving sequence places.
Before this operation, establish:
not Is_Empty (Container)On normal return the declared contract establishes:
Removed (Model (Container'Old), Model (Container), 1)
and then Places_Shifted_Down (Container'Old, Container, 1)API 034
Delete_Last (declaration) — Remove the last logical element; nonempty input is required. No removed value is returned.
Before this operation, establish:
not Is_Empty (Container)On normal return the declared contract establishes:
Removed (Model (Container'Old), Model (Container), Length (Container'Old))
and then Places_Shifted_Down (Container'Old, Container, Length (Container'Old))