NSToBytes переделал с исключением
This commit is contained in:
parent
2bacdc8c28
commit
d268d4f83b
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
|||
public const string Major = "3";
|
||||
public const string Minor = "10";
|
||||
public const string Build = "0";
|
||||
public const string Revision = "3574";
|
||||
public const string Revision = "3577";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%COREVERSION%=0
|
||||
%REVISION%=3574
|
||||
%MINOR%=10
|
||||
%REVISION%=3577
|
||||
%COREVERSION%=0
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
3.10.0.3574
|
||||
3.10.0.3577
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.10.0.3574'
|
||||
!define VERSION '3.10.0.3577'
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ const
|
|||
PARAMETER_TO_OUT_OF_RANGE = 'Параметр to за пределами диапазона!!The to parameter out of bounds';
|
||||
SLICE_SIZE_AND_RIGHT_VALUE_SIZE_MUST_BE_EQUAL = 'Размеры среза и присваиваемого выражения должны быть равны!!Slice size and assigned expression size must be equal';
|
||||
OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT = 'Выход за границы типа множества!!Out of type range in set assignment';
|
||||
OUT_OF_TYPE_RANGE_IN_SET_OPERATION = 'Выход за границы типа множества!!Out of type range in set operation';
|
||||
|
||||
|
||||
//{{{doc: Начало секции расширений строк для срезов }}}
|
||||
|
|
@ -528,8 +529,25 @@ function NSToInts(ns: NewSet<word>) := ns._hs.Select(x -> integer(x));
|
|||
//function NSToInts(ns: NewSet<int64>) := ns._hs.Select(x -> integer(x));
|
||||
function NSToInts64(ns: NewSet<byte>) := ns._hs.Select(x -> int64(x));
|
||||
function NSToInts64(ns: NewSet<integer>) := ns._hs.Select(x -> int64(x));
|
||||
function NSToBytes(ns: NewSet<integer>) := ns._hs.Select(x -> byte(x));
|
||||
function NSToBytes(ns: NewSet<int64>) := ns._hs.Select(x -> byte(x));
|
||||
function NSToBytes(ns: NewSet<integer>): sequence of byte;
|
||||
begin
|
||||
var res := new List<byte>;
|
||||
foreach var x in ns._hs do
|
||||
if (x >= byte.MinValue) and (x <= byte.MaxValue) then
|
||||
res.Add(x)
|
||||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_OPERATION));
|
||||
Result := res;
|
||||
end;
|
||||
|
||||
function NSToBytes(ns: NewSet<int64>): sequence of byte;
|
||||
begin
|
||||
var res := new List<byte>;
|
||||
foreach var x in ns._hs do
|
||||
if (x >= byte.MinValue) and (x <= byte.MaxValue) then
|
||||
res.Add(x)
|
||||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_OPERATION));
|
||||
Result := res;
|
||||
end;
|
||||
|
||||
// Надо set of integer со всеми
|
||||
function operator=(a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a.hs.SetEquals(NSToInts(b));
|
||||
|
|
@ -613,7 +631,13 @@ procedure operator*=(var a: NewSet<int64>; b: NewSet<integer>); extensionmethod
|
|||
|
||||
//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 := a.hs.UnionWith(NSToBytes(b));
|
||||
procedure operator+=(a: NewSet<byte>; b: NewSet<integer>); extensionmethod;
|
||||
begin
|
||||
var x := a.hs;
|
||||
var bt := NSToBytes(b);
|
||||
a.hs.UnionWith(bt);
|
||||
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));
|
||||
|
|
|
|||
|
|
@ -485,7 +485,7 @@ type
|
|||
type
|
||||
NewSetEmpty = class;
|
||||
|
||||
/// Тип нового встроенного множества
|
||||
/// Тип встроенного множества
|
||||
NewSet<T> = record(IEnumerable<T>)
|
||||
private
|
||||
public
|
||||
|
|
@ -508,14 +508,21 @@ type
|
|||
begin
|
||||
Result._hs := new HashSet<T>(a);
|
||||
end;
|
||||
/// Преобразовать к строковому представлению
|
||||
function ToString: string; override;
|
||||
/// Количество элементов в множестве
|
||||
function Count: integer := hs.Count;
|
||||
/// Создать копию множества
|
||||
function Clone: NewSet<T>; begin Result.hs.UnionWith(hs) end;
|
||||
/// Добавить элемент в множество
|
||||
function Add(elem: T): boolean := hs.Add(elem);
|
||||
/// Добавить набор элементов в множество. Вернуть True если элемент был добавлен
|
||||
procedure AddRange(elems: sequence of T) := hs.UnionWith(elems);
|
||||
/// Удалить элемент из множества. Вернуть True если элемент был удален
|
||||
function Remove(elem: T): boolean := hs.Remove(elem);
|
||||
static procedure operator +=(Self: NewSet<T>; elem: T) := Self.hs.Add(elem);
|
||||
static procedure operator -=(Self: NewSet<T>; elem: T) := Self.hs.Remove(elem);
|
||||
/// Содержится ли элемент во множестве
|
||||
function Contains(elem: T): boolean := hs.Contains(elem);
|
||||
static function operator in(elem: T; Self: NewSet<T>): boolean;
|
||||
begin
|
||||
|
|
@ -534,7 +541,7 @@ type
|
|||
end;
|
||||
static function operator-(first, second: NewSet<T>): NewSet<T>;
|
||||
begin
|
||||
Result.hs.UnionWith(first); Result.hs.ExceptWith(second);
|
||||
Result.hs.UnionWith(first); Result._hs.ExceptWith(second);
|
||||
end;
|
||||
static function operator=(first, second: NewSet<T>) := first.hs.SetEquals(second.hs);
|
||||
static function operator<>(first, second: NewSet<T>) := not (first = second);
|
||||
|
|
@ -4809,6 +4816,13 @@ begin
|
|||
exit;
|
||||
end;
|
||||
|
||||
if t.FullName.StartsWith('PABCSystem.NewSet`1') then
|
||||
begin
|
||||
res.Write('set of ');
|
||||
TypeToTypeNameHelper(t.GetGenericArguments.Single, res);
|
||||
exit;
|
||||
end;
|
||||
|
||||
if t.GetInterfaces.Append(t).Contains(typeof(System.Collections.IEnumerable)) then
|
||||
begin
|
||||
var typed := t.GetInterfaces.Append(t).FirstOrDefault(intr->intr.IsGenericType and (intr.GetGenericTypeDefinition=typeof(IEnumerable<>)));
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ const
|
|||
PARAMETER_TO_OUT_OF_RANGE = 'Параметр to за пределами диапазона!!The to parameter out of bounds';
|
||||
SLICE_SIZE_AND_RIGHT_VALUE_SIZE_MUST_BE_EQUAL = 'Размеры среза и присваиваемого выражения должны быть равны!!Slice size and assigned expression size must be equal';
|
||||
OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT = 'Выход за границы типа множества!!Out of type range in set assignment';
|
||||
OUT_OF_TYPE_RANGE_IN_SET_OPERATION = 'Выход за границы типа множества!!Out of type range in set operation';
|
||||
|
||||
|
||||
//{{{doc: Начало секции расширений строк для срезов }}}
|
||||
|
|
@ -528,8 +529,25 @@ function NSToInts(ns: NewSet<word>) := ns._hs.Select(x -> integer(x));
|
|||
//function NSToInts(ns: NewSet<int64>) := ns._hs.Select(x -> integer(x));
|
||||
function NSToInts64(ns: NewSet<byte>) := ns._hs.Select(x -> int64(x));
|
||||
function NSToInts64(ns: NewSet<integer>) := ns._hs.Select(x -> int64(x));
|
||||
function NSToBytes(ns: NewSet<integer>) := ns._hs.Select(x -> byte(x));
|
||||
function NSToBytes(ns: NewSet<int64>) := ns._hs.Select(x -> byte(x));
|
||||
function NSToBytes(ns: NewSet<integer>): sequence of byte;
|
||||
begin
|
||||
var res := new List<byte>;
|
||||
foreach var x in ns._hs do
|
||||
if (x >= byte.MinValue) and (x <= byte.MaxValue) then
|
||||
res.Add(x)
|
||||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_OPERATION));
|
||||
Result := res;
|
||||
end;
|
||||
|
||||
function NSToBytes(ns: NewSet<int64>): sequence of byte;
|
||||
begin
|
||||
var res := new List<byte>;
|
||||
foreach var x in ns._hs do
|
||||
if (x >= byte.MinValue) and (x <= byte.MaxValue) then
|
||||
res.Add(x)
|
||||
else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_OPERATION));
|
||||
Result := res;
|
||||
end;
|
||||
|
||||
// Надо set of integer со всеми
|
||||
function operator=(a: NewSet<integer>; b: NewSet<byte>); extensionmethod := a.hs.SetEquals(NSToInts(b));
|
||||
|
|
@ -613,7 +631,13 @@ procedure operator*=(var a: NewSet<int64>; b: NewSet<integer>); extensionmethod
|
|||
|
||||
//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 := a.hs.UnionWith(NSToBytes(b));
|
||||
procedure operator+=(a: NewSet<byte>; b: NewSet<integer>); extensionmethod;
|
||||
begin
|
||||
var x := a.hs;
|
||||
var bt := NSToBytes(b);
|
||||
a.hs.UnionWith(bt);
|
||||
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));
|
||||
|
|
|
|||
Loading…
Reference in a new issue