From 255533f407cb4cfa0644fbbeff64a1b36c7b99ce Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Fri, 9 May 2025 16:39:12 +0300 Subject: [PATCH] =?UTF-8?q?IsOrdered=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=20?= =?UTF-8?q?=D1=80=D0=B0=D1=81=D1=88=D0=B8=D1=80=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 4 +- Release/pabcversion.txt | 2 +- ReleaseGenerators/PascalABCNET_version.nsh | 2 +- TestSuite/CompilationSamples/PABCSystem.pas | 98 ++++++++++++++++++++- bin/Lib/PABCSystem.pas | 98 ++++++++++++++++++++- 6 files changed, 199 insertions(+), 7 deletions(-) diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 71e39b03f..e4eed8ff3 100644 --- a/Configuration/GlobalAssemblyInfo.cs +++ b/Configuration/GlobalAssemblyInfo.cs @@ -15,7 +15,7 @@ internal static class RevisionClass public const string Major = "3"; public const string Minor = "10"; public const string Build = "3"; - public const string Revision = "3619"; + public const string Revision = "3620"; public const string MainVersion = Major + "." + Minor; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; diff --git a/Configuration/Version.defs b/Configuration/Version.defs index ebfc697ba..4db75c7e0 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%MINOR%=10 -%REVISION%=3619 %COREVERSION%=3 +%REVISION%=3620 +%MINOR%=10 %MAJOR%=3 diff --git a/Release/pabcversion.txt b/Release/pabcversion.txt index 2a87c7034..74479c2dd 100644 --- a/Release/pabcversion.txt +++ b/Release/pabcversion.txt @@ -1 +1 @@ -3.10.3.3619 +3.10.3.3620 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index c63aa6c09..fc34c20b9 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.10.3.3619' +!define VERSION '3.10.3.3620' diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index 3a47974bd..810dd6054 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -11195,6 +11195,66 @@ begin Result := Self.OrderByDescending(x -> x, System.StringComparer.Ordinal); end; +/// Проверяет, отсортирована ли последовательность по возрастанию +function IsOrdered(self: sequence of T): boolean; extensionmethod; where T: System.IComparable; +begin + var prev: T; + var first := True; + foreach var current in self do + begin + if not first and (prev.CompareTo(current) > 0) then + exit(False); + prev := current; + first := False; + end; + Result := True; +end; + +/// Проверяет, отсортирована ли последовательность по возрастанию в порядке, заданном компаратором comparer +function IsOrdered(self: sequence of T; comparer: IComparer): boolean; extensionmethod; +begin + var prev: T; + var first := True; + foreach var current in self do + begin + if not first and (comparer.Compare(prev, current) > 0) then + exit(False); + prev := current; + first := False; + end; + Result := True; +end; + +/// Проверяет, отсортирована ли последовательность по убыванию +function IsOrderedDescending(self: sequence of T): boolean; extensionmethod; where T: System.IComparable; +begin + var prev: T; + var first := True; + foreach var current in self do + begin + if not first and (prev.CompareTo(current) < 0) then + exit(False); + prev := current; + first := False; + end; + Result := True; +end; + +/// Проверяет, отсортирована ли последовательность по убыванию в порядке, заданном компаратором comparer +function IsOrderedDescending(self: sequence of T; comparer: IComparer): boolean; extensionmethod; +begin + var prev: T; + var first := True; + foreach var current in self do + begin + if not first and (comparer.Compare(prev, current) < 0) then // Обратный знак + exit(False); + prev := current; + first := False; + end; + Result := True; +end; + /// Возвращает множество HashSet по данной последовательности function ToHashSet(Self: sequence of T): HashSet; extensionmethod; begin @@ -13342,13 +13402,49 @@ begin System.Array.Copy(a,Self,a.Length); end; - /// Возвращает индекс последнего элемента массива function High(Self: System.Array); extensionmethod := High(Self); /// Возвращает индекс первого элемента массива function Low(Self: System.Array); extensionmethod := Low(Self); +/// Проверяет, отсортирован ли массив по возрастанию +function IsOrdered(self: array of T): boolean; extensionmethod; where T: System.IComparable; +begin + for var i := 0 to self.High - 1 do + if self[i].CompareTo(self[i + 1]) > 0 then + exit(False); + Result := True; +end; + +/// Проверяет, отсортирован ли массив в порядке, заданном компаратором comparer +function IsOrdered(self: array of T; comparer: IComparer): boolean; extensionmethod; +begin + for var i := 0 to self.High - 1 do + if comparer.Compare(self[i], self[i + 1]) > 0 then + exit(False); + Result := True; +end; + +/// Проверяет, отсортирован ли массив по убыванию +function IsOrderedDescending(self: array of T): boolean; extensionmethod; where T: System.IComparable; +begin + for var i := 0 to self.High - 1 do + if self[i].CompareTo(self[i + 1]) < 0 then + exit(False); + Result := True; +end; + +/// Проверяет, отсортирован ли массив по убыванию в порядке, заданном компаратором comparer +function IsOrderedDescending(self: array of T; comparer: IComparer): boolean; extensionmethod; +begin + for var i := 0 to self.High - 1 do + if comparer.Compare(self[i], self[i + 1]) < 0 then // Обратный знак + exit(False); + Result := True; +end; + + /// Возвращает последовательность индексов одномерного массива function Indices(Self: array of T): sequence of integer; extensionmethod := Range(0, Self.Length - 1); diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index 3a47974bd..810dd6054 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -11195,6 +11195,66 @@ begin Result := Self.OrderByDescending(x -> x, System.StringComparer.Ordinal); end; +/// Проверяет, отсортирована ли последовательность по возрастанию +function IsOrdered(self: sequence of T): boolean; extensionmethod; where T: System.IComparable; +begin + var prev: T; + var first := True; + foreach var current in self do + begin + if not first and (prev.CompareTo(current) > 0) then + exit(False); + prev := current; + first := False; + end; + Result := True; +end; + +/// Проверяет, отсортирована ли последовательность по возрастанию в порядке, заданном компаратором comparer +function IsOrdered(self: sequence of T; comparer: IComparer): boolean; extensionmethod; +begin + var prev: T; + var first := True; + foreach var current in self do + begin + if not first and (comparer.Compare(prev, current) > 0) then + exit(False); + prev := current; + first := False; + end; + Result := True; +end; + +/// Проверяет, отсортирована ли последовательность по убыванию +function IsOrderedDescending(self: sequence of T): boolean; extensionmethod; where T: System.IComparable; +begin + var prev: T; + var first := True; + foreach var current in self do + begin + if not first and (prev.CompareTo(current) < 0) then + exit(False); + prev := current; + first := False; + end; + Result := True; +end; + +/// Проверяет, отсортирована ли последовательность по убыванию в порядке, заданном компаратором comparer +function IsOrderedDescending(self: sequence of T; comparer: IComparer): boolean; extensionmethod; +begin + var prev: T; + var first := True; + foreach var current in self do + begin + if not first and (comparer.Compare(prev, current) < 0) then // Обратный знак + exit(False); + prev := current; + first := False; + end; + Result := True; +end; + /// Возвращает множество HashSet по данной последовательности function ToHashSet(Self: sequence of T): HashSet; extensionmethod; begin @@ -13342,13 +13402,49 @@ begin System.Array.Copy(a,Self,a.Length); end; - /// Возвращает индекс последнего элемента массива function High(Self: System.Array); extensionmethod := High(Self); /// Возвращает индекс первого элемента массива function Low(Self: System.Array); extensionmethod := Low(Self); +/// Проверяет, отсортирован ли массив по возрастанию +function IsOrdered(self: array of T): boolean; extensionmethod; where T: System.IComparable; +begin + for var i := 0 to self.High - 1 do + if self[i].CompareTo(self[i + 1]) > 0 then + exit(False); + Result := True; +end; + +/// Проверяет, отсортирован ли массив в порядке, заданном компаратором comparer +function IsOrdered(self: array of T; comparer: IComparer): boolean; extensionmethod; +begin + for var i := 0 to self.High - 1 do + if comparer.Compare(self[i], self[i + 1]) > 0 then + exit(False); + Result := True; +end; + +/// Проверяет, отсортирован ли массив по убыванию +function IsOrderedDescending(self: array of T): boolean; extensionmethod; where T: System.IComparable; +begin + for var i := 0 to self.High - 1 do + if self[i].CompareTo(self[i + 1]) < 0 then + exit(False); + Result := True; +end; + +/// Проверяет, отсортирован ли массив по убыванию в порядке, заданном компаратором comparer +function IsOrderedDescending(self: array of T; comparer: IComparer): boolean; extensionmethod; +begin + for var i := 0 to self.High - 1 do + if comparer.Compare(self[i], self[i + 1]) < 0 then // Обратный знак + exit(False); + Result := True; +end; + + /// Возвращает последовательность индексов одномерного массива function Indices(Self: array of T): sequence of integer; extensionmethod := Range(0, Self.Length - 1);