mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-04 23:36:00 +02:00
Merge pull request #1013 from EinBurgbauer/corlib-additions
Corlib additions
This commit is contained in:
commit
b338c9fb9f
10 changed files with 85 additions and 8 deletions
|
@ -267,7 +267,11 @@ namespace System.Collections
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//TODO: IMPORTANT!
|
for (int_cosize i = 0; i < mCount; i++)
|
||||||
|
{
|
||||||
|
if (mEntries[i].mHashCode >= 0 && mEntries[i].mValue == value) return true;
|
||||||
|
}
|
||||||
|
//TODO: comparison
|
||||||
/*EqualityComparer<TValue> c = EqualityComparer<TValue>.Default;
|
/*EqualityComparer<TValue> c = EqualityComparer<TValue>.Default;
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -930,6 +930,59 @@ namespace System.Collections
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension List<T> where T : String
|
||||||
|
{
|
||||||
|
public bool Contains(T item, StringComparison comparison)
|
||||||
|
{
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < mSize; i++)
|
||||||
|
if (mItems[i] == null)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < mSize; i++)
|
||||||
|
if (mItems[i].Equals(item, comparison))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int IndexOf(T item, StringComparison comparison)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < mSize; i++)
|
||||||
|
if (mItems[i].Equals(item, comparison))
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int IndexOf(T item, int index, StringComparison comparison)
|
||||||
|
{
|
||||||
|
for (int i = index; i < mSize; i++)
|
||||||
|
if (mItems[i].Equals(item, comparison))
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int IndexOf(T item, int index, int count, StringComparison comparison)
|
||||||
|
{
|
||||||
|
for (int i = index; i < index + count; i++)
|
||||||
|
if (mItems[i].Equals(item, comparison))
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int LastIndexOf(T item, StringComparison comparison)
|
||||||
|
{
|
||||||
|
for (int i = mSize - 1; i >= 0; i--)
|
||||||
|
if (mItems[i].Equals(item, comparison))
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ListWithAlloc<T> : List<T>
|
class ListWithAlloc<T> : List<T>
|
||||||
{
|
{
|
||||||
IRawAllocator mAlloc;
|
IRawAllocator mAlloc;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace System.Diagnostics
|
namespace System.Diagnostics
|
||||||
{
|
{
|
||||||
class Check
|
static class Check
|
||||||
{
|
{
|
||||||
|
|
||||||
[Unchecked, SkipCall]
|
[Unchecked, SkipCall]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace System.Diagnostics.Contracts
|
namespace System.Diagnostics.Contracts
|
||||||
{
|
{
|
||||||
class Contract
|
static class Contract
|
||||||
{
|
{
|
||||||
public enum ContractFailureKind
|
public enum ContractFailureKind
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace System.Diagnostics
|
namespace System.Diagnostics
|
||||||
{
|
{
|
||||||
class Debug
|
static class Debug
|
||||||
{
|
{
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
[SkipCall]
|
[SkipCall]
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace System.IO
|
||||||
case FileReadError(FileReadError);
|
case FileReadError(FileReadError);
|
||||||
}
|
}
|
||||||
|
|
||||||
class File
|
static class File
|
||||||
{
|
{
|
||||||
public static Result<void, FileError> ReadAll(StringView path, List<uint8> outData)
|
public static Result<void, FileError> ReadAll(StringView path, List<uint8> outData)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,7 @@ using System.Threading;
|
||||||
namespace System
|
namespace System
|
||||||
{
|
{
|
||||||
[StaticInitPriority(100)]
|
[StaticInitPriority(100)]
|
||||||
class Runtime
|
static class Runtime
|
||||||
{
|
{
|
||||||
const int32 cVersion = 8;
|
const int32 cVersion = 8;
|
||||||
|
|
||||||
|
|
|
@ -227,6 +227,26 @@ static
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static mixin DeleteContainerAndDisposeItems(var container)
|
||||||
|
{
|
||||||
|
if (container != null)
|
||||||
|
{
|
||||||
|
for (var value in container)
|
||||||
|
value.Dispose();
|
||||||
|
delete container;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static mixin ClearAndDisposeItems(var container)
|
||||||
|
{
|
||||||
|
if (container != null)
|
||||||
|
{
|
||||||
|
for (var value in container)
|
||||||
|
value.Dispose();
|
||||||
|
container.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static mixin DeleteAndNullify(var val)
|
public static mixin DeleteAndNullify(var val)
|
||||||
{
|
{
|
||||||
delete val;
|
delete val;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
namespace System.Text
|
namespace System.Text
|
||||||
{
|
{
|
||||||
public class UTF16
|
public static class UTF16
|
||||||
{
|
{
|
||||||
public enum EncodeError
|
public enum EncodeError
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
namespace System.Text
|
namespace System.Text
|
||||||
{
|
{
|
||||||
class UTF8
|
static class UTF8
|
||||||
{
|
{
|
||||||
public const int8[256] sTrailingBytesForUTF8 =
|
public const int8[256] sTrailingBytesForUTF8 =
|
||||||
.(
|
.(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue