diff --git a/BeefLibs/corlib/src/Collections/Dictionary.bf b/BeefLibs/corlib/src/Collections/Dictionary.bf index 32fca56a..9789c46d 100644 --- a/BeefLibs/corlib/src/Collections/Dictionary.bf +++ b/BeefLibs/corlib/src/Collections/Dictionary.bf @@ -267,7 +267,11 @@ namespace System.Collections } 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 c = EqualityComparer.Default; for (int i = 0; i < count; i++) { diff --git a/BeefLibs/corlib/src/Collections/List.bf b/BeefLibs/corlib/src/Collections/List.bf index 605cb723..90423812 100644 --- a/BeefLibs/corlib/src/Collections/List.bf +++ b/BeefLibs/corlib/src/Collections/List.bf @@ -930,6 +930,59 @@ namespace System.Collections } } + extension List 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 : List { IRawAllocator mAlloc; diff --git a/BeefLibs/corlib/src/Diagnostics/Check.bf b/BeefLibs/corlib/src/Diagnostics/Check.bf index 0b26b71c..b041f6fb 100644 --- a/BeefLibs/corlib/src/Diagnostics/Check.bf +++ b/BeefLibs/corlib/src/Diagnostics/Check.bf @@ -1,6 +1,6 @@ namespace System.Diagnostics { - class Check + static class Check { [Unchecked, SkipCall] diff --git a/BeefLibs/corlib/src/Diagnostics/Contracts/Contracts.bf b/BeefLibs/corlib/src/Diagnostics/Contracts/Contracts.bf index e14d5a0c..e5f7d80c 100644 --- a/BeefLibs/corlib/src/Diagnostics/Contracts/Contracts.bf +++ b/BeefLibs/corlib/src/Diagnostics/Contracts/Contracts.bf @@ -1,6 +1,6 @@ namespace System.Diagnostics.Contracts { - class Contract + static class Contract { public enum ContractFailureKind { diff --git a/BeefLibs/corlib/src/Diagnostics/Debug.bf b/BeefLibs/corlib/src/Diagnostics/Debug.bf index d4df7bd4..fe45865b 100644 --- a/BeefLibs/corlib/src/Diagnostics/Debug.bf +++ b/BeefLibs/corlib/src/Diagnostics/Debug.bf @@ -1,6 +1,6 @@ namespace System.Diagnostics { - class Debug + static class Debug { #if !DEBUG [SkipCall] diff --git a/BeefLibs/corlib/src/IO/File.bf b/BeefLibs/corlib/src/IO/File.bf index a3ae6cf2..06d6abd7 100644 --- a/BeefLibs/corlib/src/IO/File.bf +++ b/BeefLibs/corlib/src/IO/File.bf @@ -23,7 +23,7 @@ namespace System.IO case FileReadError(FileReadError); } - class File + static class File { public static Result ReadAll(StringView path, List outData) { diff --git a/BeefLibs/corlib/src/Runtime.bf b/BeefLibs/corlib/src/Runtime.bf index 96ae54fc..564b032c 100644 --- a/BeefLibs/corlib/src/Runtime.bf +++ b/BeefLibs/corlib/src/Runtime.bf @@ -6,7 +6,7 @@ using System.Threading; namespace System { [StaticInitPriority(100)] - class Runtime + static class Runtime { const int32 cVersion = 8; diff --git a/BeefLibs/corlib/src/System.bf b/BeefLibs/corlib/src/System.bf index def9c456..9289da0a 100644 --- a/BeefLibs/corlib/src/System.bf +++ b/BeefLibs/corlib/src/System.bf @@ -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) { delete val; diff --git a/BeefLibs/corlib/src/Text/UTF16.bf b/BeefLibs/corlib/src/Text/UTF16.bf index 4a4953f2..5ab1fc6d 100644 --- a/BeefLibs/corlib/src/Text/UTF16.bf +++ b/BeefLibs/corlib/src/Text/UTF16.bf @@ -1,7 +1,7 @@ using System.Diagnostics; namespace System.Text { - public class UTF16 + public static class UTF16 { public enum EncodeError { diff --git a/BeefLibs/corlib/src/Text/UTF8.bf b/BeefLibs/corlib/src/Text/UTF8.bf index 4df4c7f9..0dce24ae 100644 --- a/BeefLibs/corlib/src/Text/UTF8.bf +++ b/BeefLibs/corlib/src/Text/UTF8.bf @@ -1,7 +1,7 @@ using System.Diagnostics; namespace System.Text { - class UTF8 + static class UTF8 { public const int8[256] sTrailingBytesForUTF8 = .(