-- Adjust --
------------
- procedure Adjust is
- new Tree_Operations.Generic_Adjust (Copy_Tree);
+ procedure Adjust is new Tree_Operations.Generic_Adjust (Copy_Tree);
procedure Adjust (Container : in out Set) is
begin
function Ceiling (Container : Set; Item : Element_Type) return Cursor is
Node : constant Node_Access :=
Element_Keys.Ceiling (Container.Tree, Item);
-
begin
- if Node = null then
- return No_Element;
- end if;
-
- return Cursor'(Container'Unrestricted_Access, Node);
+ return (if Node = null then No_Element
+ else Cursor'(Container'Unrestricted_Access, Node));
end Ceiling;
-----------
procedure Delete_First (Container : in out Set) is
Tree : Tree_Type renames Container.Tree;
X : Node_Access := Tree.First;
-
begin
if X /= null then
Tree_Operations.Delete_Node_Sans_Free (Tree, X);
procedure Delete_Last (Container : in out Set) is
Tree : Tree_Type renames Container.Tree;
X : Node_Access := Tree.Last;
-
begin
if X /= null then
Tree_Operations.Delete_Node_Sans_Free (Tree, X);
end Difference;
function Difference (Left, Right : Set) return Set is
- Tree : constant Tree_Type :=
- Set_Ops.Difference (Left.Tree, Right.Tree);
+ Tree : constant Tree_Type := Set_Ops.Difference (Left.Tree, Right.Tree);
begin
return Set'(Controlled with Tree);
end Difference;
function Equivalent_Elements (Left, Right : Element_Type) return Boolean is
begin
- if Left < Right
- or else Right < Left
- then
+ if Left < Right or else Right < Left then
return False;
else
return True;
procedure Exclude (Container : in out Set; Item : Element_Type) is
X : Node_Access :=
Element_Keys.Find (Container.Tree, Item);
-
begin
if X /= null then
Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
function First (Container : Set) return Cursor is
begin
- if Container.Tree.First = null then
- return No_Element;
- end if;
-
- return Cursor'(Container'Unrestricted_Access, Container.Tree.First);
+ return
+ (if Container.Tree.First = null then No_Element
+ else Cursor'(Container'Unrestricted_Access, Container.Tree.First));
end First;
function First (Object : Iterator) return Cursor is
Node : constant Node_Access :=
Element_Keys.Floor (Container.Tree, Item);
begin
- if Node = null then
- return No_Element;
- else
- return Cursor'(Container'Unrestricted_Access, Node);
- end if;
+ return (if Node = null then No_Element
+ else Cursor'(Container'Unrestricted_Access, Node));
end Floor;
----------
function Ceiling (Container : Set; Key : Key_Type) return Cursor is
Node : constant Node_Access :=
Key_Keys.Ceiling (Container.Tree, Key);
-
begin
- if Node = null then
- return No_Element;
- end if;
-
- return Cursor'(Container'Unrestricted_Access, Node);
+ return (if Node = null then No_Element
+ else Cursor'(Container'Unrestricted_Access, Node));
end Ceiling;
--------------
function Equivalent_Keys (Left, Right : Key_Type) return Boolean is
begin
- if Left < Right
- or else Right < Left
- then
+ if Left < Right or else Right < Left then
return False;
else
return True;
procedure Exclude (Container : in out Set; Key : Key_Type) is
X : Node_Access := Key_Keys.Find (Container.Tree, Key);
-
begin
if X /= null then
Tree_Operations.Delete_Node_Sans_Free (Container.Tree, X);
function Find (Container : Set; Key : Key_Type) return Cursor is
Node : constant Node_Access :=
Key_Keys.Find (Container.Tree, Key);
-
begin
- if Node = null then
- return No_Element;
- end if;
-
- return Cursor'(Container'Unrestricted_Access, Node);
+ return (if Node = null then No_Element
+ else Cursor'(Container'Unrestricted_Access, Node));
end Find;
-----------
function Floor (Container : Set; Key : Key_Type) return Cursor is
Node : constant Node_Access :=
Key_Keys.Floor (Container.Tree, Key);
-
begin
- if Node = null then
- return No_Element;
- end if;
-
- return Cursor'(Container'Unrestricted_Access, Node);
+ return (if Node = null then No_Element
+ else Cursor'(Container'Unrestricted_Access, Node));
end Floor;
-------------------------
function Is_Greater_Key_Node
(Left : Key_Type;
- Right : Node_Access) return Boolean is
+ Right : Node_Access) return Boolean
+ is
begin
return Key (Right.Element.all) < Left;
end Is_Greater_Key_Node;
function Is_Less_Key_Node
(Left : Key_Type;
- Right : Node_Access) return Boolean is
+ Right : Node_Access) return Boolean
+ is
begin
return Left < Key (Right.Element.all);
end Is_Less_Key_Node;
function Is_Greater_Element_Node
(Left : Element_Type;
- Right : Node_Access) return Boolean is
+ Right : Node_Access) return Boolean
+ is
begin
-- e > node same as node < e
function Is_Less_Element_Node
(Left : Element_Type;
- Right : Node_Access) return Boolean is
+ Right : Node_Access) return Boolean
+ is
begin
return Left < Right.Element.all;
end Is_Less_Element_Node;
function Last (Container : Set) return Cursor is
begin
- if Container.Tree.Last = null then
- return No_Element;
- else
- return Cursor'(Container'Unrestricted_Access, Container.Tree.Last);
- end if;
+ return
+ (if Container.Tree.Last = null then No_Element
+ else Cursor'(Container'Unrestricted_Access, Container.Tree.Last));
end Last;
function Last (Object : Iterator) return Cursor is
begin
- if Object.Container.Tree.Last = null then
- return No_Element;
- else
- return Cursor'(
- Object.Container.all'Unrestricted_Access,
- Object.Container.Tree.Last);
- end if;
+ return (if Object.Container.Tree.Last = null then No_Element
+ else Cursor'(Object.Container.all'Unrestricted_Access,
+ Object.Container.Tree.Last));
end Last;
------------------
-- Move --
----------
- procedure Move is
- new Tree_Operations.Generic_Move (Clear);
+ procedure Move is new Tree_Operations.Generic_Move (Clear);
procedure Move (Target : in out Set; Source : in out Set) is
begin
declare
Node : constant Node_Access :=
Tree_Operations.Next (Position.Node);
-
begin
- if Node = null then
- return No_Element;
- end if;
-
- return Cursor'(Position.Container, Node);
+ return (if Node = null then No_Element
+ else Cursor'(Position.Container, Node));
end;
end Next;
declare
Node : constant Node_Access :=
Tree_Operations.Previous (Position.Node);
-
begin
- if Node = null then
- return No_Element;
- end if;
-
- return Cursor'(Position.Container, Node);
+ return (if Node = null then No_Element
+ else Cursor'(Position.Container, Node));
end;
end Previous;
pragma Inline (New_Node);
procedure Local_Insert_Post is
- new Element_Keys.Generic_Insert_Post (New_Node);
+ new Element_Keys.Generic_Insert_Post (New_Node);
procedure Local_Insert_Sans_Hint is
- new Element_Keys.Generic_Conditional_Insert (Local_Insert_Post);
+ new Element_Keys.Generic_Conditional_Insert (Local_Insert_Post);
procedure Local_Insert_With_Hint is
- new Element_Keys.Generic_Conditional_Insert_With_Hint
- (Local_Insert_Post,
- Local_Insert_Sans_Hint);
+ new Element_Keys.Generic_Conditional_Insert_With_Hint
+ (Local_Insert_Post,
+ Local_Insert_Sans_Hint);
--------------
-- New_Node --
Node.Parent := null;
Node.Right := null;
Node.Left := null;
-
return Node;
end New_Node;
------------
function To_Set (New_Item : Element_Type) return Set is
- Tree : Tree_Type;
-
+ Tree : Tree_Type;
Node : Node_Access;
Inserted : Boolean;
pragma Unreferenced (Node, Inserted);
-
begin
Insert_Sans_Hint (Tree, New_Item, Node, Inserted);
return Set'(Controlled with Tree);