Переставил operator:= в NewSet

This commit is contained in:
Mikhalkovich Stanislav 2024-11-13 22:13:41 +03:00
parent 96c68f1666
commit 03be5bd931
10 changed files with 117 additions and 100 deletions

View file

@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3";
public const string Minor = "10";
public const string Build = "0";
public const string Revision = "3559";
public const string Revision = "3565";
public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;

View file

@ -1,4 +1,4 @@
%MINOR%=10
%REVISION%=3559
%REVISION%=3565
%COREVERSION%=0
%MAJOR%=3

View file

@ -1 +1 @@
3.10.0.3559
3.10.0.3565

View file

@ -1 +1 @@
!define VERSION '3.10.0.3559'
!define VERSION '3.10.0.3565'

View file

@ -455,10 +455,10 @@ begin
end;
// Важнейший для новых множеств !!!
procedure operator:=<T>(var Self: NewSet<T>; st: NewSet<T>); extensionmethod;
{procedure operator:=<T>(var Self: NewSet<T>; st: NewSet<T>); extensionmethod;
begin
Self._hs := new HashSet<T>(st.hs);
end;
Self.hs := new HashSet<T>(st.hs);
end;}
{procedure operator:=<T>(var Self: NewSet<T>; st: NewSetEmpty); extensionmethod;
begin
@ -468,89 +468,89 @@ end;}
// Extension-методы для новых множеств
function operator implicit(n: NewSet<integer>): NewSet<byte>; extensionmethod;
begin
foreach var x in n._hs do
foreach var x in n.hs do
if (x >= byte.MinValue) and (x <= byte.MaxValue) then
Result._hs.Add(x)
Result.hs.Add(x)
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
end;
function operator implicit(n: NewSet<integer>): NewSet<shortint>; extensionmethod;
begin
foreach var x in n._hs do
foreach var x in n.hs do
if (x >= shortint.MinValue) and (x <= shortint.MaxValue) then
Result._hs.Add(x)
Result.hs.Add(x)
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
end;
function operator implicit(n: NewSet<integer>): NewSet<smallint>; extensionmethod;
begin
foreach var x in n._hs do
foreach var x in n.hs do
if (x >= smallint.MinValue) and (x <= smallint.MaxValue) then
Result._hs.Add(x)
Result.hs.Add(x)
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
end;
function operator implicit(n: NewSet<integer>): NewSet<word>; extensionmethod;
begin
foreach var x in n._hs do
foreach var x in n.hs do
if (x >= word.MinValue) and (x <= word.MaxValue) then
Result._hs.Add(x)
Result.hs.Add(x)
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
end;
function operator implicit(n: NewSet<integer>): NewSet<longword>; extensionmethod;
begin
foreach var x in n._hs do
foreach var x in n.hs do
if (x >= longword.MinValue) and (x <= longword.MaxValue) then
Result._hs.Add(x)
Result.hs.Add(x)
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
end;
function operator implicit(n: NewSet<integer>): NewSet<int64>; extensionmethod;
begin
foreach var x in n._hs do
Result._hs.Add(x)
foreach var x in n.hs do
Result.hs.Add(x)
end;
function operator implicit(n: NewSet<integer>): NewSet<uint64>; extensionmethod;
begin
foreach var x in n._hs do
foreach var x in n.hs do
if x >= 0 then
Result._hs.Add(x)
Result.hs.Add(x)
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
end;
function NSToInts(ns: NewSet<byte>) := ns._hs.Select(x -> integer(x));
function NSToInts(ns: NewSet<shortint>) := ns._hs.Select(x -> integer(x));
function NSToInts(ns: NewSet<smallint>) := ns._hs.Select(x -> integer(x));
function NSToInts(ns: NewSet<word>) := ns._hs.Select(x -> integer(x));
function NSToInts(ns: NewSet<byte>) := ns.hs.Select(x -> integer(x));
function NSToInts(ns: NewSet<shortint>) := ns.hs.Select(x -> integer(x));
function NSToInts(ns: NewSet<smallint>) := ns.hs.Select(x -> integer(x));
function NSToInts(ns: NewSet<word>) := ns.hs.Select(x -> integer(x));
//function NSToInts(ns: NewSet<longword>) := ns._hs.Select(x -> integer(x));
//function NSToInts(ns: NewSet<int64>) := ns._hs.Select(x -> integer(x));
function NSToInts64(ns: NewSet<byte>) := ns._hs.Select(x -> int64(x));
function NSToInts64(ns: NewSet<integer>) := ns._hs.Select(x -> int64(x));
function NSToBytes(ns: NewSet<integer>) := ns._hs.Select(x -> byte(x));
function NSToBytes(ns: NewSet<int64>) := ns._hs.Select(x -> byte(x));
function NSToInts64(ns: NewSet<byte>) := ns.hs.Select(x -> int64(x));
function NSToInts64(ns: NewSet<integer>) := ns.hs.Select(x -> int64(x));
function NSToBytes(ns: NewSet<integer>) := ns.hs.Select(x -> byte(x));
function NSToBytes(ns: NewSet<int64>) := ns.hs.Select(x -> byte(x));
// Надо set of integer со всеми
function operator=(a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a._hs.SetEquals(NSToInts(b));
function operator=(a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a.hs.SetEquals(NSToInts(b));
function operator=(a: NewSet<byte>; b: NewSet<integer>): boolean; extensionmethod := b = a;
function operator=(a: NewSet<integer>; b: NewSet<shortint>); extensionmethod := a._hs.SetEquals(NSToInts(b));
function operator=(a: NewSet<integer>; b: NewSet<shortint>); extensionmethod := a.hs.SetEquals(NSToInts(b));
function operator=(a: NewSet<shortint>; b: NewSet<integer>): boolean; extensionmethod := b = a;
function operator=(a: NewSet<integer>; b: NewSet<smallint>); extensionmethod := a._hs.SetEquals(NSToInts(b));
function operator=(a: NewSet<integer>; b: NewSet<smallint>); extensionmethod := a.hs.SetEquals(NSToInts(b));
function operator=(a: NewSet<smallint>; b: NewSet<integer>): boolean; extensionmethod := b = a;
function operator=(a: NewSet<integer>; b: NewSet<word>); extensionmethod := a._hs.SetEquals(NSToInts(b));
function operator=(a: NewSet<integer>; b: NewSet<word>); extensionmethod := a.hs.SetEquals(NSToInts(b));
function operator=(a: NewSet<word>; b: NewSet<integer>): boolean; extensionmethod := b = a;
// В этом случае integer и longword не вкладываются друг в друга
function operator=(a: NewSet<integer>; b: NewSet<longword>): boolean; extensionmethod;
begin
var hsInt64: HashSet<int64>;
hsInt64 := new HashSet<int64>(b._hs.Select(x -> int64(x)));
Result := hsInt64.SetEquals(a._hs.Select(x -> int64(x)));
hsInt64 := new HashSet<int64>(b.hs.Select(x -> int64(x)));
Result := hsInt64.SetEquals(a.hs.Select(x -> int64(x)));
end;
function operator=(a: NewSet<longword>; b: NewSet<integer>): boolean; extensionmethod := b = a;
function operator=(a: NewSet<int64>; b: NewSet<integer>); extensionmethod := a._hs.SetEquals(NSToInts64(b));
function operator=(a: NewSet<int64>; b: NewSet<integer>); extensionmethod := a.hs.SetEquals(NSToInts64(b));
function operator=(a: NewSet<integer>; b: NewSet<int64>): boolean; extensionmethod := b = a;
// Здесь оба типа нельзя расширить до общего типа, и есть проблема
@ -582,43 +582,43 @@ function operator<>(a: NewSet<integer>; b: NewSet<int64>); extensionmethod := no
function operator<>(a: NewSet<integer>; b: NewSet<uint64>); extensionmethod := not(a = b);
function operator<>(a: NewSet<uint64>; b: NewSet<integer>); extensionmethod := not(a = b);
function operator<(a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a._hs.IsProperSubsetOf(NSToInts(b));
function operator<(a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a.hs.IsProperSubsetOf(NSToInts(b));
function operator<(a: NewSet<byte>; b: NewSet<integer>); extensionmethod := b > a;
function operator<(a: NewSet<int64>; b: NewSet<integer>); extensionmethod := a._hs.IsProperSubsetOf(NSToInts64(b));
function operator<(a: NewSet<int64>; b: NewSet<integer>); extensionmethod := a.hs.IsProperSubsetOf(NSToInts64(b));
function operator<(a: NewSet<integer>; b: NewSet<int64>); extensionmethod := b > a;
function operator>(a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a._hs.IsProperSupersetOf(NSToInts(b));
function operator>(a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a.hs.IsProperSupersetOf(NSToInts(b));
function operator>(a: NewSet<byte>; b: NewSet<integer>); extensionmethod := b < a;
function operator>(a: NewSet<int64>; b: NewSet<integer>); extensionmethod := a._hs.IsProperSupersetOf(NSToInts64(b));
function operator>(a: NewSet<int64>; b: NewSet<integer>); extensionmethod := a.hs.IsProperSupersetOf(NSToInts64(b));
function operator>(a: NewSet<integer>; b: NewSet<int64>); extensionmethod := b < a;
function operator<=(a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a._hs.IsSubsetOf(NSToInts(b));
function operator<=(a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a.hs.IsSubsetOf(NSToInts(b));
function operator<=(a: NewSet<byte>; b: NewSet<integer>); extensionmethod := b >= a;
function operator<=(a: NewSet<int64>; b: NewSet<integer>); extensionmethod := a._hs.IsSubsetOf(NSToInts64(b));
function operator<=(a: NewSet<int64>; b: NewSet<integer>); extensionmethod := a.hs.IsSubsetOf(NSToInts64(b));
function operator<=(a: NewSet<integer>; b: NewSet<int64>); extensionmethod := b >= a;
function operator>=(a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a._hs.IsSupersetOf(NSToInts(b));
function operator>=(a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a.hs.IsSupersetOf(NSToInts(b));
function operator>=(a: NewSet<byte>; b: NewSet<integer>); extensionmethod := b <= a;
function operator>=(a: NewSet<int64>; b: NewSet<integer>); extensionmethod := a._hs.IsSupersetOf(NSToInts64(b));
function operator>=(a: NewSet<int64>; b: NewSet<integer>); extensionmethod := a.hs.IsSupersetOf(NSToInts64(b));
function operator>=(a: NewSet<integer>; b: NewSet<int64>); extensionmethod := b <= a;
procedure operator*=(var a: NewSet<byte>; b: NewSet<integer>); extensionmethod := a._hs.IntersectWith(NSToBytes(b));
procedure operator*=(var a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a._hs.IntersectWith(NSToInts(b));
procedure operator*=(var a: NewSet<int64>; b: NewSet<integer>); extensionmethod := a._hs.IntersectWith(NSToInts64(b));
procedure operator*=(var a: NewSet<byte>; b: NewSet<integer>); extensionmethod := a.hs.IntersectWith(NSToBytes(b));
procedure operator*=(var a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a.hs.IntersectWith(NSToInts(b));
procedure operator*=(var a: NewSet<int64>; b: NewSet<integer>); extensionmethod := a.hs.IntersectWith(NSToInts64(b));
//procedure operator*=(var a: NewSet<integer>; b: NewSet<int64>); extensionmethod := a._hs.IntersectWith(NSToInts(b));
//procedure operator*=(var a: NewSet<byte>; b: NewSet<int64>); extensionmethod := a._hs.IntersectWith(NSToBytes(b));
//procedure operator*=(var a: NewSet<int64>; b: NewSet<byte>); extensionmethod := a._hs.IntersectWith(NSToInts64(b));
procedure operator+=(var a: NewSet<byte>; b: NewSet<integer>); extensionmethod := a._hs.UnionWith(NSToBytes(b));
procedure operator+=(var a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a._hs.UnionWith(NSToInts(b));
procedure operator+=(var a: NewSet<int64>; b: NewSet<integer>); extensionmethod := a._hs.UnionWith(NSToInts64(b));
procedure operator+=(var a: NewSet<byte>; b: NewSet<integer>); extensionmethod := a.hs.UnionWith(NSToBytes(b));
procedure operator+=(var a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a.hs.UnionWith(NSToInts(b));
procedure operator+=(var a: NewSet<int64>; b: NewSet<integer>); extensionmethod := a.hs.UnionWith(NSToInts64(b));
//procedure operator+=(var a: NewSet<integer>; b: NewSet<int64>); extensionmethod := a._hs.UnionWith(NSToInts(b));
procedure operator+=(var a: NewSet<byte>; b: NewSet<int64>); extensionmethod := a._hs.UnionWith(NSToBytes(b));
procedure operator+=(var a: NewSet<int64>; b: NewSet<byte>); extensionmethod := a._hs.UnionWith(NSToInts64(b));
procedure operator+=(var a: NewSet<byte>; b: NewSet<int64>); extensionmethod := a.hs.UnionWith(NSToBytes(b));
procedure operator+=(var a: NewSet<int64>; b: NewSet<byte>); extensionmethod := a.hs.UnionWith(NSToInts64(b));
procedure operator-=(var a: NewSet<byte>; b: NewSet<integer>); extensionmethod := a._hs.ExceptWith(NSToBytes(b));
procedure operator-=(var a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a._hs.ExceptWith(NSToInts(b));
procedure operator-=(var a: NewSet<int64>; b: NewSet<integer>); extensionmethod := a._hs.ExceptWith(NSToInts64(b));
procedure operator-=(var a: NewSet<byte>; b: NewSet<integer>); extensionmethod := a.hs.ExceptWith(NSToBytes(b));
procedure operator-=(var a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a.hs.ExceptWith(NSToInts(b));
procedure operator-=(var a: NewSet<int64>; b: NewSet<integer>); extensionmethod := a.hs.ExceptWith(NSToInts64(b));
//procedure operator-=(var a: NewSet<integer>; b: NewSet<int64>); extensionmethod := a._hs.ExceptWith(NSToInts(b));
@ -686,7 +686,7 @@ begin
end;
// и для массивов столько же
function operator=(a: NewSet<integer>; b: array of byte); extensionmethod := a._hs.SetEquals(b.Select(x -> integer(x)));
function operator=(a: NewSet<integer>; b: array of byte); extensionmethod := a.hs.SetEquals(b.Select(x -> integer(x)));
function operator=(a: array of byte; b: NewSet<integer>): boolean; extensionmethod := b = a;
function operator=(a: array of int64; b: NewSet<integer>); extensionmethod := a.ToHashSet.SetEquals(NSToInts64(b));
function operator=(a: NewSet<integer>; b: array of int64): boolean; extensionmethod := b = a;

View file

@ -483,19 +483,21 @@ type
end;}
type
NewSetEmpty = class;
/// Тип нового встроенного множества
NewSet<T> = record(IEnumerable<T>)
private
public
///--
_hs := new HashSet<T>;
hs := new HashSet<T>;
///--
function hs: HashSet<T>;
{function hs: HashSet<T>;
begin
if _hs = nil then
_hs := new HashSet<T>;
Result := _hs;
end;
end;}
constructor (params a: array of T);
begin
hs.UnionWith(a);
@ -504,7 +506,7 @@ type
function System.Collections.IEnumerable.GetEnumerator: System.Collections.IEnumerator := GetEnumerator;
static function operator implicit(a: array of T): NewSet<T>;
begin
Result._hs := new HashSet<T>(a);
Result.hs := new HashSet<T>(a);
end;
function ToString: string; override;
function Count: integer := hs.Count;
@ -545,12 +547,17 @@ type
static function operator implicit(ns: HashSet<T>): NewSet<T>;
begin
Result.hs.UnionWith(ns);
end;
end;
static function operator implicit(ns: NewSetEmpty): NewSet<T>; begin end;
static function operator:=(var Self: NewSet<T>; st: NewSet<T>): NewSet<T>;
begin
Self.hs := new HashSet<T>(st.hs);
end;
end;
NewSetEmpty = record
static function operator implicit<T>(ns: NewSetEmpty): NewSet<T>; begin end;
NewSetEmpty = class
public
static function operator=<T>(s1: NewSet<T>; s2: NewSetEmpty): boolean := s1.Count = 0;
static function operator=<T>(s2: NewSetEmpty; s1: NewSet<T>): boolean := s1.Count = 0;
static function operator<><T>(s1: NewSet<T>; s2: NewSetEmpty): boolean := not (s1 = s2);
@ -565,16 +572,16 @@ type
static function operator<=<T>(s2: NewSetEmpty; s1: NewSet<T>): boolean := s1.Count >= 0;
// ToDo: определить то же для массивов на будущее
static function operator+(first, second: NewSetEmpty): NewSetEmpty; begin end;
static function operator-(first, second: NewSetEmpty): NewSetEmpty; begin end;
static function operator*(first, second: NewSetEmpty): NewSetEmpty; begin end;
static function operator+(first, second: NewSetEmpty): NewSetEmpty := new NewSetEmpty;
static function operator-(first, second: NewSetEmpty): NewSetEmpty := new NewSetEmpty;
static function operator*(first, second: NewSetEmpty): NewSetEmpty := new NewSetEmpty;
static function operator+<T>(first: NewSetEmpty; second: array of T): NewSet<T>;
begin
Result._hs.UnionWith(second);
Result.hs.UnionWith(second);
end;
static function operator+<T>(first: array of T; second: NewSetEmpty): NewSet<T>;
begin
Result._hs.UnionWith(first);
Result.hs.UnionWith(first);
end;
static function operator+<T>(first: NewSet<T>; second: NewSetEmpty): NewSet<T> := first;
static function operator+<T>(first: NewSetEmpty; second: NewSet<T>): NewSet<T> := second;
@ -588,7 +595,7 @@ type
static function operator-<T>(first: NewSetEmpty; second: array of T): NewSet<T>; begin end;
static function operator-<T>(first: array of T; second: NewSetEmpty): NewSet<T>;
begin
Result._hs.UnionWith(first);
Result.hs.UnionWith(first);
end;
function ToString: string; override := '{}';
function ToSet<T>(): NewSet<T>; begin end;
@ -602,7 +609,7 @@ type
Result := new HashSet<T>;
end;
end;
type
// Вспомогательный тип для множества
///--
@ -15395,7 +15402,7 @@ end;}
// Присваивание реализовано в PABCExtensions. Здесь не работает
var _emptyset: NewSetEmpty;
var _emptyset: NewSetEmpty := new NewSetEmpty;
type
SetCreatorFunctionAttribute = class(Attribute)
@ -15406,14 +15413,14 @@ function EmptySet := _emptyset;
[SetCreatorFunction]
function __NewSetCreatorInternal<T>(params a: array of T): NewSet<T>;
begin
Result._hs := new HashSet<T>;
Result._hs.UnionWith(a);
Result.hs := new HashSet<T>;
Result.hs.UnionWith(a);
end;
[SetCreatorFunction]
function __NSetInteger(a: array of integer; dd: array of integer): NewSet<integer>;
begin
Result._hs.UnionWith(a);
Result.hs.UnionWith(a);
var n := dd.Length;
for var i:=0 to n-1 step 2 do
begin
@ -15425,7 +15432,7 @@ end;
[SetCreatorFunction]
function __NSetChar(a: array of char; dd: array of char): NewSet<char>;
begin
Result._hs.UnionWith(a);
Result.hs.UnionWith(a);
var n := dd.Length;
for var i:=0 to n-1 step 2 do
begin
@ -15437,7 +15444,7 @@ end;
[SetCreatorFunction]
function __NSetBoolean(a: array of boolean; dd: array of boolean): NewSet<boolean>;
begin
Result._hs.UnionWith(a);
Result.hs.UnionWith(a);
var n := dd.Length;
for var i:=0 to n-1 step 2 do
begin
@ -15449,7 +15456,7 @@ end;
[SetCreatorFunction]
function __NSetEnum<T>(a: array of T; dd: array of T): NewSet<T>;
begin
Result._hs.UnionWith(a);
Result.hs.UnionWith(a);
var vals := System.Enum.GetValues(typeof(T)).Cast&<T>.ToArray;
var n := dd.Length;
for var i:=0 to n-1 step 2 do
@ -15471,51 +15478,53 @@ end;
function operator implicit(n: array of integer): set of byte; extensionmethod;
begin
foreach var x in n do
Result._hs.Add(x);
Result.hs.Add(x);
end;
function operator implicit(n: array of integer): set of shortint; extensionmethod;
begin
foreach var x in n do
Result._hs.Add(x);
Result.hs.Add(x);
end;
function operator implicit(n: array of integer): set of smallint; extensionmethod;
begin
foreach var x in n do
Result._hs.Add(x);
Result.hs.Add(x);
end;
function operator implicit(n: array of integer): set of word; extensionmethod;
begin
foreach var x in n do
Result._hs.Add(x);
Result.hs.Add(x);
end;
function operator implicit(n: array of integer): set of longword; extensionmethod;
begin
foreach var x in n do
Result._hs.Add(x);
Result.hs.Add(x);
end;
function operator implicit(a: array of integer): set of int64; extensionmethod;
begin
foreach var x in a do
Result._hs.Add(x);
Result.hs.Add(x);
end;
function operator implicit(a: array of integer): set of uint64; extensionmethod;
begin
foreach var x in a do
Result._hs.Add(x);
Result.hs.Add(x);
end;
function operator implicit(a: array of integer): set of BigInteger; extensionmethod;
begin
foreach var x in a do
Result._hs.Add(x);
Result.hs.Add(x);
end;
//function operator implicit<T>(ns: NewSetEmpty): NewSet<T>; extensionmethod; begin end;
// -----------------------------------------------------------------------------
// Внутренние вспомогательные функции
// -----------------------------------------------------------------------------

View file

@ -5321,7 +5321,6 @@ namespace PascalABCCompiler.TreeConverter
}
else
{
_pascal_set_constant = _pascal_set_constant;
// Ну теперь самый общий NSet<el_type>(Arr<el_type>(consts), Arr<el_type>(consts_diap))
var nset_type = new semantic_type_node(el_type, psc);
var dnNSetInt = new dot_node(new ident("PABCSystem", psc), new ident("__NSetInteger", psc));

View file

@ -18,8 +18,8 @@ cd ..
ExecHide.exe gacutil.exe /u PABCRtl
ExecHide.exe gacutil.exe /i ..\bin\Lib\PABCRtl.dll
..\bin\pabcnetc RebuildStandartModules.pas /rebuild
@IF %ERRORLEVEL% NEQ 0 GOTO ERROR
rem ..\bin\pabcnetc RebuildStandartModules.pas /rebuild
rem @IF %ERRORLEVEL% NEQ 0 GOTO ERROR
cd ..\bin

View file

@ -455,10 +455,10 @@ begin
end;
// Важнейший для новых множеств !!!
procedure operator:=<T>(var Self: NewSet<T>; st: NewSet<T>); extensionmethod;
{procedure operator:=<T>(var Self: NewSet<T>; st: NewSet<T>); extensionmethod;
begin
Self._hs := new HashSet<T>(st.hs);
end;
end;}
{procedure operator:=<T>(var Self: NewSet<T>; st: NewSetEmpty); extensionmethod;
begin

View file

@ -483,6 +483,8 @@ type
end;}
type
NewSetEmpty = class;
/// Тип нового встроенного множества
NewSet<T> = record(IEnumerable<T>)
private
@ -545,12 +547,17 @@ type
static function operator implicit(ns: HashSet<T>): NewSet<T>;
begin
Result.hs.UnionWith(ns);
end;
end;
static function operator implicit(ns: NewSetEmpty): NewSet<T>; begin end;
static function operator:=(var s: NewSet<T>; st: NewSet<T>): NewSet<T>;
begin
s._hs := new HashSet<T>(st.hs);
end;
end;
NewSetEmpty = record
static function operator implicit<T>(ns: NewSetEmpty): NewSet<T>; begin end;
NewSetEmpty = class
public
static function operator=<T>(s1: NewSet<T>; s2: NewSetEmpty): boolean := s1.Count = 0;
static function operator=<T>(s2: NewSetEmpty; s1: NewSet<T>): boolean := s1.Count = 0;
static function operator<><T>(s1: NewSet<T>; s2: NewSetEmpty): boolean := not (s1 = s2);
@ -565,9 +572,9 @@ type
static function operator<=<T>(s2: NewSetEmpty; s1: NewSet<T>): boolean := s1.Count >= 0;
// ToDo: определить то же для массивов на будущее
static function operator+(first, second: NewSetEmpty): NewSetEmpty; begin end;
static function operator-(first, second: NewSetEmpty): NewSetEmpty; begin end;
static function operator*(first, second: NewSetEmpty): NewSetEmpty; begin end;
static function operator+(first, second: NewSetEmpty): NewSetEmpty := new NewSetEmpty;
static function operator-(first, second: NewSetEmpty): NewSetEmpty := new NewSetEmpty;
static function operator*(first, second: NewSetEmpty): NewSetEmpty := new NewSetEmpty;
static function operator+<T>(first: NewSetEmpty; second: array of T): NewSet<T>;
begin
Result._hs.UnionWith(second);
@ -602,7 +609,7 @@ type
Result := new HashSet<T>;
end;
end;
type
// Вспомогательный тип для множества
///--
@ -15395,7 +15402,7 @@ end;}
// Присваивание реализовано в PABCExtensions. Здесь не работает
var _emptyset: NewSetEmpty;
var _emptyset: NewSetEmpty := new NewSetEmpty;
type
SetCreatorFunctionAttribute = class(Attribute)
@ -15516,6 +15523,8 @@ begin
Result._hs.Add(x);
end;
//function operator implicit<T>(ns: NewSetEmpty): NewSet<T>; extensionmethod; begin end;
// -----------------------------------------------------------------------------
// Внутренние вспомогательные функции
// -----------------------------------------------------------------------------