| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT LIBRARY COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- A D A . C O N T A I N E R S . S T A B L E _ S O R T I N G -- |
| 6 |
-- -- |
| 7 |
-- S p e c -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 1995-2025, AdaCore -- |
| 10 |
-- -- |
| 11 |
-- GNAT is free software; you can redistribute it and/or modify it under -- |
| 12 |
-- terms of the GNU General Public License as published by the Free Soft- -- |
| 13 |
-- ware Foundation; either version 3, or (at your option) any later ver- -- |
| 14 |
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
| 15 |
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
| 16 |
-- or FITNESS FOR A PARTICULAR PURPOSE. -- |
| 17 |
-- -- |
| 18 |
-- As a special exception under Section 7 of GPL version 3, you are granted -- |
| 19 |
-- additional permissions described in the GCC Runtime Library Exception, -- |
| 20 |
-- version 3.1, as published by the Free Software Foundation. -- |
| 21 |
-- -- |
| 22 |
-- You should have received a copy of the GNU General Public License and -- |
| 23 |
-- a copy of the GCC Runtime Library Exception along with this program; -- |
| 24 |
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- |
| 25 |
-- <http://www.gnu.org/licenses/>. -- |
| 26 |
-- -- |
| 27 |
-- GNAT was originally developed by the GNAT team at New York University. -- |
| 28 |
-- Extensive contributions were provided by Ada Core Technologies Inc. -- |
| 29 |
-- -- |
| 30 |
------------------------------------------------------------------------------ |
| 31 |
|
| 32 |
-- Stable_Sorting package |
| 33 |
|
| 34 |
-- This package provides a generic stable sorting procedure that is |
| 35 |
-- intended for use by the various doubly linked list container generics. |
| 36 |
-- If a stable array sorting algorithm with better-than-quadratic worst |
| 37 |
-- case execution time is ever needed, then it could also reside here. |
| 38 |
|
| 39 |
private package Ada.Containers.Stable_Sorting is |
| 40 |
pragma Annotate (CodePeer, Skip_Analysis); |
| 41 |
pragma Pure; |
| 42 |
pragma Remote_Types; |
| 43 |
|
| 44 |
-- Stable sorting algorithms with N-log-N worst case execution time. |
| 45 |
|
| 46 |
generic |
| 47 |
type Node_Ref is private; -- access value or array index |
| 48 |
Nil : Node_Ref; |
| 49 |
package List_Descriptors is |
| 50 |
|
| 51 |
type List_Descriptor is |
| 52 |
record |
| 53 |
First, Last : Node_Ref := Nil; |
| 54 |
Length : Count_Type := 0; |
| 55 |
end record; |
| 56 |
|
| 57 |
-- We use a nested generic here so that the inner generic can |
| 58 |
-- refer to the List_Descriptor type. |
| 59 |
|
| 60 |
generic |
| 61 |
with function Next (N : Node_Ref) return Node_Ref is <>; |
| 62 |
with procedure Set_Next (N : Node_Ref; Next : Node_Ref) is <>; |
| 63 |
with procedure Set_Prev (N : Node_Ref; Prev : Node_Ref) is <>; |
| 64 |
with function "<" (L, R : Node_Ref) return Boolean is <>; |
| 65 |
|
| 66 |
with procedure Update_Container (List : List_Descriptor) is <>; |
| 67 |
procedure Doubly_Linked_List_Sort (List : List_Descriptor); |
| 68 |
|
| 69 |
end List_Descriptors; |
| 70 |
|
| 71 |
end Ada.Containers.Stable_Sorting; |