DEVELOPMENT EDITION · 769442725406
Library Reference
On this page

Verada.Containers.Unbounded.Ordered_Sets

A limited reclaimed ordered set with array-valued contents.

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

The element type's < must be a strict order consistent with its equality. Include leaves a present member alone; Exclude removes a member if present, and Remove one that must be. The set operators (or, and, -, xor) build new sets, and the comparisons are by inclusion. Copy is explicit.

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

Vibe does not instantiate library generics; 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;
   with function "<" (Left, Right : Element_Type) return Boolean is <>;

API 002

Element_Array (declaration) — Unconstrained Positive-indexed element value array for content snapshots/contracts. A particular Model result has its own lower-bound guarantee; the array type alone does not force every object to start at 1.

Declared interface:

type Element_Array is array (Positive range <>) of Element_Type;

API 003

Has (declaration) — Ghost existential membership predicate over an array model.

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

API 004

Set (declaration) — Limited reclaimed ordered-set state, initially empty; explicit Copy creates a separate value and finalization calls Clear.

Declared interface:

type Set is limited private
  with Default_Initial_Condition => Length (Set) = 0,
       Finalizable => (Finalize => Clear, Relaxed_Finalization => True),
       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.

On normal return the declared contract establishes:

Length'Result < Verada.Storage.Length_Bound

API 006

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

API 007

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:

Model'Result'Length = Length (Container)
               and then (Model'Result'Length = 0 or else Model'Result'First = 1)

API 008

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)

On normal return the declared contract establishes:

Element'Result = Model (Container) (Index)

API 009

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

API 010

Only_Added (declaration) — Ghost relation restricting new set contents to an old member or the newly added item.

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

API 011

Only_Kept (declaration) — Ghost predicate: every element of the set is an element of A, so no element joined; Exclude and Remove state it.

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

API 012

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 013

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)

On normal return the declared contract establishes:

Length (Container) = Length (Container)'Old + 1
               and Contains (Container, Item)
               and (for all X of Model (Container)'Old => Contains (Container, X))
               and Only_Added (Container, Model (Container)'Old, Item)

API 014

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.

On normal return the declared contract establishes:

Contains (Container, Item)
               and Length (Container) = Length (Container)'Old + (if Contains (Container, Item)'Old then 0 else 1)

API 015

Exclude (declaration) — Python's s.discard(x): Item is absent afterwards; it leaves if present, and the other elements stay.

On normal return the declared contract establishes:

not Contains (Container, Item)
               and Length (Container) = Length (Container)'Old - (if Contains (Container, Item)'Old then 1 else 0)
               and (for all X of Model (Container)'Old => (if X /= Item then Contains (Container, X)))
               and Only_Kept (Container, Model (Container)'Old)

API 016

Remove (declaration) — Python's s.remove(x): Item, which must be present, leaves; the other elements stay.

Before this operation, establish:

Contains (Container, Item)

On normal return the declared contract establishes:

not Contains (Container, Item)
               and Length (Container) = Length (Container)'Old - 1
               and (for all X of Model (Container)'Old => (if X /= Item then Contains (Container, X)))
               and Only_Kept (Container, Model (Container)'Old)

API 017

"or" (declaration) — Python's s | t: a new set of the elements of either operand, under the combined length guard.

On normal return the declared contract establishes:

Length ("or"'Result) <= Length (Left) + Length (Right)
               and then (for all I in 1 .. Length ("or"'Result) =>
                           Contains (Left, Element ("or"'Result, I)) or else Contains (Right, Element ("or"'Result, I)))
               and then (for all I in 1 .. Length (Left) => Contains ("or"'Result, Element (Left, I)))
               and then (for all I in 1 .. Length (Right) => Contains ("or"'Result, Element (Right, I)))

API 018

"and" (declaration) — Python's s & t: a new set of the elements of both operands.

On normal return the declared contract establishes:

Length ("and"'Result) <= Length (Left)
               and then (for all I in 1 .. Length ("and"'Result) =>
                           Contains (Left, Element ("and"'Result, I)) and then Contains (Right, Element ("and"'Result, I)))
               and then (for all I in 1 .. Length (Left) =>
                           (if Contains (Right, Element (Left, I)) then Contains ("and"'Result, Element (Left, I))))

API 019

"-" (declaration) — Python's s - t: a new set of Left's elements that are not Right's.

On normal return the declared contract establishes:

Length ("-"'Result) <= Length (Left)
               and then (for all I in 1 .. Length ("-"'Result) =>
                           Contains (Left, Element ("-"'Result, I)) and then not Contains (Right, Element ("-"'Result, I)))
               and then (for all I in 1 .. Length (Left) =>
                           (if not Contains (Right, Element (Left, I)) then Contains ("-"'Result, Element (Left, I))))

API 020

"xor" (declaration) — Python's s ^ t: a new set of the elements of exactly one operand, under the combined length guard.

On normal return the declared contract establishes:

Length ("xor"'Result) <= Length (Left) + Length (Right)
               and then (for all I in 1 .. Length ("xor"'Result) =>
                           Contains (Left, Element ("xor"'Result, I)) /= Contains (Right, Element ("xor"'Result, I)))
               and then (for all I in 1 .. Length (Left) =>
                           (if not Contains (Right, Element (Left, I)) then Contains ("xor"'Result, Element (Left, I))))
               and then (for all I in 1 .. Length (Right) =>
                           (if not Contains (Left, Element (Right, I)) then Contains ("xor"'Result, Element (Right, I))))

API 021

"<=" (declaration) — Python's s <= t and s.issubset(t): every element of Left is Right's.

API 022

"=" (declaration) — Python's s == t: each set is included in the other, so they have the same elements.

API 023

"<" (declaration) — Python's s < t: Left is included in Right and is not the whole of it.

API 024

">=" (declaration) — Python's s >= t: Right is included in Left.

API 025

">" (declaration) — Python's s > t: Right is a proper subset of Left.

API 026

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

API 027

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

API 028

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

API 029

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

Before this operation, establish:

Iter_Has_Element (Container, Position)

API 030

Copy (declaration) — Explicitly create the source's logical contents in a mutable target. Observe language alias/ownership rules; this is not a shallow owner assignment.

On normal return the declared contract establishes:

Model (Target) = Model (Source)