DEVELOPMENT EDITION · 769442725406
Library Reference
On this page

Verada.Containers.Formal.Ordered_Sets

A fixed-capacity set stored in comparison order.

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

Supply a consistent strict ordering. Insert requires absence/room; Include permits existing members. Positions can shift. No Remove or runtime union/intersection is declared.

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.Ordered_Sets;
package Instance_Name is new Verada.Containers.Formal.Ordered_Sets (Integer, 8);
import Verada.Containers.Formal.Ordered_Sets;
package Instance_Name = new Verada.Containers.Formal.Ordered_Sets<Integer, 8>;

A Vibe module imports this unit's names with from Verada.Containers.Formal.Ordered_Sets 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;
   with function "<" (Left, Right : Element_Type) return Boolean is <>;

API 002

Extended_Index (declaration) — Capacity-bounded length/search-result domain including zero. A nonzero search result still needs the declared existence property.

Declared interface:

subtype Extended_Index is Natural range 0 .. Capacity;

API 003

Index_Type (declaration) — Capacity-bounded positive position domain; a read must additionally establish the position is at most current Length.

Declared interface:

subtype Index_Type is Positive range 1 .. Capacity;

API 004

Set (declaration) — Copyable fixed-capacity ordered-membership state, initially empty; use a consistent comparison and allow numeric positions to shift during insertion.

Declared interface:

type Set is private
  with Default_Initial_Condition => Length (Set) = 0,
       Iterable => (First => Iter_First, Next => Iter_Next, Has_Element => Iter_Has_Element, Element => Iter_Element);

API 005

Length (declaration) — Observe the logical length/cardinality, not backing capacity or physical allocation size.

API 006

Is_Empty (declaration) — Test whether logical length is zero; this is safe before an element selection.

API 007

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:

Index <= Length (Container)

API 008

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 009

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)
               and then (for all I in 1 .. Length (Container) => Models.Get (Model'Result, I) = Element (Container, I))

Ghost: for contracts and ghost code, and left out of the program.

API 010

Contains (declaration) — Test the family's declared membership/search relation; it is not a mutation or a guarantee of constant-time lookup.

API 011

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) = 0

API 012

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 Contains (Container, Item) and then Length (Container) < Capacity

On normal return the declared contract establishes:

Length (Container) = Length (Container)'Old + 1
               and then Contains (Container, Item)
               and then (for all I in 1 .. Length (Container'Old) => Contains (Container, Element (Container'Old, I)))
               and then (for all I in 1 .. Length (Container) => Element (Container, I) = Item or else Contains (Container'Old, Element (Container, I)))

API 013

Include (declaration) — Ensure an item/key is present: preserve a duplicate set member or upsert a dictionary value. Only a genuinely new entry needs extra room.

Before this operation, establish:

Contains (Container, Item) or else Length (Container) < Capacity

On normal return the declared contract establishes:

Contains (Container, Item)

               and then Models.Contains (Model (Container), Item)
               and then (for all I in 1 .. Length (Container'Old) => Contains (Container, Element (Container'Old, I)))
               and then (for all I in 1 .. Length (Container) => Element (Container, I) = Item or else Contains (Container'Old, Element (Container, I)))

API 014

Iter_First (declaration) — Return the first candidate iteration position. Call Has_Element before selecting an element; empty input can still have a candidate.

API 015

Iter_Next (declaration) — Advance the candidate position under the declared sentinel/finite-bound behavior.

API 016

Iter_Has_Element (declaration) — Test whether an iteration candidate denotes a currently present logical element.

API 017

Iter_Element (declaration) — Read the iteration element after establishing Iter_Has_Element.

Before this operation, establish:

Iter_Has_Element (Container, Position)