mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-25 11:08:02 +02:00
Implement IRefEnumerator<T> in HashSet Enumerator
This commit is contained in:
parent
78549fa364
commit
c64dc37d61
1 changed files with 22 additions and 7 deletions
|
@ -1217,14 +1217,14 @@ namespace System.Collections
|
||||||
public int32 mNext; // Index of next entry, -1 if last
|
public int32 mNext; // Index of next entry, -1 if last
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct Enumerator : IEnumerator<T>
|
public struct Enumerator : IRefEnumerator<T*>, IEnumerator<T>
|
||||||
{
|
{
|
||||||
private HashSet<T> mSet;
|
private HashSet<T> mSet;
|
||||||
private int_cosize mIndex;
|
private int_cosize mIndex;
|
||||||
#if VERSION_HASHSET
|
#if VERSION_HASHSET
|
||||||
private int32 mVersion;
|
private int32 mVersion;
|
||||||
#endif
|
#endif
|
||||||
private T mCurrent;
|
private T* mCurrent;
|
||||||
|
|
||||||
public this(HashSet<T> set)
|
public this(HashSet<T> set)
|
||||||
{
|
{
|
||||||
|
@ -1233,7 +1233,7 @@ namespace System.Collections
|
||||||
#if VERSION_HASHSET
|
#if VERSION_HASHSET
|
||||||
mVersion = set.mVersion;
|
mVersion = set.mVersion;
|
||||||
#endif
|
#endif
|
||||||
mCurrent = default;
|
mCurrent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VERSION_HASHSET
|
#if VERSION_HASHSET
|
||||||
|
@ -1257,14 +1257,14 @@ namespace System.Collections
|
||||||
{
|
{
|
||||||
if (mSet.mSlots[mIndex].mHashCode >= 0)
|
if (mSet.mSlots[mIndex].mHashCode >= 0)
|
||||||
{
|
{
|
||||||
mCurrent = mSet.mSlots[mIndex].mValue;
|
mCurrent = &mSet.mSlots[mIndex].mValue;
|
||||||
mIndex++;
|
mIndex++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
mIndex++;
|
mIndex++;
|
||||||
}
|
}
|
||||||
mIndex = mSet.mLastIndex + 1;
|
mIndex = mSet.mLastIndex + 1;
|
||||||
mCurrent = default(T);
|
mCurrent = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1272,7 +1272,15 @@ namespace System.Collections
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return mCurrent;
|
return *mCurrent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ref T CurrentRef
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ref *mCurrent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1292,7 +1300,7 @@ namespace System.Collections
|
||||||
CheckVersion();
|
CheckVersion();
|
||||||
#endif
|
#endif
|
||||||
mIndex = 0;
|
mIndex = 0;
|
||||||
mCurrent = default(T);
|
mCurrent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result<T> GetNext() mut
|
public Result<T> GetNext() mut
|
||||||
|
@ -1301,6 +1309,13 @@ namespace System.Collections
|
||||||
return .Err;
|
return .Err;
|
||||||
return Current;
|
return Current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Result<T*> GetNextRef() mut
|
||||||
|
{
|
||||||
|
if (!MoveNext())
|
||||||
|
return .Err;
|
||||||
|
return &CurrentRef;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue