Небольшие изменения в реализации операций с множествами
This commit is contained in:
parent
087591c7b6
commit
7906d73da3
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
|||
public const string Major = "3";
|
||||
public const string Minor = "10";
|
||||
public const string Build = "1";
|
||||
public const string Revision = "3579";
|
||||
public const string Revision = "3581";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%MINOR%=10
|
||||
%REVISION%=3579
|
||||
%REVISION%=3581
|
||||
%COREVERSION%=1
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
3.10.1.3579
|
||||
3.10.1.3581
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.10.1.3579'
|
||||
!define VERSION '3.10.1.3581'
|
||||
|
|
|
|||
|
|
@ -456,18 +456,22 @@ begin
|
|||
end;
|
||||
|
||||
// Важнейший для новых множеств !!!
|
||||
{procedure operator:=<T>(var Self: NewSet<T>; st: NewSet<T>); extensionmethod;
|
||||
{procedure operator:=<T>(var Self: set of T>; st: set of T>); extensionmethod;
|
||||
begin
|
||||
Self._hs := new HashSet<T>(st.hs);
|
||||
end;}
|
||||
|
||||
{procedure operator:=<T>(var Self: NewSet<T>; st: NewSetEmpty); extensionmethod;
|
||||
{procedure operator:=<T>(var Self: set of T>; st: NewSetEmpty); extensionmethod;
|
||||
begin
|
||||
Self._hs := new HashSet<T>();
|
||||
end;}
|
||||
|
||||
// --------------------------------------
|
||||
// Extension-методы для новых множеств
|
||||
function operator implicit(n: NewSet<integer>): NewSet<byte>; extensionmethod;
|
||||
// --------------------------------------
|
||||
|
||||
// operator implicit
|
||||
function operator implicit(n: set of integer): set of byte; extensionmethod;
|
||||
begin
|
||||
foreach var x in n._hs do
|
||||
if (x >= byte.MinValue) and (x <= byte.MaxValue) then
|
||||
|
|
@ -475,7 +479,7 @@ begin
|
|||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(n: NewSet<integer>): NewSet<shortint>; extensionmethod;
|
||||
function operator implicit(n: set of integer): set of shortint; extensionmethod;
|
||||
begin
|
||||
foreach var x in n._hs do
|
||||
if (x >= shortint.MinValue) and (x <= shortint.MaxValue) then
|
||||
|
|
@ -483,7 +487,7 @@ begin
|
|||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(n: NewSet<integer>): NewSet<smallint>; extensionmethod;
|
||||
function operator implicit(n: set of integer): set of smallint; extensionmethod;
|
||||
begin
|
||||
foreach var x in n._hs do
|
||||
if (x >= smallint.MinValue) and (x <= smallint.MaxValue) then
|
||||
|
|
@ -491,7 +495,7 @@ begin
|
|||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(n: NewSet<integer>): NewSet<word>; extensionmethod;
|
||||
function operator implicit(n: set of integer): set of word; extensionmethod;
|
||||
begin
|
||||
foreach var x in n._hs do
|
||||
if (x >= word.MinValue) and (x <= word.MaxValue) then
|
||||
|
|
@ -499,7 +503,7 @@ begin
|
|||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(n: NewSet<integer>): NewSet<longword>; extensionmethod;
|
||||
function operator implicit(n: set of integer): set of longword; extensionmethod;
|
||||
begin
|
||||
foreach var x in n._hs do
|
||||
if (x >= longword.MinValue) and (x <= longword.MaxValue) then
|
||||
|
|
@ -507,13 +511,13 @@ begin
|
|||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(n: NewSet<integer>): NewSet<int64>; extensionmethod;
|
||||
function operator implicit(n: set of integer): set of int64; extensionmethod;
|
||||
begin
|
||||
foreach var x in n._hs do
|
||||
Result._hs.Add(x)
|
||||
end;
|
||||
|
||||
function operator implicit(n: NewSet<integer>): NewSet<uint64>; extensionmethod;
|
||||
function operator implicit(n: set of integer): set of uint64; extensionmethod;
|
||||
begin
|
||||
foreach var x in n._hs do
|
||||
if x >= 0 then
|
||||
|
|
@ -521,15 +525,81 @@ begin
|
|||
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<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>): sequence of byte;
|
||||
function operator implicit(a: set of integer): set of BigInteger; extensionmethod;
|
||||
begin
|
||||
foreach var x in a do
|
||||
Result._hs.Add(x);
|
||||
end;
|
||||
|
||||
//-- operator implicit array of integer -> set of целое
|
||||
function operator implicit(n: array of integer): set of byte; extensionmethod;
|
||||
begin
|
||||
foreach var x in n do
|
||||
if (x >= byte.MinValue) and (x <= byte.MaxValue) then
|
||||
Result._hs.Add(x)
|
||||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(n: array of integer): set of shortint; extensionmethod;
|
||||
begin
|
||||
foreach var x in n do
|
||||
if (x >= shortint.MinValue) and (x <= shortint.MaxValue) then
|
||||
Result._hs.Add(x)
|
||||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(n: array of integer): set of smallint; extensionmethod;
|
||||
begin
|
||||
foreach var x in n do
|
||||
if (x >= smallint.MinValue) and (x <= smallint.MaxValue) then
|
||||
Result._hs.Add(x)
|
||||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(n: array of integer): set of word; extensionmethod;
|
||||
begin
|
||||
foreach var x in n do
|
||||
if (x >= word.MinValue) and (x <= word.MaxValue) then
|
||||
Result._hs.Add(x)
|
||||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(n: array of integer): set of longword; extensionmethod;
|
||||
begin
|
||||
foreach var x in n do
|
||||
if (x >= longword.MinValue) and (x <= longword.MaxValue) then
|
||||
Result._hs.Add(x)
|
||||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(a: array of integer): set of int64; extensionmethod;
|
||||
begin
|
||||
foreach var x in a do
|
||||
Result._hs.Add(x);
|
||||
end;
|
||||
|
||||
function operator implicit(a: array of integer): set of uint64; extensionmethod;
|
||||
begin
|
||||
foreach var x in a do
|
||||
if x >= 0 then
|
||||
Result._hs.Add(x)
|
||||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(a: array of integer): set of BigInteger; extensionmethod;
|
||||
begin
|
||||
foreach var x in a do
|
||||
Result._hs.Add(x);
|
||||
end;
|
||||
|
||||
function NSToInts(ns: set of byte) := ns._hs.Select(x -> integer(x));
|
||||
function NSToInts(ns: set of shortint) := ns._hs.Select(x -> integer(x));
|
||||
function NSToInts(ns: set of smallint) := ns._hs.Select(x -> integer(x));
|
||||
function NSToInts(ns: set of word) := ns._hs.Select(x -> integer(x));
|
||||
function NSToInts64(ns: set of byte) := ns._hs.Select(x -> int64(x));
|
||||
function NSToInts64(ns: set of integer) := ns._hs.Select(x -> int64(x));
|
||||
|
||||
function NSToBytes(ns: set of integer): sequence of byte;
|
||||
begin
|
||||
var res := new List<byte>;
|
||||
foreach var x in ns._hs do
|
||||
|
|
@ -539,7 +609,7 @@ begin
|
|||
Result := res;
|
||||
end;
|
||||
|
||||
function NSToBytes(ns: NewSet<int64>): sequence of byte;
|
||||
function NSToBytes(ns: set of int64): sequence of byte;
|
||||
begin
|
||||
var res := new List<byte>;
|
||||
foreach var x in ns._hs do
|
||||
|
|
@ -549,184 +619,455 @@ begin
|
|||
Result := res;
|
||||
end;
|
||||
|
||||
// Надо set of integer со всеми
|
||||
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<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<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<word>; b: NewSet<integer>): boolean; extensionmethod := b = a;
|
||||
// operator= для set
|
||||
// set of integer сравнивается со всеми
|
||||
function operator=(a: set of integer; b: set of byte); extensionmethod
|
||||
:= (a.Count = b.Count) and b.All(x -> x in a); // x в меньшем диапазоне, поэтому x in a работает верно
|
||||
function operator=(a: set of byte; b: set of integer): boolean; extensionmethod
|
||||
:= b = a;
|
||||
function operator=(a: set of integer; b: set of shortint); extensionmethod
|
||||
:= (a.Count = b.Count) and b.All(x -> x in a);
|
||||
function operator=(a: set of shortint; b: set of integer): boolean; extensionmethod
|
||||
:= b = a;
|
||||
function operator=(a: set of integer; b: set of smallint); extensionmethod
|
||||
:= (a.Count = b.Count) and b.All(x -> x in a);
|
||||
function operator=(a: set of smallint; b: set of integer): boolean; extensionmethod
|
||||
:= b = a;
|
||||
function operator=(a: set of integer; b: set of word); extensionmethod
|
||||
:= (a.Count = b.Count) and b.All(x -> x in a);
|
||||
function operator=(a: set of word; b: set of 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)));
|
||||
end;
|
||||
function operator=(a: set of integer; b: set of longword): boolean; extensionmethod
|
||||
:= (a.Count = b.Count) and a.All(x -> x >= 0) and a.All(x -> x in b);
|
||||
function operator=(a: set of longword; b: set of integer): boolean; extensionmethod
|
||||
:= b = a;
|
||||
|
||||
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<integer>; b: NewSet<int64>): boolean; extensionmethod := b = a;
|
||||
function operator=(a: set of int64; b: set of integer); extensionmethod
|
||||
:= (a.Count = b.Count) and b.All(x -> x in a);
|
||||
function operator=(a: set of integer; b: set of int64): boolean; extensionmethod
|
||||
:= b = a;
|
||||
|
||||
// Здесь оба типа нельзя расширить до общего типа, и есть проблема
|
||||
function operator=(a: NewSet<integer>; b: NewSet<uint64>): boolean; extensionmethod;
|
||||
function operator=(a: set of integer; b: set of uint64): boolean; extensionmethod
|
||||
:= (a.Count = b.Count) and a.All(x -> x >= 0) and a.All(x -> x in b);
|
||||
function operator=(a: set of uint64; b: set of integer): boolean; extensionmethod := b = a;
|
||||
|
||||
|
||||
// arrays = sets
|
||||
function operator=(a: array of integer; b: set of byte); extensionmethod
|
||||
:= a.ToSet = b;
|
||||
function operator=(a: set of byte; b: array of integer): boolean; extensionmethod := b = a;
|
||||
function operator=(a: array of integer; b: set of shortint); extensionmethod
|
||||
:= a.ToSet = b;
|
||||
function operator=(a: set of shortint; b: array of integer): boolean; extensionmethod := b = a;
|
||||
function operator=(a: array of integer; b: set of smallint); extensionmethod
|
||||
:= a.ToSet = b;
|
||||
function operator=(a: set of smallint; b: array of integer): boolean; extensionmethod := b = a;
|
||||
function operator=(a: array of integer; b: set of word); extensionmethod
|
||||
:= a.ToSet = b;
|
||||
function operator=(a: set of word; b: array of integer): boolean; extensionmethod := b = a;
|
||||
function operator=(a: array of integer; b: set of longword): boolean; extensionmethod
|
||||
:= a.ToSet = b;
|
||||
function operator=(a: set of longword; b: array of integer): boolean; extensionmethod := b = a;
|
||||
function operator=(a: array of integer; b: set of int64): boolean; extensionmethod
|
||||
:= a.ToSet = b;
|
||||
function operator=(a: set of int64; b: array of integer); extensionmethod := b = a;
|
||||
function operator=(a: array of integer; b: set of uint64): boolean; extensionmethod
|
||||
:= a.ToSet = b;
|
||||
function operator=(a: set of uint64; b: array of integer): boolean; extensionmethod := b = a;
|
||||
function operator=(a: array of integer; b: set of integer); extensionmethod
|
||||
:= (a.Count = b.Count) and a.All(x -> x in b);
|
||||
function operator=(a: set of integer; b: array of integer): boolean; extensionmethod := b = a;
|
||||
|
||||
// operator<> для set
|
||||
function operator<>(a: set of integer; b: set of byte); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of byte; b: set of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of integer; b: set of shortint); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of shortint; b: set of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of integer; b: set of smallint); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of smallint; b: set of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of integer; b: set of word); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of word; b: set of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of integer; b: set of longword); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of longword; b: set of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of integer; b: set of int64); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of int64; b: set of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of integer; b: set of uint64); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of uint64; b: set of integer); extensionmethod := not(a = b);
|
||||
|
||||
// set<>array
|
||||
function operator<>(a: array of integer; b: set of byte); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of byte; b: array of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: array of integer; b: set of shortint); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of shortint; b: array of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: array of integer; b: set of smallint); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of smallint; b: array of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: array of integer; b: set of word); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of word; b: array of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: array of integer; b: set of longword); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of longword; b: array of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: array of integer; b: set of int64); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of int64; b: array of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: array of integer; b: set of uint64); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of uint64; b: array of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: array of integer; b: set of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of integer; b: array of integer); extensionmethod := not(a = b);
|
||||
|
||||
// operator< для set
|
||||
function operator<(a: set of integer; b: set of byte); extensionmethod
|
||||
:= (a.Count < b.Count) and a.All(x -> (x >= 0) and (x <= byte.MaxValue) and (x in b));
|
||||
function operator<(a: set of byte; b: set of integer); extensionmethod
|
||||
:= (a.Count < b.Count) and a.All(x -> x in b);
|
||||
function operator<(a: set of integer; b: set of int64); extensionmethod
|
||||
:= (a.Count < b.Count) and a.All(x -> x in b);
|
||||
function operator<(a: set of int64; b: set of integer); extensionmethod
|
||||
:= (a.Count < b.Count) and a.All(x -> (x >= 0) and (x <= byte.MaxValue) and (x in b));
|
||||
|
||||
// set < array
|
||||
function operator<(a: array of integer; b: set of byte); extensionmethod
|
||||
:= a.ToSet < b;
|
||||
function operator<(a: set of byte; b: array of integer); extensionmethod
|
||||
:= a < b.ToSet;
|
||||
function operator<(a: array of integer; b: set of int64); extensionmethod
|
||||
:= a.ToSet < b;
|
||||
function operator<(a: set of int64; b: array of integer); extensionmethod
|
||||
:= a < b.ToSet;
|
||||
function operator<(a: array of integer; b: set of integer); extensionmethod
|
||||
:= (a.Count < b.Count) and a.All(x -> x in b);
|
||||
function operator<(a: set of integer; b: array of integer); extensionmethod
|
||||
:= (a.Count < b.Count) and a.All(x -> x in b);
|
||||
|
||||
// operator> для set
|
||||
function operator>(a: set of integer; b: set of byte); extensionmethod
|
||||
:= b < a;
|
||||
function operator>(a: set of byte; b: set of integer); extensionmethod
|
||||
:= b < a;
|
||||
function operator>(a: set of integer; b: set of int64); extensionmethod
|
||||
:= b < a;
|
||||
function operator>(a: set of int64; b: set of integer); extensionmethod
|
||||
:= b < a;
|
||||
|
||||
// set > array
|
||||
function operator>(a: array of integer; b: set of byte); extensionmethod
|
||||
:= b < a;
|
||||
function operator>(a: set of byte; b: array of integer); extensionmethod
|
||||
:= b < a;
|
||||
function operator>(a: array of integer; b: set of int64); extensionmethod
|
||||
:= b < a;
|
||||
function operator>(a: set of int64; b: array of integer); extensionmethod
|
||||
:= b < a;
|
||||
function operator>(a: array of integer; b: set of integer); extensionmethod
|
||||
:= b < a;
|
||||
function operator>(a: set of integer; b: array of integer); extensionmethod
|
||||
:= b < a;
|
||||
|
||||
// operator<= для set - доделать!!!
|
||||
function operator<=(a: set of integer; b: set of byte); extensionmethod
|
||||
:= (a.Count <= b.Count) and a.All(x -> (x >= 0) and (x <= byte.MaxValue) and (x in b));
|
||||
function operator<=(a: set of byte; b: set of integer); extensionmethod
|
||||
:= (a.Count <= b.Count) and a.All(x -> x in b);
|
||||
function operator<=(a: set of int64; b: set of integer); extensionmethod
|
||||
:= (a.Count <= b.Count) and a.All(x -> x in b);
|
||||
function operator<=(a: set of integer; b: set of int64); extensionmethod
|
||||
:= (a.Count <= b.Count) and a.All(x -> (x >= 0) and (x <= byte.MaxValue) and (x in b));
|
||||
|
||||
// set <= array
|
||||
function operator<=(a: array of integer; b: set of byte); extensionmethod
|
||||
:= a.ToSet <= b;
|
||||
function operator<=(a: set of byte; b: array of integer); extensionmethod
|
||||
:= a <= b.ToSet;
|
||||
function operator<=(a: array of integer; b: set of int64); extensionmethod
|
||||
:= a.ToSet <= b;
|
||||
function operator<=(a: set of int64; b: array of integer); extensionmethod
|
||||
:= a <= b.ToSet;
|
||||
function operator<=(a: array of integer; b: set of integer); extensionmethod
|
||||
:= (a.Count <= b.Count) and a.All(x -> x in b);
|
||||
function operator<=(a: set of integer; b: array of integer); extensionmethod
|
||||
:= (a.Count <= b.Count) and a.All(x -> x in b);
|
||||
|
||||
|
||||
// operator>= для set
|
||||
function operator>=(a: set of integer; b: set of byte); extensionmethod
|
||||
:= b <= a;
|
||||
function operator>=(a: set of byte; b: set of integer); extensionmethod
|
||||
:= b <= a;
|
||||
function operator>=(a: set of int64; b: set of integer); extensionmethod
|
||||
:= b <= a;
|
||||
function operator>=(a: set of integer; b: set of int64); extensionmethod
|
||||
:= b <= a;
|
||||
|
||||
// set >= array
|
||||
function operator>=(a: array of integer; b: set of byte); extensionmethod
|
||||
:= b <= a;
|
||||
function operator>=(a: set of byte; b: array of integer); extensionmethod
|
||||
:= b <= a;
|
||||
function operator>=(a: array of integer; b: set of int64); extensionmethod
|
||||
:= b <= a;
|
||||
function operator>=(a: set of int64; b: array of integer); extensionmethod
|
||||
:= b <= a;
|
||||
function operator>=(a: array of integer; b: set of integer); extensionmethod
|
||||
:= b <= a;
|
||||
function operator>=(a: set of integer; b: array of integer); extensionmethod
|
||||
:= b <= a;
|
||||
|
||||
|
||||
// set *= set
|
||||
procedure operator*=(a: set of byte; b: set of integer); extensionmethod
|
||||
:= a *= NewSet&<byte>(b);
|
||||
procedure operator*=(a: set of word; b: set of integer); extensionmethod
|
||||
:= a *= NewSet&<word>(b);
|
||||
procedure operator*=(a: set of shortint; b: set of integer); extensionmethod
|
||||
:= a *= NewSet&<shortint>(b);
|
||||
procedure operator*=(a: set of smallint; b: set of integer); extensionmethod
|
||||
:= a *= NewSet&<smallint>(b);
|
||||
procedure operator*=(a: set of longword; b: set of integer); extensionmethod
|
||||
:= a *= NewSet&<longword>(b);
|
||||
procedure operator*=(a: set of int64; b: set of integer); extensionmethod
|
||||
:= a *= NewSet&<int64>(b);
|
||||
procedure operator*=(a: set of uint64; b: set of integer); extensionmethod
|
||||
:= a *= NewSet&<uint64>(b);
|
||||
|
||||
// set *= array
|
||||
procedure operator*=(a: set of byte; b: array of integer); extensionmethod
|
||||
:= a *= NewSet&<byte>(b);
|
||||
procedure operator*=(a: set of word; b: array of integer); extensionmethod
|
||||
:= a *= NewSet&<word>(b);
|
||||
procedure operator*=(a: set of shortint; b: array of integer); extensionmethod
|
||||
:= a *= NewSet&<shortint>(b);
|
||||
procedure operator*=(a: set of smallint; b: array of integer); extensionmethod
|
||||
:= a *= NewSet&<smallint>(b);
|
||||
procedure operator*=(a: set of longword; b: array of integer); extensionmethod
|
||||
:= a *= NewSet&<longword>(b);
|
||||
procedure operator*=(a: set of int64; b: array of integer); extensionmethod
|
||||
:= a *= NewSet&<int64>(b);
|
||||
procedure operator*=(a: set of uint64; b: array of integer); extensionmethod
|
||||
:= a *= NewSet&<uint64>(b);
|
||||
|
||||
|
||||
// set += set
|
||||
procedure operator+=(a: set of byte; b: set of integer); extensionmethod
|
||||
:= a += NewSet&<byte>(b);
|
||||
procedure operator+=(a: set of word; b: set of integer); extensionmethod
|
||||
:= a += NewSet&<word>(b);
|
||||
procedure operator+=(a: set of shortint; b: set of integer); extensionmethod
|
||||
:= a += NewSet&<shortint>(b);
|
||||
procedure operator+=(a: set of smallint; b: set of integer); extensionmethod
|
||||
:= a += NewSet&<smallint>(b);
|
||||
procedure operator+=(a: set of longword; b: set of integer); extensionmethod
|
||||
:= a += NewSet&<longword>(b);
|
||||
procedure operator+=(a: set of int64; b: set of integer); extensionmethod
|
||||
:= a += NewSet&<int64>(b);
|
||||
procedure operator+=(a: set of uint64; b: set of integer); extensionmethod
|
||||
:= a += NewSet&<uint64>(b);
|
||||
|
||||
// set += array
|
||||
procedure operator+=(a: set of byte; b: array of integer); extensionmethod
|
||||
:= a += NewSet&<byte>(b);
|
||||
procedure operator+=(a: set of word; b: array of integer); extensionmethod
|
||||
:= a += NewSet&<word>(b);
|
||||
procedure operator+=(a: set of shortint; b: array of integer); extensionmethod
|
||||
:= a += NewSet&<shortint>(b);
|
||||
procedure operator+=(a: set of smallint; b: array of integer); extensionmethod
|
||||
:= a += NewSet&<smallint>(b);
|
||||
procedure operator+=(a: set of longword; b: array of integer); extensionmethod
|
||||
:= a += NewSet&<longword>(b);
|
||||
procedure operator+=(a: set of int64; b: array of integer); extensionmethod
|
||||
:= a += NewSet&<int64>(b);
|
||||
procedure operator+=(a: set of uint64; b: array of integer); extensionmethod
|
||||
:= a += NewSet&<uint64>(b);
|
||||
|
||||
// set -= set
|
||||
procedure operator-=(a: set of byte; b: set of integer); extensionmethod
|
||||
:= a -= NewSet&<byte>(b);
|
||||
procedure operator-=(a: set of word; b: set of integer); extensionmethod
|
||||
:= a -= NewSet&<word>(b);
|
||||
procedure operator-=(a: set of shortint; b: set of integer); extensionmethod
|
||||
:= a -= NewSet&<shortint>(b);
|
||||
procedure operator-=(a: set of smallint; b: set of integer); extensionmethod
|
||||
:= a -= NewSet&<smallint>(b);
|
||||
procedure operator-=(a: set of longword; b: set of integer); extensionmethod
|
||||
:= a -= NewSet&<longword>(b);
|
||||
procedure operator-=(a: set of int64; b: set of integer); extensionmethod
|
||||
:= a -= NewSet&<int64>(b);
|
||||
procedure operator-=(a: set of uint64; b: set of integer); extensionmethod
|
||||
:= a -= NewSet&<uint64>(b);
|
||||
|
||||
// set -= array
|
||||
procedure operator-=(a: set of byte; b: array of integer); extensionmethod
|
||||
:= a -= NewSet&<byte>(b);
|
||||
procedure operator-=(a: set of word; b: array of integer); extensionmethod
|
||||
:= a -= NewSet&<word>(b);
|
||||
procedure operator-=(a: set of shortint; b: array of integer); extensionmethod
|
||||
:= a -= NewSet&<shortint>(b);
|
||||
procedure operator-=(a: set of smallint; b: array of integer); extensionmethod
|
||||
:= a -= NewSet&<smallint>(b);
|
||||
procedure operator-=(a: set of longword; b: array of integer); extensionmethod
|
||||
:= a -= NewSet&<longword>(b);
|
||||
procedure operator-=(a: set of int64; b: array of integer); extensionmethod
|
||||
:= a -= NewSet&<int64>(b);
|
||||
procedure operator-=(a: set of uint64; b: array of integer); extensionmethod
|
||||
:= a -= NewSet&<uint64>(b);
|
||||
|
||||
// Один из операндов должен быть set of integer (array of integer)
|
||||
// operator* sets
|
||||
function operator*(a: set of integer; b: set of byte): set of integer; extensionmethod;
|
||||
begin
|
||||
Result := True;
|
||||
foreach var x in a do
|
||||
if x not in b then
|
||||
begin
|
||||
Result := False;
|
||||
exit
|
||||
end;
|
||||
Result := a;
|
||||
Result.hs.IntersectWith(b.Select(x -> integer(x)));
|
||||
end;
|
||||
|
||||
function operator=(a: NewSet<uint64>; b: NewSet<integer>): boolean; extensionmethod := b = a;
|
||||
function operator*(a: set of byte; b: set of integer): set of integer; extensionmethod
|
||||
:= b * a;
|
||||
|
||||
|
||||
function operator<>(a: NewSet<integer>; b: NewSet<byte>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<byte>; b: NewSet<integer>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<integer>; b: NewSet<shortint>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<shortint>; b: NewSet<integer>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<integer>; b: NewSet<smallint>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<smallint>; b: NewSet<integer>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<integer>; b: NewSet<word>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<word>; b: NewSet<integer>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<integer>; b: NewSet<longword>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<longword>; b: NewSet<integer>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<int64>; b: NewSet<integer>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<integer>; b: NewSet<int64>); extensionmethod := not(a = b);
|
||||
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<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<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<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<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<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<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<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<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<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+=<T>(var a: NewSet<T>; another: NewSet<T>); extensionmethod := a.hs.UnionWith(another.hs);
|
||||
|
||||
procedure operator+=(a: NewSet<byte>; b: NewSet<integer>); extensionmethod;
|
||||
function operator*(a: set of integer; b: set of int64): set of int64; extensionmethod;
|
||||
begin
|
||||
var x := a.hs;
|
||||
var bt := NSToBytes(b);
|
||||
a.hs.UnionWith(bt);
|
||||
Result := b;
|
||||
Result.hs.IntersectWith(a.Select(x -> int64(x)));
|
||||
end;
|
||||
|
||||
procedure operator+=(a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a.hs.UnionWith(NSToInts(b));
|
||||
procedure operator+=(a: NewSet<int64>; b: NewSet<integer>); extensionmethod := a.hs.UnionWith(NSToInts64(b));
|
||||
//procedure operator+=(a: NewSet<integer>; b: NewSet<int64>); extensionmethod := a.hs.UnionWith(NSToInts(b));
|
||||
procedure operator+=(a: NewSet<byte>; b: NewSet<int64>); extensionmethod := a.hs.UnionWith(NSToBytes(b));
|
||||
procedure operator+=(a: NewSet<int64>; b: NewSet<byte>); extensionmethod := a.hs.UnionWith(NSToInts64(b));
|
||||
function operator*(a: set of int64; b: set of integer): set of int64; extensionmethod
|
||||
:= b * a;
|
||||
|
||||
procedure operator-=(a: NewSet<byte>; b: NewSet<integer>); extensionmethod := a.hs.ExceptWith(NSToBytes(b));
|
||||
procedure operator-=(a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a.hs.ExceptWith(NSToInts(b));
|
||||
procedure operator-=(a: NewSet<int64>; b: NewSet<integer>); extensionmethod := a.hs.ExceptWith(NSToInts64(b));
|
||||
//procedure operator-=(a: NewSet<integer>; b: NewSet<int64>); extensionmethod := a.hs.ExceptWith(NSToInts(b));
|
||||
|
||||
|
||||
// Нет операции между set of byte и set of int64. Один из операндов должен быть set of integer
|
||||
function operator*(a: NewSet<integer>; b: NewSet<byte>): NewSet<integer>; extensionmethod;
|
||||
// set * array
|
||||
function operator*(a: array of integer; b: set of byte): set of integer; extensionmethod;
|
||||
begin
|
||||
Result += a; Result *= b
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.IntersectWith(b.Select(x -> integer(x)));
|
||||
end;
|
||||
|
||||
function operator*(a: NewSet<byte>; b: NewSet<integer>): NewSet<integer>; extensionmethod;
|
||||
function operator*(a: set of byte; b: array of integer): set of integer; extensionmethod
|
||||
:= b * a;
|
||||
|
||||
function operator*(a: array of integer; b: set of int64): set of int64; extensionmethod;
|
||||
begin
|
||||
Result += a; Result *= b
|
||||
Result.hs.UnionWith(b);
|
||||
Result.hs.IntersectWith(a.Select(x -> int64(x)));
|
||||
end;
|
||||
|
||||
function operator*(a: NewSet<integer>; b: NewSet<int64>): NewSet<int64>; extensionmethod;
|
||||
function operator*(a: set of int64; b: array of integer): set of int64; extensionmethod
|
||||
:= b * a;
|
||||
|
||||
function operator*(a: array of integer; b: set of integer): set of integer; extensionmethod;
|
||||
begin
|
||||
Result += a; Result *= b
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.IntersectWith(b);
|
||||
end;
|
||||
|
||||
function operator*(a: NewSet<int64>; b: NewSet<integer>): NewSet<int64>; extensionmethod;
|
||||
begin
|
||||
Result += a; Result *= b
|
||||
end;
|
||||
//-----
|
||||
function operator*(a: set of integer; b: array of integer): set of integer; extensionmethod
|
||||
:= b * a;
|
||||
|
||||
function operator+(a: NewSet<integer>; b: NewSet<byte>): NewSet<integer>; extensionmethod;
|
||||
|
||||
// operator+ sets
|
||||
function operator+(a: set of integer; b: set of byte): set of integer; extensionmethod;
|
||||
begin
|
||||
Result += a; Result += b
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.UnionWith(b.Select(x -> integer(x)));
|
||||
end;
|
||||
|
||||
function operator+(a: NewSet<byte>; b: NewSet<integer>): NewSet<integer>; extensionmethod;
|
||||
function operator+(a: set of byte; b: set of integer): set of integer; extensionmethod
|
||||
:= b * a;
|
||||
|
||||
function operator+(a: set of integer; b: set of int64): set of int64; extensionmethod;
|
||||
begin
|
||||
Result += a; Result += b
|
||||
Result.hs.UnionWith(b);
|
||||
Result.hs.UnionWith(a.Select(x -> int64(x)));
|
||||
end;
|
||||
|
||||
function operator+(a: NewSet<integer>; b: NewSet<int64>): NewSet<int64>; extensionmethod;
|
||||
function operator+(a: set of int64; b: set of integer): set of int64; extensionmethod
|
||||
:= b * a;
|
||||
|
||||
// set + array
|
||||
function operator+(a: array of integer; b: set of byte): set of integer; extensionmethod;
|
||||
begin
|
||||
Result += a; Result += b
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.UnionWith(b.Select(x -> integer(x)));
|
||||
end;
|
||||
|
||||
function operator+(a: NewSet<int64>; b: NewSet<integer>): NewSet<int64>; extensionmethod;
|
||||
function operator+(a: set of byte; b: array of integer): set of integer; extensionmethod
|
||||
:= b * a;
|
||||
|
||||
function operator+(a: array of integer; b: set of int64): set of int64; extensionmethod;
|
||||
begin
|
||||
Result += a; Result += b
|
||||
Result.hs.UnionWith(b);
|
||||
Result.hs.UnionWith(a.Select(x -> int64(x)));
|
||||
end;
|
||||
|
||||
//-----
|
||||
function operator-(a: NewSet<integer>; b: NewSet<byte>): NewSet<integer>; extensionmethod;
|
||||
function operator+(a: set of int64; b: array of integer): set of int64; extensionmethod
|
||||
:= b * a;
|
||||
|
||||
function operator+(a: set of integer; b: array of integer): set of integer; extensionmethod;
|
||||
begin
|
||||
Result += a; Result -= b
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.UnionWith(b);
|
||||
end;
|
||||
|
||||
function operator-(a: NewSet<byte>; b: NewSet<integer>): NewSet<integer>; extensionmethod;
|
||||
function operator+(a: array of integer; b: set of integer): set of integer; extensionmethod
|
||||
:= b * a;
|
||||
|
||||
|
||||
// operator- sets
|
||||
function operator-(a: set of integer; b: set of byte): set of integer; extensionmethod;
|
||||
begin
|
||||
Result += a; Result -= b
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.ExceptWith(b.Select(x -> integer(x)));
|
||||
end;
|
||||
|
||||
function operator-(a: NewSet<integer>; b: NewSet<int64>): NewSet<int64>; extensionmethod;
|
||||
function operator-(a: set of byte; b: set of integer): set of integer; extensionmethod;
|
||||
begin
|
||||
Result += a; Result -= b
|
||||
Result.hs.UnionWith(a.Select(x -> integer(x)));
|
||||
Result.hs.ExceptWith(b);
|
||||
end;
|
||||
|
||||
function operator-(a: NewSet<int64>; b: NewSet<integer>): NewSet<int64>; extensionmethod;
|
||||
function operator-(a: set of integer; b: set of int64): set of int64; extensionmethod;
|
||||
begin
|
||||
Result += a; Result -= b
|
||||
Result.hs.UnionWith(a.Select(x -> int64(x)));
|
||||
Result.hs.ExceptWith(b);
|
||||
end;
|
||||
|
||||
// и для массивов столько же
|
||||
(*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;
|
||||
*)
|
||||
//function operator=(a: NewSet<int64>; b: NewSet<byte>); extensionmethod := a._hs.SetEquals(NSToInts64(b));
|
||||
//function operator=(a: NewSet<byte>; b: NewSet<int64>): boolean; extensionmethod := a = b;
|
||||
function operator-(a: set of int64; b: set of integer): set of int64; extensionmethod;
|
||||
begin
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.ExceptWith(b.Select(x -> int64(x)));
|
||||
end;
|
||||
|
||||
// Следующие функции предназначены для сравнения массива целых со множеством.
|
||||
// Массив должен интерпретироваться как множество
|
||||
// Не пойму - что использовать - эту строку или предыдущие. Все типы массивов сравнивать с NewSet<integer>
|
||||
// или наоборот все типы множеств - с array of integer
|
||||
function operator=(a: NewSet<byte>; b: array of integer): boolean; extensionmethod := NSToInts(a).ToHashSet.SetEquals(b);
|
||||
// set - array
|
||||
function operator-(a: array of integer; b: set of byte): set of integer; extensionmethod;
|
||||
begin
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.ExceptWith(b.Select(x -> integer(x)));
|
||||
end;
|
||||
|
||||
function operator-(a: set of byte; b: array of integer): set of integer; extensionmethod;
|
||||
begin
|
||||
Result.hs.UnionWith(a.Select(x -> integer(x)));
|
||||
Result.hs.ExceptWith(b);
|
||||
end;
|
||||
|
||||
function operator-(a: array of integer; b: set of int64): set of int64; extensionmethod;
|
||||
begin
|
||||
Result.hs.UnionWith(a.Select(x -> int64(x)));
|
||||
Result.hs.ExceptWith(b);
|
||||
end;
|
||||
|
||||
function operator-(a: set of int64; b: array of integer): set of int64; extensionmethod;
|
||||
begin
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.ExceptWith(b.Select(x -> int64(x)));
|
||||
end;
|
||||
|
||||
function operator-(a: array of integer; b: set of integer): set of integer; extensionmethod;
|
||||
begin
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.ExceptWith(b);
|
||||
end;
|
||||
|
||||
function operator-(a: set of integer; b: array of integer): set of integer; extensionmethod;
|
||||
begin
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.ExceptWith(b);
|
||||
end;
|
||||
|
||||
|
||||
var __initialized: boolean;
|
||||
|
|
|
|||
|
|
@ -504,10 +504,6 @@ type
|
|||
end;
|
||||
function GetEnumerator: IEnumerator<T> := hs.GetEnumerator;
|
||||
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);
|
||||
end;
|
||||
/// Преобразовать к строковому представлению
|
||||
function ToString: string; override;
|
||||
/// Количество элементов в множестве
|
||||
|
|
@ -555,6 +551,10 @@ type
|
|||
begin
|
||||
Result.hs.UnionWith(ns);
|
||||
end;
|
||||
static function operator implicit(a: array of T): NewSet<T>;
|
||||
begin
|
||||
Result._hs := new HashSet<T>(a);
|
||||
end;
|
||||
|
||||
static function operator implicit(ns: NewSetEmpty): NewSet<T>; begin end;
|
||||
static function operator:=(var s: NewSet<T>; st: NewSet<T>): NewSet<T>; // Эту функцию обязательно здесь определять
|
||||
|
|
@ -2699,7 +2699,7 @@ function HSetInt(params a: array of integer): HashSet<integer>;
|
|||
/// Возвращает множество на базе хеш таблицы, заполненное строковыми значениями
|
||||
function HSetStr(params a: array of string): HashSet<string>;
|
||||
/// Возвращает множество, заполненное указанными значениями
|
||||
function SetOf<T>(params a: array of T): HashSet<T>;
|
||||
function SetOf<T>(params a: array of T): NewSet<T>;
|
||||
|
||||
|
||||
/// Возвращает множество на базе бинарного дерева поиска, заполненное указанными значениями
|
||||
|
|
@ -6097,8 +6097,10 @@ function HSet(a: IntRange): HashSet<integer> := new HashSet<integer>(a);
|
|||
|
||||
function HSet(a: CharRange): HashSet<char> := new HashSet<char>(a);
|
||||
|
||||
function SetOf<T>(params a: array of T): HashSet<T> := new HashSet<T>(a);
|
||||
|
||||
function SetOf<T>(params a: array of T): NewSet<T>;
|
||||
begin
|
||||
Result._hs := new HashSet<T>(a);
|
||||
end;
|
||||
|
||||
function Dict<TKey, TVal>(params pairs: array of KeyValuePair<TKey, TVal>): Dictionary<TKey, TVal>;
|
||||
begin
|
||||
|
|
@ -11188,9 +11190,9 @@ begin
|
|||
end;
|
||||
|
||||
/// Возвращает множество по данной последовательности
|
||||
function ToSet<T>(Self: sequence of T): HashSet<T>; extensionmethod;
|
||||
function ToSet<T>(Self: sequence of T): NewSet<T>; extensionmethod;
|
||||
begin
|
||||
Result := new HashSet<T>(Self);
|
||||
Result._hs := new HashSet<T>(Self);
|
||||
end;
|
||||
|
||||
/// Возвращает множество SortedSet по данной последовательности
|
||||
|
|
@ -15067,14 +15069,6 @@ function operator><T1,T2,T3,T4,T5,T6,T7>(Self: (T1, T2, T3, T4,T5,T6,T7); v: (T1
|
|||
///--
|
||||
function operator>=<T1,T2,T3,T4,T5,T6,T7>(Self: (T1, T2, T3, T4,T5,T6,T7); v: (T1, T2, T3, T4,T5,T6,T7)); extensionmethod := CompareToTup5(Self, v) >= 0;
|
||||
|
||||
{
|
||||
///--
|
||||
function operator implicit<T>(a: array of T): set of T; extensionmethod;
|
||||
begin
|
||||
foreach var x in a do
|
||||
Include(Result,x);
|
||||
end;
|
||||
}
|
||||
|
||||
{// Определяет, есть ли указанный элемент в массиве
|
||||
function Contains<T>(self: array of T; x: T): boolean; extensionmethod;
|
||||
|
|
@ -15482,60 +15476,7 @@ begin
|
|||
end
|
||||
end;
|
||||
|
||||
function operator implicit(a: set of integer): set of BigInteger; extensionmethod;
|
||||
begin
|
||||
foreach var x in a do
|
||||
Result.Add(x);
|
||||
end;
|
||||
|
||||
//------------------
|
||||
function operator implicit(n: array of integer): set of byte; extensionmethod;
|
||||
begin
|
||||
foreach var x in n do
|
||||
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);
|
||||
end;
|
||||
|
||||
function operator implicit(n: array of integer): set of smallint; extensionmethod;
|
||||
begin
|
||||
foreach var x in n do
|
||||
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);
|
||||
end;
|
||||
|
||||
function operator implicit(n: array of integer): set of longword; extensionmethod;
|
||||
begin
|
||||
foreach var x in n do
|
||||
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);
|
||||
end;
|
||||
|
||||
function operator implicit(a: array of integer): set of uint64; extensionmethod;
|
||||
begin
|
||||
foreach var x in a do
|
||||
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);
|
||||
end;
|
||||
|
||||
//function operator implicit<T>(ns: NewSetEmpty): NewSet<T>; extensionmethod; begin end;
|
||||
|
||||
|
|
@ -15824,7 +15765,8 @@ begin
|
|||
end;
|
||||
try
|
||||
if (System.Environment.OSVersion.Version.Major >= 6) and (System.Environment.OSVersion.Version.Minor >= 2) then
|
||||
System.Console.OutputEncoding := Encoding.UTF8;
|
||||
System.Console.OutputEncoding := new System.Text.UTF8Encoding(false);
|
||||
//System.Console.OutputEncoding := Encoding.UTF8;
|
||||
except
|
||||
end;
|
||||
rnd := new System.Random;
|
||||
|
|
|
|||
|
|
@ -456,18 +456,22 @@ begin
|
|||
end;
|
||||
|
||||
// Важнейший для новых множеств !!!
|
||||
{procedure operator:=<T>(var Self: NewSet<T>; st: NewSet<T>); extensionmethod;
|
||||
{procedure operator:=<T>(var Self: set of T>; st: set of T>); extensionmethod;
|
||||
begin
|
||||
Self._hs := new HashSet<T>(st.hs);
|
||||
end;}
|
||||
|
||||
{procedure operator:=<T>(var Self: NewSet<T>; st: NewSetEmpty); extensionmethod;
|
||||
{procedure operator:=<T>(var Self: set of T>; st: NewSetEmpty); extensionmethod;
|
||||
begin
|
||||
Self._hs := new HashSet<T>();
|
||||
end;}
|
||||
|
||||
// --------------------------------------
|
||||
// Extension-методы для новых множеств
|
||||
function operator implicit(n: NewSet<integer>): NewSet<byte>; extensionmethod;
|
||||
// --------------------------------------
|
||||
|
||||
// operator implicit
|
||||
function operator implicit(n: set of integer): set of byte; extensionmethod;
|
||||
begin
|
||||
foreach var x in n._hs do
|
||||
if (x >= byte.MinValue) and (x <= byte.MaxValue) then
|
||||
|
|
@ -475,7 +479,7 @@ begin
|
|||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(n: NewSet<integer>): NewSet<shortint>; extensionmethod;
|
||||
function operator implicit(n: set of integer): set of shortint; extensionmethod;
|
||||
begin
|
||||
foreach var x in n._hs do
|
||||
if (x >= shortint.MinValue) and (x <= shortint.MaxValue) then
|
||||
|
|
@ -483,7 +487,7 @@ begin
|
|||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(n: NewSet<integer>): NewSet<smallint>; extensionmethod;
|
||||
function operator implicit(n: set of integer): set of smallint; extensionmethod;
|
||||
begin
|
||||
foreach var x in n._hs do
|
||||
if (x >= smallint.MinValue) and (x <= smallint.MaxValue) then
|
||||
|
|
@ -491,7 +495,7 @@ begin
|
|||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(n: NewSet<integer>): NewSet<word>; extensionmethod;
|
||||
function operator implicit(n: set of integer): set of word; extensionmethod;
|
||||
begin
|
||||
foreach var x in n._hs do
|
||||
if (x >= word.MinValue) and (x <= word.MaxValue) then
|
||||
|
|
@ -499,7 +503,7 @@ begin
|
|||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(n: NewSet<integer>): NewSet<longword>; extensionmethod;
|
||||
function operator implicit(n: set of integer): set of longword; extensionmethod;
|
||||
begin
|
||||
foreach var x in n._hs do
|
||||
if (x >= longword.MinValue) and (x <= longword.MaxValue) then
|
||||
|
|
@ -507,13 +511,13 @@ begin
|
|||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(n: NewSet<integer>): NewSet<int64>; extensionmethod;
|
||||
function operator implicit(n: set of integer): set of int64; extensionmethod;
|
||||
begin
|
||||
foreach var x in n._hs do
|
||||
Result._hs.Add(x)
|
||||
end;
|
||||
|
||||
function operator implicit(n: NewSet<integer>): NewSet<uint64>; extensionmethod;
|
||||
function operator implicit(n: set of integer): set of uint64; extensionmethod;
|
||||
begin
|
||||
foreach var x in n._hs do
|
||||
if x >= 0 then
|
||||
|
|
@ -521,15 +525,81 @@ begin
|
|||
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<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>): sequence of byte;
|
||||
function operator implicit(a: set of integer): set of BigInteger; extensionmethod;
|
||||
begin
|
||||
foreach var x in a do
|
||||
Result._hs.Add(x);
|
||||
end;
|
||||
|
||||
//-- operator implicit array of integer -> set of целое
|
||||
function operator implicit(n: array of integer): set of byte; extensionmethod;
|
||||
begin
|
||||
foreach var x in n do
|
||||
if (x >= byte.MinValue) and (x <= byte.MaxValue) then
|
||||
Result._hs.Add(x)
|
||||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(n: array of integer): set of shortint; extensionmethod;
|
||||
begin
|
||||
foreach var x in n do
|
||||
if (x >= shortint.MinValue) and (x <= shortint.MaxValue) then
|
||||
Result._hs.Add(x)
|
||||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(n: array of integer): set of smallint; extensionmethod;
|
||||
begin
|
||||
foreach var x in n do
|
||||
if (x >= smallint.MinValue) and (x <= smallint.MaxValue) then
|
||||
Result._hs.Add(x)
|
||||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(n: array of integer): set of word; extensionmethod;
|
||||
begin
|
||||
foreach var x in n do
|
||||
if (x >= word.MinValue) and (x <= word.MaxValue) then
|
||||
Result._hs.Add(x)
|
||||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(n: array of integer): set of longword; extensionmethod;
|
||||
begin
|
||||
foreach var x in n do
|
||||
if (x >= longword.MinValue) and (x <= longword.MaxValue) then
|
||||
Result._hs.Add(x)
|
||||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(a: array of integer): set of int64; extensionmethod;
|
||||
begin
|
||||
foreach var x in a do
|
||||
Result._hs.Add(x);
|
||||
end;
|
||||
|
||||
function operator implicit(a: array of integer): set of uint64; extensionmethod;
|
||||
begin
|
||||
foreach var x in a do
|
||||
if x >= 0 then
|
||||
Result._hs.Add(x)
|
||||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT));
|
||||
end;
|
||||
|
||||
function operator implicit(a: array of integer): set of BigInteger; extensionmethod;
|
||||
begin
|
||||
foreach var x in a do
|
||||
Result._hs.Add(x);
|
||||
end;
|
||||
|
||||
function NSToInts(ns: set of byte) := ns._hs.Select(x -> integer(x));
|
||||
function NSToInts(ns: set of shortint) := ns._hs.Select(x -> integer(x));
|
||||
function NSToInts(ns: set of smallint) := ns._hs.Select(x -> integer(x));
|
||||
function NSToInts(ns: set of word) := ns._hs.Select(x -> integer(x));
|
||||
function NSToInts64(ns: set of byte) := ns._hs.Select(x -> int64(x));
|
||||
function NSToInts64(ns: set of integer) := ns._hs.Select(x -> int64(x));
|
||||
|
||||
function NSToBytes(ns: set of integer): sequence of byte;
|
||||
begin
|
||||
var res := new List<byte>;
|
||||
foreach var x in ns._hs do
|
||||
|
|
@ -539,7 +609,7 @@ begin
|
|||
Result := res;
|
||||
end;
|
||||
|
||||
function NSToBytes(ns: NewSet<int64>): sequence of byte;
|
||||
function NSToBytes(ns: set of int64): sequence of byte;
|
||||
begin
|
||||
var res := new List<byte>;
|
||||
foreach var x in ns._hs do
|
||||
|
|
@ -549,184 +619,455 @@ begin
|
|||
Result := res;
|
||||
end;
|
||||
|
||||
// Надо set of integer со всеми
|
||||
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<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<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<word>; b: NewSet<integer>): boolean; extensionmethod := b = a;
|
||||
// operator= для set
|
||||
// set of integer сравнивается со всеми
|
||||
function operator=(a: set of integer; b: set of byte); extensionmethod
|
||||
:= (a.Count = b.Count) and b.All(x -> x in a); // x в меньшем диапазоне, поэтому x in a работает верно
|
||||
function operator=(a: set of byte; b: set of integer): boolean; extensionmethod
|
||||
:= b = a;
|
||||
function operator=(a: set of integer; b: set of shortint); extensionmethod
|
||||
:= (a.Count = b.Count) and b.All(x -> x in a);
|
||||
function operator=(a: set of shortint; b: set of integer): boolean; extensionmethod
|
||||
:= b = a;
|
||||
function operator=(a: set of integer; b: set of smallint); extensionmethod
|
||||
:= (a.Count = b.Count) and b.All(x -> x in a);
|
||||
function operator=(a: set of smallint; b: set of integer): boolean; extensionmethod
|
||||
:= b = a;
|
||||
function operator=(a: set of integer; b: set of word); extensionmethod
|
||||
:= (a.Count = b.Count) and b.All(x -> x in a);
|
||||
function operator=(a: set of word; b: set of 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)));
|
||||
end;
|
||||
function operator=(a: set of integer; b: set of longword): boolean; extensionmethod
|
||||
:= (a.Count = b.Count) and a.All(x -> x >= 0) and a.All(x -> x in b);
|
||||
function operator=(a: set of longword; b: set of integer): boolean; extensionmethod
|
||||
:= b = a;
|
||||
|
||||
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<integer>; b: NewSet<int64>): boolean; extensionmethod := b = a;
|
||||
function operator=(a: set of int64; b: set of integer); extensionmethod
|
||||
:= (a.Count = b.Count) and b.All(x -> x in a);
|
||||
function operator=(a: set of integer; b: set of int64): boolean; extensionmethod
|
||||
:= b = a;
|
||||
|
||||
// Здесь оба типа нельзя расширить до общего типа, и есть проблема
|
||||
function operator=(a: NewSet<integer>; b: NewSet<uint64>): boolean; extensionmethod;
|
||||
function operator=(a: set of integer; b: set of uint64): boolean; extensionmethod
|
||||
:= (a.Count = b.Count) and a.All(x -> x >= 0) and a.All(x -> x in b);
|
||||
function operator=(a: set of uint64; b: set of integer): boolean; extensionmethod := b = a;
|
||||
|
||||
|
||||
// arrays = sets
|
||||
function operator=(a: array of integer; b: set of byte); extensionmethod
|
||||
:= a.ToSet = b;
|
||||
function operator=(a: set of byte; b: array of integer): boolean; extensionmethod := b = a;
|
||||
function operator=(a: array of integer; b: set of shortint); extensionmethod
|
||||
:= a.ToSet = b;
|
||||
function operator=(a: set of shortint; b: array of integer): boolean; extensionmethod := b = a;
|
||||
function operator=(a: array of integer; b: set of smallint); extensionmethod
|
||||
:= a.ToSet = b;
|
||||
function operator=(a: set of smallint; b: array of integer): boolean; extensionmethod := b = a;
|
||||
function operator=(a: array of integer; b: set of word); extensionmethod
|
||||
:= a.ToSet = b;
|
||||
function operator=(a: set of word; b: array of integer): boolean; extensionmethod := b = a;
|
||||
function operator=(a: array of integer; b: set of longword): boolean; extensionmethod
|
||||
:= a.ToSet = b;
|
||||
function operator=(a: set of longword; b: array of integer): boolean; extensionmethod := b = a;
|
||||
function operator=(a: array of integer; b: set of int64): boolean; extensionmethod
|
||||
:= a.ToSet = b;
|
||||
function operator=(a: set of int64; b: array of integer); extensionmethod := b = a;
|
||||
function operator=(a: array of integer; b: set of uint64): boolean; extensionmethod
|
||||
:= a.ToSet = b;
|
||||
function operator=(a: set of uint64; b: array of integer): boolean; extensionmethod := b = a;
|
||||
function operator=(a: array of integer; b: set of integer); extensionmethod
|
||||
:= (a.Count = b.Count) and a.All(x -> x in b);
|
||||
function operator=(a: set of integer; b: array of integer): boolean; extensionmethod := b = a;
|
||||
|
||||
// operator<> для set
|
||||
function operator<>(a: set of integer; b: set of byte); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of byte; b: set of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of integer; b: set of shortint); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of shortint; b: set of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of integer; b: set of smallint); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of smallint; b: set of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of integer; b: set of word); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of word; b: set of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of integer; b: set of longword); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of longword; b: set of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of integer; b: set of int64); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of int64; b: set of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of integer; b: set of uint64); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of uint64; b: set of integer); extensionmethod := not(a = b);
|
||||
|
||||
// set<>array
|
||||
function operator<>(a: array of integer; b: set of byte); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of byte; b: array of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: array of integer; b: set of shortint); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of shortint; b: array of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: array of integer; b: set of smallint); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of smallint; b: array of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: array of integer; b: set of word); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of word; b: array of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: array of integer; b: set of longword); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of longword; b: array of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: array of integer; b: set of int64); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of int64; b: array of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: array of integer; b: set of uint64); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of uint64; b: array of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: array of integer; b: set of integer); extensionmethod := not(a = b);
|
||||
function operator<>(a: set of integer; b: array of integer); extensionmethod := not(a = b);
|
||||
|
||||
// operator< для set
|
||||
function operator<(a: set of integer; b: set of byte); extensionmethod
|
||||
:= (a.Count < b.Count) and a.All(x -> (x >= 0) and (x <= byte.MaxValue) and (x in b));
|
||||
function operator<(a: set of byte; b: set of integer); extensionmethod
|
||||
:= (a.Count < b.Count) and a.All(x -> x in b);
|
||||
function operator<(a: set of integer; b: set of int64); extensionmethod
|
||||
:= (a.Count < b.Count) and a.All(x -> x in b);
|
||||
function operator<(a: set of int64; b: set of integer); extensionmethod
|
||||
:= (a.Count < b.Count) and a.All(x -> (x >= 0) and (x <= byte.MaxValue) and (x in b));
|
||||
|
||||
// set < array
|
||||
function operator<(a: array of integer; b: set of byte); extensionmethod
|
||||
:= a.ToSet < b;
|
||||
function operator<(a: set of byte; b: array of integer); extensionmethod
|
||||
:= a < b.ToSet;
|
||||
function operator<(a: array of integer; b: set of int64); extensionmethod
|
||||
:= a.ToSet < b;
|
||||
function operator<(a: set of int64; b: array of integer); extensionmethod
|
||||
:= a < b.ToSet;
|
||||
function operator<(a: array of integer; b: set of integer); extensionmethod
|
||||
:= (a.Count < b.Count) and a.All(x -> x in b);
|
||||
function operator<(a: set of integer; b: array of integer); extensionmethod
|
||||
:= (a.Count < b.Count) and a.All(x -> x in b);
|
||||
|
||||
// operator> для set
|
||||
function operator>(a: set of integer; b: set of byte); extensionmethod
|
||||
:= b < a;
|
||||
function operator>(a: set of byte; b: set of integer); extensionmethod
|
||||
:= b < a;
|
||||
function operator>(a: set of integer; b: set of int64); extensionmethod
|
||||
:= b < a;
|
||||
function operator>(a: set of int64; b: set of integer); extensionmethod
|
||||
:= b < a;
|
||||
|
||||
// set > array
|
||||
function operator>(a: array of integer; b: set of byte); extensionmethod
|
||||
:= b < a;
|
||||
function operator>(a: set of byte; b: array of integer); extensionmethod
|
||||
:= b < a;
|
||||
function operator>(a: array of integer; b: set of int64); extensionmethod
|
||||
:= b < a;
|
||||
function operator>(a: set of int64; b: array of integer); extensionmethod
|
||||
:= b < a;
|
||||
function operator>(a: array of integer; b: set of integer); extensionmethod
|
||||
:= b < a;
|
||||
function operator>(a: set of integer; b: array of integer); extensionmethod
|
||||
:= b < a;
|
||||
|
||||
// operator<= для set - доделать!!!
|
||||
function operator<=(a: set of integer; b: set of byte); extensionmethod
|
||||
:= (a.Count <= b.Count) and a.All(x -> (x >= 0) and (x <= byte.MaxValue) and (x in b));
|
||||
function operator<=(a: set of byte; b: set of integer); extensionmethod
|
||||
:= (a.Count <= b.Count) and a.All(x -> x in b);
|
||||
function operator<=(a: set of int64; b: set of integer); extensionmethod
|
||||
:= (a.Count <= b.Count) and a.All(x -> x in b);
|
||||
function operator<=(a: set of integer; b: set of int64); extensionmethod
|
||||
:= (a.Count <= b.Count) and a.All(x -> (x >= 0) and (x <= byte.MaxValue) and (x in b));
|
||||
|
||||
// set <= array
|
||||
function operator<=(a: array of integer; b: set of byte); extensionmethod
|
||||
:= a.ToSet <= b;
|
||||
function operator<=(a: set of byte; b: array of integer); extensionmethod
|
||||
:= a <= b.ToSet;
|
||||
function operator<=(a: array of integer; b: set of int64); extensionmethod
|
||||
:= a.ToSet <= b;
|
||||
function operator<=(a: set of int64; b: array of integer); extensionmethod
|
||||
:= a <= b.ToSet;
|
||||
function operator<=(a: array of integer; b: set of integer); extensionmethod
|
||||
:= (a.Count <= b.Count) and a.All(x -> x in b);
|
||||
function operator<=(a: set of integer; b: array of integer); extensionmethod
|
||||
:= (a.Count <= b.Count) and a.All(x -> x in b);
|
||||
|
||||
|
||||
// operator>= для set
|
||||
function operator>=(a: set of integer; b: set of byte); extensionmethod
|
||||
:= b <= a;
|
||||
function operator>=(a: set of byte; b: set of integer); extensionmethod
|
||||
:= b <= a;
|
||||
function operator>=(a: set of int64; b: set of integer); extensionmethod
|
||||
:= b <= a;
|
||||
function operator>=(a: set of integer; b: set of int64); extensionmethod
|
||||
:= b <= a;
|
||||
|
||||
// set >= array
|
||||
function operator>=(a: array of integer; b: set of byte); extensionmethod
|
||||
:= b <= a;
|
||||
function operator>=(a: set of byte; b: array of integer); extensionmethod
|
||||
:= b <= a;
|
||||
function operator>=(a: array of integer; b: set of int64); extensionmethod
|
||||
:= b <= a;
|
||||
function operator>=(a: set of int64; b: array of integer); extensionmethod
|
||||
:= b <= a;
|
||||
function operator>=(a: array of integer; b: set of integer); extensionmethod
|
||||
:= b <= a;
|
||||
function operator>=(a: set of integer; b: array of integer); extensionmethod
|
||||
:= b <= a;
|
||||
|
||||
|
||||
// set *= set
|
||||
procedure operator*=(a: set of byte; b: set of integer); extensionmethod
|
||||
:= a *= NewSet&<byte>(b);
|
||||
procedure operator*=(a: set of word; b: set of integer); extensionmethod
|
||||
:= a *= NewSet&<word>(b);
|
||||
procedure operator*=(a: set of shortint; b: set of integer); extensionmethod
|
||||
:= a *= NewSet&<shortint>(b);
|
||||
procedure operator*=(a: set of smallint; b: set of integer); extensionmethod
|
||||
:= a *= NewSet&<smallint>(b);
|
||||
procedure operator*=(a: set of longword; b: set of integer); extensionmethod
|
||||
:= a *= NewSet&<longword>(b);
|
||||
procedure operator*=(a: set of int64; b: set of integer); extensionmethod
|
||||
:= a *= NewSet&<int64>(b);
|
||||
procedure operator*=(a: set of uint64; b: set of integer); extensionmethod
|
||||
:= a *= NewSet&<uint64>(b);
|
||||
|
||||
// set *= array
|
||||
procedure operator*=(a: set of byte; b: array of integer); extensionmethod
|
||||
:= a *= NewSet&<byte>(b);
|
||||
procedure operator*=(a: set of word; b: array of integer); extensionmethod
|
||||
:= a *= NewSet&<word>(b);
|
||||
procedure operator*=(a: set of shortint; b: array of integer); extensionmethod
|
||||
:= a *= NewSet&<shortint>(b);
|
||||
procedure operator*=(a: set of smallint; b: array of integer); extensionmethod
|
||||
:= a *= NewSet&<smallint>(b);
|
||||
procedure operator*=(a: set of longword; b: array of integer); extensionmethod
|
||||
:= a *= NewSet&<longword>(b);
|
||||
procedure operator*=(a: set of int64; b: array of integer); extensionmethod
|
||||
:= a *= NewSet&<int64>(b);
|
||||
procedure operator*=(a: set of uint64; b: array of integer); extensionmethod
|
||||
:= a *= NewSet&<uint64>(b);
|
||||
|
||||
|
||||
// set += set
|
||||
procedure operator+=(a: set of byte; b: set of integer); extensionmethod
|
||||
:= a += NewSet&<byte>(b);
|
||||
procedure operator+=(a: set of word; b: set of integer); extensionmethod
|
||||
:= a += NewSet&<word>(b);
|
||||
procedure operator+=(a: set of shortint; b: set of integer); extensionmethod
|
||||
:= a += NewSet&<shortint>(b);
|
||||
procedure operator+=(a: set of smallint; b: set of integer); extensionmethod
|
||||
:= a += NewSet&<smallint>(b);
|
||||
procedure operator+=(a: set of longword; b: set of integer); extensionmethod
|
||||
:= a += NewSet&<longword>(b);
|
||||
procedure operator+=(a: set of int64; b: set of integer); extensionmethod
|
||||
:= a += NewSet&<int64>(b);
|
||||
procedure operator+=(a: set of uint64; b: set of integer); extensionmethod
|
||||
:= a += NewSet&<uint64>(b);
|
||||
|
||||
// set += array
|
||||
procedure operator+=(a: set of byte; b: array of integer); extensionmethod
|
||||
:= a += NewSet&<byte>(b);
|
||||
procedure operator+=(a: set of word; b: array of integer); extensionmethod
|
||||
:= a += NewSet&<word>(b);
|
||||
procedure operator+=(a: set of shortint; b: array of integer); extensionmethod
|
||||
:= a += NewSet&<shortint>(b);
|
||||
procedure operator+=(a: set of smallint; b: array of integer); extensionmethod
|
||||
:= a += NewSet&<smallint>(b);
|
||||
procedure operator+=(a: set of longword; b: array of integer); extensionmethod
|
||||
:= a += NewSet&<longword>(b);
|
||||
procedure operator+=(a: set of int64; b: array of integer); extensionmethod
|
||||
:= a += NewSet&<int64>(b);
|
||||
procedure operator+=(a: set of uint64; b: array of integer); extensionmethod
|
||||
:= a += NewSet&<uint64>(b);
|
||||
|
||||
// set -= set
|
||||
procedure operator-=(a: set of byte; b: set of integer); extensionmethod
|
||||
:= a -= NewSet&<byte>(b);
|
||||
procedure operator-=(a: set of word; b: set of integer); extensionmethod
|
||||
:= a -= NewSet&<word>(b);
|
||||
procedure operator-=(a: set of shortint; b: set of integer); extensionmethod
|
||||
:= a -= NewSet&<shortint>(b);
|
||||
procedure operator-=(a: set of smallint; b: set of integer); extensionmethod
|
||||
:= a -= NewSet&<smallint>(b);
|
||||
procedure operator-=(a: set of longword; b: set of integer); extensionmethod
|
||||
:= a -= NewSet&<longword>(b);
|
||||
procedure operator-=(a: set of int64; b: set of integer); extensionmethod
|
||||
:= a -= NewSet&<int64>(b);
|
||||
procedure operator-=(a: set of uint64; b: set of integer); extensionmethod
|
||||
:= a -= NewSet&<uint64>(b);
|
||||
|
||||
// set -= array
|
||||
procedure operator-=(a: set of byte; b: array of integer); extensionmethod
|
||||
:= a -= NewSet&<byte>(b);
|
||||
procedure operator-=(a: set of word; b: array of integer); extensionmethod
|
||||
:= a -= NewSet&<word>(b);
|
||||
procedure operator-=(a: set of shortint; b: array of integer); extensionmethod
|
||||
:= a -= NewSet&<shortint>(b);
|
||||
procedure operator-=(a: set of smallint; b: array of integer); extensionmethod
|
||||
:= a -= NewSet&<smallint>(b);
|
||||
procedure operator-=(a: set of longword; b: array of integer); extensionmethod
|
||||
:= a -= NewSet&<longword>(b);
|
||||
procedure operator-=(a: set of int64; b: array of integer); extensionmethod
|
||||
:= a -= NewSet&<int64>(b);
|
||||
procedure operator-=(a: set of uint64; b: array of integer); extensionmethod
|
||||
:= a -= NewSet&<uint64>(b);
|
||||
|
||||
// Один из операндов должен быть set of integer (array of integer)
|
||||
// operator* sets
|
||||
function operator*(a: set of integer; b: set of byte): set of integer; extensionmethod;
|
||||
begin
|
||||
Result := True;
|
||||
foreach var x in a do
|
||||
if x not in b then
|
||||
begin
|
||||
Result := False;
|
||||
exit
|
||||
end;
|
||||
Result := a;
|
||||
Result.hs.IntersectWith(b.Select(x -> integer(x)));
|
||||
end;
|
||||
|
||||
function operator=(a: NewSet<uint64>; b: NewSet<integer>): boolean; extensionmethod := b = a;
|
||||
function operator*(a: set of byte; b: set of integer): set of integer; extensionmethod
|
||||
:= b * a;
|
||||
|
||||
|
||||
function operator<>(a: NewSet<integer>; b: NewSet<byte>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<byte>; b: NewSet<integer>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<integer>; b: NewSet<shortint>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<shortint>; b: NewSet<integer>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<integer>; b: NewSet<smallint>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<smallint>; b: NewSet<integer>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<integer>; b: NewSet<word>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<word>; b: NewSet<integer>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<integer>; b: NewSet<longword>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<longword>; b: NewSet<integer>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<int64>; b: NewSet<integer>); extensionmethod := not(a = b);
|
||||
function operator<>(a: NewSet<integer>; b: NewSet<int64>); extensionmethod := not(a = b);
|
||||
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<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<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<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<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<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<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<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<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<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+=<T>(var a: NewSet<T>; another: NewSet<T>); extensionmethod := a.hs.UnionWith(another.hs);
|
||||
|
||||
procedure operator+=(a: NewSet<byte>; b: NewSet<integer>); extensionmethod;
|
||||
function operator*(a: set of integer; b: set of int64): set of int64; extensionmethod;
|
||||
begin
|
||||
var x := a.hs;
|
||||
var bt := NSToBytes(b);
|
||||
a.hs.UnionWith(bt);
|
||||
Result := b;
|
||||
Result.hs.IntersectWith(a.Select(x -> int64(x)));
|
||||
end;
|
||||
|
||||
procedure operator+=(a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a.hs.UnionWith(NSToInts(b));
|
||||
procedure operator+=(a: NewSet<int64>; b: NewSet<integer>); extensionmethod := a.hs.UnionWith(NSToInts64(b));
|
||||
//procedure operator+=(a: NewSet<integer>; b: NewSet<int64>); extensionmethod := a.hs.UnionWith(NSToInts(b));
|
||||
procedure operator+=(a: NewSet<byte>; b: NewSet<int64>); extensionmethod := a.hs.UnionWith(NSToBytes(b));
|
||||
procedure operator+=(a: NewSet<int64>; b: NewSet<byte>); extensionmethod := a.hs.UnionWith(NSToInts64(b));
|
||||
function operator*(a: set of int64; b: set of integer): set of int64; extensionmethod
|
||||
:= b * a;
|
||||
|
||||
procedure operator-=(a: NewSet<byte>; b: NewSet<integer>); extensionmethod := a.hs.ExceptWith(NSToBytes(b));
|
||||
procedure operator-=(a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a.hs.ExceptWith(NSToInts(b));
|
||||
procedure operator-=(a: NewSet<int64>; b: NewSet<integer>); extensionmethod := a.hs.ExceptWith(NSToInts64(b));
|
||||
//procedure operator-=(a: NewSet<integer>; b: NewSet<int64>); extensionmethod := a.hs.ExceptWith(NSToInts(b));
|
||||
|
||||
|
||||
// Нет операции между set of byte и set of int64. Один из операндов должен быть set of integer
|
||||
function operator*(a: NewSet<integer>; b: NewSet<byte>): NewSet<integer>; extensionmethod;
|
||||
// set * array
|
||||
function operator*(a: array of integer; b: set of byte): set of integer; extensionmethod;
|
||||
begin
|
||||
Result += a; Result *= b
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.IntersectWith(b.Select(x -> integer(x)));
|
||||
end;
|
||||
|
||||
function operator*(a: NewSet<byte>; b: NewSet<integer>): NewSet<integer>; extensionmethod;
|
||||
function operator*(a: set of byte; b: array of integer): set of integer; extensionmethod
|
||||
:= b * a;
|
||||
|
||||
function operator*(a: array of integer; b: set of int64): set of int64; extensionmethod;
|
||||
begin
|
||||
Result += a; Result *= b
|
||||
Result.hs.UnionWith(b);
|
||||
Result.hs.IntersectWith(a.Select(x -> int64(x)));
|
||||
end;
|
||||
|
||||
function operator*(a: NewSet<integer>; b: NewSet<int64>): NewSet<int64>; extensionmethod;
|
||||
function operator*(a: set of int64; b: array of integer): set of int64; extensionmethod
|
||||
:= b * a;
|
||||
|
||||
function operator*(a: array of integer; b: set of integer): set of integer; extensionmethod;
|
||||
begin
|
||||
Result += a; Result *= b
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.IntersectWith(b);
|
||||
end;
|
||||
|
||||
function operator*(a: NewSet<int64>; b: NewSet<integer>): NewSet<int64>; extensionmethod;
|
||||
begin
|
||||
Result += a; Result *= b
|
||||
end;
|
||||
//-----
|
||||
function operator*(a: set of integer; b: array of integer): set of integer; extensionmethod
|
||||
:= b * a;
|
||||
|
||||
function operator+(a: NewSet<integer>; b: NewSet<byte>): NewSet<integer>; extensionmethod;
|
||||
|
||||
// operator+ sets
|
||||
function operator+(a: set of integer; b: set of byte): set of integer; extensionmethod;
|
||||
begin
|
||||
Result += a; Result += b
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.UnionWith(b.Select(x -> integer(x)));
|
||||
end;
|
||||
|
||||
function operator+(a: NewSet<byte>; b: NewSet<integer>): NewSet<integer>; extensionmethod;
|
||||
function operator+(a: set of byte; b: set of integer): set of integer; extensionmethod
|
||||
:= b * a;
|
||||
|
||||
function operator+(a: set of integer; b: set of int64): set of int64; extensionmethod;
|
||||
begin
|
||||
Result += a; Result += b
|
||||
Result.hs.UnionWith(b);
|
||||
Result.hs.UnionWith(a.Select(x -> int64(x)));
|
||||
end;
|
||||
|
||||
function operator+(a: NewSet<integer>; b: NewSet<int64>): NewSet<int64>; extensionmethod;
|
||||
function operator+(a: set of int64; b: set of integer): set of int64; extensionmethod
|
||||
:= b * a;
|
||||
|
||||
// set + array
|
||||
function operator+(a: array of integer; b: set of byte): set of integer; extensionmethod;
|
||||
begin
|
||||
Result += a; Result += b
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.UnionWith(b.Select(x -> integer(x)));
|
||||
end;
|
||||
|
||||
function operator+(a: NewSet<int64>; b: NewSet<integer>): NewSet<int64>; extensionmethod;
|
||||
function operator+(a: set of byte; b: array of integer): set of integer; extensionmethod
|
||||
:= b * a;
|
||||
|
||||
function operator+(a: array of integer; b: set of int64): set of int64; extensionmethod;
|
||||
begin
|
||||
Result += a; Result += b
|
||||
Result.hs.UnionWith(b);
|
||||
Result.hs.UnionWith(a.Select(x -> int64(x)));
|
||||
end;
|
||||
|
||||
//-----
|
||||
function operator-(a: NewSet<integer>; b: NewSet<byte>): NewSet<integer>; extensionmethod;
|
||||
function operator+(a: set of int64; b: array of integer): set of int64; extensionmethod
|
||||
:= b * a;
|
||||
|
||||
function operator+(a: set of integer; b: array of integer): set of integer; extensionmethod;
|
||||
begin
|
||||
Result += a; Result -= b
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.UnionWith(b);
|
||||
end;
|
||||
|
||||
function operator-(a: NewSet<byte>; b: NewSet<integer>): NewSet<integer>; extensionmethod;
|
||||
function operator+(a: array of integer; b: set of integer): set of integer; extensionmethod
|
||||
:= b * a;
|
||||
|
||||
|
||||
// operator- sets
|
||||
function operator-(a: set of integer; b: set of byte): set of integer; extensionmethod;
|
||||
begin
|
||||
Result += a; Result -= b
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.ExceptWith(b.Select(x -> integer(x)));
|
||||
end;
|
||||
|
||||
function operator-(a: NewSet<integer>; b: NewSet<int64>): NewSet<int64>; extensionmethod;
|
||||
function operator-(a: set of byte; b: set of integer): set of integer; extensionmethod;
|
||||
begin
|
||||
Result += a; Result -= b
|
||||
Result.hs.UnionWith(a.Select(x -> integer(x)));
|
||||
Result.hs.ExceptWith(b);
|
||||
end;
|
||||
|
||||
function operator-(a: NewSet<int64>; b: NewSet<integer>): NewSet<int64>; extensionmethod;
|
||||
function operator-(a: set of integer; b: set of int64): set of int64; extensionmethod;
|
||||
begin
|
||||
Result += a; Result -= b
|
||||
Result.hs.UnionWith(a.Select(x -> int64(x)));
|
||||
Result.hs.ExceptWith(b);
|
||||
end;
|
||||
|
||||
// и для массивов столько же
|
||||
(*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;
|
||||
*)
|
||||
//function operator=(a: NewSet<int64>; b: NewSet<byte>); extensionmethod := a._hs.SetEquals(NSToInts64(b));
|
||||
//function operator=(a: NewSet<byte>; b: NewSet<int64>): boolean; extensionmethod := a = b;
|
||||
function operator-(a: set of int64; b: set of integer): set of int64; extensionmethod;
|
||||
begin
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.ExceptWith(b.Select(x -> int64(x)));
|
||||
end;
|
||||
|
||||
// Следующие функции предназначены для сравнения массива целых со множеством.
|
||||
// Массив должен интерпретироваться как множество
|
||||
// Не пойму - что использовать - эту строку или предыдущие. Все типы массивов сравнивать с NewSet<integer>
|
||||
// или наоборот все типы множеств - с array of integer
|
||||
function operator=(a: NewSet<byte>; b: array of integer): boolean; extensionmethod := NSToInts(a).ToHashSet.SetEquals(b);
|
||||
// set - array
|
||||
function operator-(a: array of integer; b: set of byte): set of integer; extensionmethod;
|
||||
begin
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.ExceptWith(b.Select(x -> integer(x)));
|
||||
end;
|
||||
|
||||
function operator-(a: set of byte; b: array of integer): set of integer; extensionmethod;
|
||||
begin
|
||||
Result.hs.UnionWith(a.Select(x -> integer(x)));
|
||||
Result.hs.ExceptWith(b);
|
||||
end;
|
||||
|
||||
function operator-(a: array of integer; b: set of int64): set of int64; extensionmethod;
|
||||
begin
|
||||
Result.hs.UnionWith(a.Select(x -> int64(x)));
|
||||
Result.hs.ExceptWith(b);
|
||||
end;
|
||||
|
||||
function operator-(a: set of int64; b: array of integer): set of int64; extensionmethod;
|
||||
begin
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.ExceptWith(b.Select(x -> int64(x)));
|
||||
end;
|
||||
|
||||
function operator-(a: array of integer; b: set of integer): set of integer; extensionmethod;
|
||||
begin
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.ExceptWith(b);
|
||||
end;
|
||||
|
||||
function operator-(a: set of integer; b: array of integer): set of integer; extensionmethod;
|
||||
begin
|
||||
Result.hs.UnionWith(a);
|
||||
Result.hs.ExceptWith(b);
|
||||
end;
|
||||
|
||||
|
||||
var __initialized: boolean;
|
||||
|
|
|
|||
|
|
@ -504,10 +504,6 @@ type
|
|||
end;
|
||||
function GetEnumerator: IEnumerator<T> := hs.GetEnumerator;
|
||||
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);
|
||||
end;
|
||||
/// Преобразовать к строковому представлению
|
||||
function ToString: string; override;
|
||||
/// Количество элементов в множестве
|
||||
|
|
@ -555,6 +551,10 @@ type
|
|||
begin
|
||||
Result.hs.UnionWith(ns);
|
||||
end;
|
||||
static function operator implicit(a: array of T): NewSet<T>;
|
||||
begin
|
||||
Result._hs := new HashSet<T>(a);
|
||||
end;
|
||||
|
||||
static function operator implicit(ns: NewSetEmpty): NewSet<T>; begin end;
|
||||
static function operator:=(var s: NewSet<T>; st: NewSet<T>): NewSet<T>; // Эту функцию обязательно здесь определять
|
||||
|
|
@ -2699,7 +2699,7 @@ function HSetInt(params a: array of integer): HashSet<integer>;
|
|||
/// Возвращает множество на базе хеш таблицы, заполненное строковыми значениями
|
||||
function HSetStr(params a: array of string): HashSet<string>;
|
||||
/// Возвращает множество, заполненное указанными значениями
|
||||
function SetOf<T>(params a: array of T): HashSet<T>;
|
||||
function SetOf<T>(params a: array of T): NewSet<T>;
|
||||
|
||||
|
||||
/// Возвращает множество на базе бинарного дерева поиска, заполненное указанными значениями
|
||||
|
|
@ -6097,8 +6097,10 @@ function HSet(a: IntRange): HashSet<integer> := new HashSet<integer>(a);
|
|||
|
||||
function HSet(a: CharRange): HashSet<char> := new HashSet<char>(a);
|
||||
|
||||
function SetOf<T>(params a: array of T): HashSet<T> := new HashSet<T>(a);
|
||||
|
||||
function SetOf<T>(params a: array of T): NewSet<T>;
|
||||
begin
|
||||
Result._hs := new HashSet<T>(a);
|
||||
end;
|
||||
|
||||
function Dict<TKey, TVal>(params pairs: array of KeyValuePair<TKey, TVal>): Dictionary<TKey, TVal>;
|
||||
begin
|
||||
|
|
@ -11188,9 +11190,9 @@ begin
|
|||
end;
|
||||
|
||||
/// Возвращает множество по данной последовательности
|
||||
function ToSet<T>(Self: sequence of T): HashSet<T>; extensionmethod;
|
||||
function ToSet<T>(Self: sequence of T): NewSet<T>; extensionmethod;
|
||||
begin
|
||||
Result := new HashSet<T>(Self);
|
||||
Result._hs := new HashSet<T>(Self);
|
||||
end;
|
||||
|
||||
/// Возвращает множество SortedSet по данной последовательности
|
||||
|
|
@ -15067,14 +15069,6 @@ function operator><T1,T2,T3,T4,T5,T6,T7>(Self: (T1, T2, T3, T4,T5,T6,T7); v: (T1
|
|||
///--
|
||||
function operator>=<T1,T2,T3,T4,T5,T6,T7>(Self: (T1, T2, T3, T4,T5,T6,T7); v: (T1, T2, T3, T4,T5,T6,T7)); extensionmethod := CompareToTup5(Self, v) >= 0;
|
||||
|
||||
{
|
||||
///--
|
||||
function operator implicit<T>(a: array of T): set of T; extensionmethod;
|
||||
begin
|
||||
foreach var x in a do
|
||||
Include(Result,x);
|
||||
end;
|
||||
}
|
||||
|
||||
{// Определяет, есть ли указанный элемент в массиве
|
||||
function Contains<T>(self: array of T; x: T): boolean; extensionmethod;
|
||||
|
|
@ -15482,60 +15476,7 @@ begin
|
|||
end
|
||||
end;
|
||||
|
||||
function operator implicit(a: set of integer): set of BigInteger; extensionmethod;
|
||||
begin
|
||||
foreach var x in a do
|
||||
Result.Add(x);
|
||||
end;
|
||||
|
||||
//------------------
|
||||
function operator implicit(n: array of integer): set of byte; extensionmethod;
|
||||
begin
|
||||
foreach var x in n do
|
||||
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);
|
||||
end;
|
||||
|
||||
function operator implicit(n: array of integer): set of smallint; extensionmethod;
|
||||
begin
|
||||
foreach var x in n do
|
||||
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);
|
||||
end;
|
||||
|
||||
function operator implicit(n: array of integer): set of longword; extensionmethod;
|
||||
begin
|
||||
foreach var x in n do
|
||||
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);
|
||||
end;
|
||||
|
||||
function operator implicit(a: array of integer): set of uint64; extensionmethod;
|
||||
begin
|
||||
foreach var x in a do
|
||||
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);
|
||||
end;
|
||||
|
||||
//function operator implicit<T>(ns: NewSetEmpty): NewSet<T>; extensionmethod; begin end;
|
||||
|
||||
|
|
@ -15824,7 +15765,8 @@ begin
|
|||
end;
|
||||
try
|
||||
if (System.Environment.OSVersion.Version.Major >= 6) and (System.Environment.OSVersion.Version.Minor >= 2) then
|
||||
System.Console.OutputEncoding := Encoding.UTF8;
|
||||
System.Console.OutputEncoding := new System.Text.UTF8Encoding(false);
|
||||
//System.Console.OutputEncoding := Encoding.UTF8;
|
||||
except
|
||||
end;
|
||||
rnd := new System.Random;
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in a new issue