]>
Commit | Line | Data |
---|---|---|
8c18a165 AC |
1 | ------------------------------------------------------------------------------ |
2 | -- -- | |
3 | -- GNAT LIBRARY COMPONENTS -- | |
4 | -- -- | |
5 | -- ADA.CONTAINERS.GENERIC_SORT -- | |
6 | -- -- | |
7 | -- S p e c -- | |
8 | -- -- | |
1d005acc | 9 | -- Copyright (C) 2011-2019, Free Software Foundation, Inc. -- |
8c18a165 AC |
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 | -- This unit was originally developed by Matthew J Heaney. -- | |
28 | ------------------------------------------------------------------------------ | |
29 | ||
30 | -- Allows an anonymous array (or array-like container) to be sorted. Generic | |
31 | -- formal Before returns the result of comparing the elements designated by | |
32 | -- the indexes, and generic formal Swap exchanges the designated elements. | |
33 | ||
34 | generic | |
35 | type Index_Type is (<>); | |
36 | with function Before (Left, Right : Index_Type) return Boolean; | |
37 | with procedure Swap (Left, Right : Index_Type); | |
38 | ||
39 | procedure Ada.Containers.Generic_Sort (First, Last : Index_Type'Base); | |
40 | pragma Pure (Ada.Containers.Generic_Sort); | |
27ebda19 PMR |
41 | -- Reorders the elements of an indexable structure, over the range |
42 | -- First .. Last, such that the elements are sorted in the ordering determined | |
43 | -- by the generic formal function Before; Before should return True if Left is | |
44 | -- to be sorted before Right. The generic formal Before compares the elements | |
45 | -- having the given indices, and the generic formal Swap exchanges the values | |
46 | -- of the indicated elements. Any exception raised during evaluation of Before | |
47 | -- or Swap is propagated. | |
48 | -- | |
49 | -- The actual function for the generic formal function "<" is expected to | |
50 | -- return the same value each time it is called with a particular pair of | |
51 | -- element values. It should not modify Container and it should define a | |
52 | -- strict weak ordering relationship: irreflexive, asymmetric, transitive, and | |
53 | -- in addition, if x < y for any values x and y, then for all other values z, | |
54 | -- (x < z) or (z < y). If the actual for "<" behaves in some other manner, | |
55 | -- the behavior of the instance of Generic_Sort is unspecified. The number of | |
56 | -- times Generic_Sort calls "<" is unspecified. |