On this page
Verada.Containers.Arenas
Bounded generation-stamped handles for shared/cyclic structures.
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
Handles must be paired with the matching arena. Has_Room accounts for retired exhausted generations. Other live handles/values are preserved by each mutation.
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.Arenas;
package Instance_Name is new Verada.Containers.Arenas (Integer, 8);import Verada.Containers.Arenas;
package Instance_Name = new Verada.Containers.Arenas<Integer, 8>;
A Vibe module imports this unit's names with from Verada.Containers.Arenas 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
Handle (declaration) — Nonnegative signed64 handle domain; zero means No_Handle. A nonzero number is usable only after Valid establishes its slot/generation in the matching arena.
Declared interface:
subtype Handle is Long_Long_Integer range 0 .. Long_Long_Integer'Last;API 003
No_Handle (declaration) — Zero sentinel denoting no arena element; Valid is false for it.
Declared interface:
No_Handle : constant Handle := 0;API 004
Arena (declaration) — Copyable bounded slot state, initially with no valid handles. Pair handles with the correct arena history; copying the arena does not add a global handle-owner identity.
Declared interface:
type Arena is private
with Default_Initial_Condition => (for all H in Handle => not Valid (Arena, H));API 005
Valid (declaration) — Test an arena handle against this arena's current slot/generation state. It is not the unrelated language attribute Valid.
On normal return the declared contract establishes:
(if Valid'Result then H /= No_Handle)API 006
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:
Valid (A, H)API 007
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 008
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:
(for all G in Handle => Models.Has_Key (Model'Result, G) = Valid (A, G))
and then (for all I in 1 .. Models.Length (Model'Result) =>
Valid (A, Models.Key_At (Model'Result, I))
and then Models.Element_At (Model'Result, I) = Element (A, Models.Key_At (Model'Result, I)))Ghost: for contracts and ghost code, and left out of the program.
API 009
Has_Room (declaration) — Test whether the arena has a reusable unoccupied, nonexhausted generation slot.
API 010
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:
Has_Room (A)On normal return the declared contract establishes:
Valid (A, H) and then Element (A, H) = Item
and then not Valid (A'Old, H)
and then (for all G in Handle => (if G /= H then Valid (A, G) = Valid (A'Old, G)))
and then (for all G in Handle => (if G /= H and then Valid (A'Old, G) then Element (A, G) = Element (A'Old, G)))API 011
Replace_Element (declaration) — Replace one present value while preserving logical length and the other values/positions specified by the contract.
Before this operation, establish:
Valid (A, H)On normal return the declared contract establishes:
Valid (A, H) and then Element (A, H) = Item
and then Has_Room (A) = Has_Room (A'Old)
and then (for all G in Handle => Valid (A, G) = Valid (A'Old, G))
and then (for all G in Handle => (if G /= H and then Valid (A'Old, G) then Element (A, G) = Element (A'Old, G)))API 012
Remove (declaration) — Return/remove the selected present entry according to this family; ghost functional updates return a new value while arena mutation invalidates its handle.
Before this operation, establish:
Valid (A, H)On normal return the declared contract establishes:
not Valid (A, H)
and then (for all G in Handle => (if G /= H then Valid (A, G) = Valid (A'Old, G)))
and then (for all G in Handle => (if G /= H and then Valid (A'Old, G) then Element (A, G) = Element (A'Old, G)))