mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-20 08:58:00 +02:00
Collapsible regions (aka outlining aka code folding)
This commit is contained in:
parent
3dd4212ccd
commit
90735e3bf8
21 changed files with 2518 additions and 277 deletions
|
@ -822,6 +822,20 @@ namespace System.Collections
|
|||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetRef(TKey key, out TKey* matchKey, out TValue* value)
|
||||
{
|
||||
int_cosize i = (int_cosize)FindEntry(key);
|
||||
if (i >= 0)
|
||||
{
|
||||
matchKey = &mEntries[i].mKey;
|
||||
value = &mEntries[i].mValue;
|
||||
return true;
|
||||
}
|
||||
matchKey = null;
|
||||
value = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetAlt<TAltKey>(TAltKey key, out TKey matchKey, out TValue value) where TAltKey : IHashable where bool : operator TKey == TAltKey
|
||||
{
|
||||
int_cosize i = (int_cosize)FindEntryAlt(key);
|
||||
|
@ -836,6 +850,20 @@ namespace System.Collections
|
|||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetRefAlt<TAltKey>(TAltKey key, out TKey* matchKey, out TValue* value) where TAltKey : IHashable where bool : operator TKey == TAltKey
|
||||
{
|
||||
int_cosize i = (int_cosize)FindEntryAlt(key);
|
||||
if (i >= 0)
|
||||
{
|
||||
matchKey = &mEntries[i].mKey;
|
||||
value = &mEntries[i].mValue;
|
||||
return true;
|
||||
}
|
||||
matchKey = null;
|
||||
value = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public TValue GetValueOrDefault(TKey key)
|
||||
{
|
||||
int_cosize i = (int_cosize)FindEntry(key);
|
||||
|
@ -848,7 +876,7 @@ namespace System.Collections
|
|||
|
||||
public struct Enumerator : IEnumerator<KeyValuePair>, IRefEnumerator<KeyRefValuePair>
|
||||
{
|
||||
private Dictionary<TKey, TValue> mDictionary;
|
||||
private Dictionary<TKey, TValue> mDictionary;
|
||||
#if VERSION_DICTIONARY
|
||||
private int_cosize mVersion;
|
||||
#endif
|
||||
|
@ -1024,7 +1052,7 @@ namespace System.Collections
|
|||
private int_cosize mVersion;
|
||||
#endif
|
||||
private int_cosize mIndex;
|
||||
private TValue mCurrent;
|
||||
private TValue* mCurrent;
|
||||
|
||||
const int_cosize cDictEntry = 1;
|
||||
const int_cosize cKeyValuePair = 2;
|
||||
|
@ -1051,7 +1079,7 @@ namespace System.Collections
|
|||
{
|
||||
if (mDictionary.mEntries[mIndex].mHashCode >= 0)
|
||||
{
|
||||
mCurrent = mDictionary.mEntries[mIndex].mValue;
|
||||
mCurrent = &mDictionary.mEntries[mIndex].mValue;
|
||||
mIndex++;
|
||||
return true;
|
||||
}
|
||||
|
@ -1065,12 +1093,12 @@ namespace System.Collections
|
|||
|
||||
public TValue Current
|
||||
{
|
||||
get { return mCurrent; }
|
||||
get { return *mCurrent; }
|
||||
}
|
||||
|
||||
public ref TValue CurrentRef
|
||||
{
|
||||
get mut { return ref mCurrent; }
|
||||
get mut { return ref *mCurrent; }
|
||||
}
|
||||
|
||||
public ref TKey Key
|
||||
|
@ -1128,7 +1156,7 @@ namespace System.Collections
|
|||
}
|
||||
}
|
||||
|
||||
public struct KeyEnumerator : IEnumerator<TKey>, IResettable
|
||||
public struct KeyEnumerator : IEnumerator<TKey>, IRefEnumerator<TKey*>, IResettable
|
||||
{
|
||||
private Dictionary<TKey, TValue> mDictionary;
|
||||
#if VERSION_DICTIONARY
|
||||
|
@ -1187,6 +1215,11 @@ namespace System.Collections
|
|||
get { return *mCurrent; }
|
||||
}
|
||||
|
||||
public ref TKey CurrentRef
|
||||
{
|
||||
get { return ref *mCurrent; }
|
||||
}
|
||||
|
||||
public ref TValue Value
|
||||
{
|
||||
get
|
||||
|
@ -1224,6 +1257,13 @@ namespace System.Collections
|
|||
return .Err;
|
||||
return Current;
|
||||
}
|
||||
|
||||
public Result<TKey*> GetNextRef() mut
|
||||
{
|
||||
if (!MoveNext())
|
||||
return .Err;
|
||||
return &CurrentRef;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -536,6 +536,15 @@ namespace System.Collections
|
|||
EnsureCapacity(size, true);
|
||||
}
|
||||
|
||||
public void Resize(int size)
|
||||
{
|
||||
EnsureCapacity(size, true);
|
||||
int addSize = size - mSize;
|
||||
if (addSize > 0)
|
||||
Internal.MemSet(Ptr + mSize, 0, addSize * alignof(T));
|
||||
mSize = (.)size;
|
||||
}
|
||||
|
||||
public Enumerator GetEnumerator()
|
||||
{
|
||||
return Enumerator(this);
|
||||
|
@ -716,6 +725,13 @@ namespace System.Collections
|
|||
sorter.[Friend]Sort(0, mSize);
|
||||
}
|
||||
|
||||
public void Sort(Comparison<T> comp, int index, int count)
|
||||
{
|
||||
Debug.Assert((uint)index + (uint)count <= (uint)mSize);
|
||||
var sorter = Sorter<T, void>(mItems, null, mSize, comp);
|
||||
sorter.[Friend]Sort(index, count);
|
||||
}
|
||||
|
||||
public int RemoveAll(Predicate<T> match)
|
||||
{
|
||||
int_cosize freeIndex = 0; // the first free slot in items array
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue