EditorContentManager Part 2

This commit is contained in:
Simon Lübeß
2023-01-01 16:53:58 +01:00
parent c389a77274
commit 502cee47e7
3 changed files with 33 additions and 74 deletions
@@ -1,5 +1,3 @@
// https://github.com/Moneyl/Beef.Linq/blob/master/src/src/Enumerable.bf
using System.Collections;
using System;
using internal System.Linq;
@@ -164,7 +162,7 @@ namespace System.Linq
}
public static bool Any<TCollection, TSource, TPredicate>(this TCollection items, TPredicate predicate)
where TCollection : concrete, IEnumerable<TSource>, class, new
where TCollection : concrete, IEnumerable<TSource>
where TPredicate : delegate bool(TSource)
{
for (var it in items)
@@ -557,24 +555,6 @@ namespace System.Linq
return false;
}
public static bool InternalFirst<TEnum, TSource, TPredicate>(TEnum items, out TSource val, TPredicate predicate)
where TEnum : concrete, IEnumerator<TSource>
where TPredicate : delegate bool(TSource)
{
val = default;
using (var iterator = Iterator.Wrap(items))
{
var enumerator = iterator.mEnum;
if (enumerator.GetNext() case .Ok(out val))
{
if (predicate(val))
return true;
}
}
return false;
}
public static TSource First<TCollection, TSource>(this TCollection items)
where TCollection : concrete, IEnumerable<TSource>
{
@@ -582,15 +562,6 @@ namespace System.Linq
return val;
Runtime.FatalError("Sequence contained no elements.");
}
public static TSource First<TCollection, TSource, TPredicate>(this TCollection items, TPredicate predicate)
where TCollection : concrete, IEnumerable<TSource>
where TPredicate : delegate bool(TSource)
{
if (InternalFirst<decltype(default(TCollection).GetEnumerator()), TSource, TPredicate>(items.GetEnumerator(), let val, predicate))
return val;
Runtime.FatalError("Sequence contained no elements.");
}
public static TSource First<TEnum, TSource>(this TEnum items)
where TEnum : concrete, IEnumerator<TSource>
@@ -600,15 +571,6 @@ namespace System.Linq
Runtime.FatalError("Sequence contained no elements.");
}
public static TSource First<TEnum, TSource, TPredicate>(this TEnum items, TPredicate predicate)
where TEnum : concrete, IEnumerator<TSource>
where TPredicate : delegate bool(TSource)
{
if (InternalFirst<TEnum, TSource, TPredicate>(items, let val, predicate))
return val;
Runtime.FatalError("Sequence contained no elements.");
}
public static TSource FirstOrDefault<TCollection, TSource>(this TCollection items)
where TCollection : concrete, IEnumerable<TSource>
{
@@ -618,24 +580,6 @@ namespace System.Linq
return default;
}
public static TSource FirstOrDefault<TCollection, TSource, TPredicate>(this TCollection items, TPredicate predicate)
where TCollection : concrete, IEnumerable<TSource>
where TPredicate : delegate bool(TSource)
{
if (InternalFirst<decltype(default(TCollection).GetEnumerator()), TSource, TPredicate>(items.GetEnumerator(), let val, predicate))
return val;
return default;
}
/*public static WhereEnumerable<TSource, decltype(default(TCollection).GetEnumerator()), TPredicate>
Where<TCollection, TSource, TPredicate>(this TCollection items, TPredicate predicate)
where TCollection : concrete, IEnumerable<TSource>
where TPredicate : delegate bool(TSource)
{
return .(items.GetEnumerator(), predicate);
}*/
public static TSource FirstOrDefault<TEnum, TSource>(this TEnum items)
where TEnum : concrete, IEnumerator<TSource>
{