Consider now, the implementation of the Recursive_Quick_Sort content, requiring a Partition algorithm as contentual context.
genericwith Procedure Partition(Els: in out El_Sequence;
Low,High: in El_Sequence_Ind;
Split: out El_Sequence_Ind);
procedure Recursive_Quick_Sort (Els: in out El_Sequence;
Low,High: in El_Sequence_Ind) implements Sort as
C: El_Sequence_Ind;
begin
if Low < High then
Partition(Els,Low,High,C);
Recursive_Quick_Sort(Els,Low,El_Sequence_Ind'Pred(C));
Recursive_Quick_Sort(Els,El_Sequence_Ind'Succ(C),High);
end if;
end Recursive_Quick_Sort;
Note that the concern encapsulated here is essentially control. The actual partitioning is performed in Partition. Because of this, the control algorithm and both the Element and El_Sequence conceptual context are only "weakly" interconnected. That is, the control algorithm only passes Els as a parameter and does not use the El_Sequence operations provided by the Sort concept. Furthermore, the algorithm makes no reference to operations on Element objects.