Annotate enumerators and extension helpers for versioned variants
This commit is contained in:
1 parent
1e64c71af3
commit
3d37c1391f
8 files changed
+51
-26
No files matched your search
@@ -6,9 +6,11 @@ namespace Recyclable.Collections
|
||||
{
|
||||
public partial class RecyclableList<T>
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct Enumerator : IEnumerator<T>
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
[VersionedCollectionsGenerator.CloneForVersioned]
|
||||
// TODO: confirm if enumerator should implement a versioned interface for generated types
|
||||
public struct Enumerator : IEnumerator<T>
|
||||
{
|
||||
private static readonly bool _isReferenceType = !typeof(T).IsValueType;
|
||||
|
||||
private int _currentItemIndex;
|
||||
|
||||
@@ -3,8 +3,9 @@ using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Recyclable.Collections
|
||||
{
|
||||
public static class RecyclableListExtensions
|
||||
{
|
||||
[VersionedCollectionsGenerator.GenerateVersioned]
|
||||
public static class RecyclableListExtensions
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static RecyclableList<T> ToRecyclableList<T>(this Array values) => new(values);
|
||||
|
||||
|
||||
@@ -6,11 +6,14 @@ namespace Recyclable.Collections
|
||||
{
|
||||
public partial class RecyclableList<T> : IRecyclableVersionedList<T>
|
||||
{
|
||||
VersionedEnumerator IRecyclableVersionedList<T>.GetEnumerator() => new(this);
|
||||
[VersionedCollectionsGenerator.CloneForVersioned]
|
||||
VersionedEnumerator IRecyclableVersionedList<T>.GetEnumerator() => new(this);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct VersionedEnumerator : IEnumerator<T>
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
[VersionedCollectionsGenerator.CloneForVersioned]
|
||||
// TODO: confirm if enumerator should implement a versioned interface for generated types
|
||||
public struct VersionedEnumerator : IEnumerator<T>
|
||||
{
|
||||
private int _currentItemIndex;
|
||||
private readonly ulong _enumeratorVersion;
|
||||
private readonly RecyclableList<T> _list;
|
||||
|
||||
@@ -363,14 +363,20 @@ namespace Recyclable.Collections
|
||||
#endif
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Enumerator GetEnumerator() => new(this);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VersionedCollectionsGenerator.CloneForVersioned]
|
||||
// TODO: review if returned enumerator type should change for versioned list
|
||||
public Enumerator GetEnumerator() => new(this);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
IEnumerator IEnumerable.GetEnumerator() => new Enumerator(this);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VersionedCollectionsGenerator.CloneForVersioned]
|
||||
// TODO: review if returned enumerator type should change for versioned list
|
||||
IEnumerator IEnumerable.GetEnumerator() => new Enumerator(this);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
IEnumerator<T> IEnumerable<T>.GetEnumerator() => new Enumerator(this);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VersionedCollectionsGenerator.CloneForVersioned]
|
||||
// TODO: review if returned enumerator type should change for versioned list
|
||||
IEnumerator<T> IEnumerable<T>.GetEnumerator() => new Enumerator(this);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
@@ -5,8 +5,10 @@ namespace Recyclable.Collections
|
||||
{
|
||||
public partial class RecyclableLongList<T>
|
||||
{
|
||||
public struct Enumerator : IEnumerator<T>
|
||||
{
|
||||
[VersionedCollectionsGenerator.CloneForVersioned]
|
||||
// TODO: confirm if enumerator should implement a versioned interface for generated types
|
||||
public struct Enumerator : IEnumerator<T>
|
||||
{
|
||||
#nullable disable
|
||||
private static readonly T _default = default;
|
||||
#nullable restore
|
||||
|
||||
@@ -3,8 +3,9 @@ using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Recyclable.Collections
|
||||
{
|
||||
public static class RecyclableLongListExtensions
|
||||
{
|
||||
[VersionedCollectionsGenerator.GenerateVersioned]
|
||||
public static class RecyclableLongListExtensions
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static RecyclableLongList<T> ToRecyclableLongList<T>(this Array values, int minBlockSize = RecyclableDefaults.BlockSize) => new(values, minBlockSize);
|
||||
|
||||
|
||||
@@ -5,11 +5,15 @@ namespace Recyclable.Collections
|
||||
{
|
||||
public partial class RecyclableLongList<T> : IRecyclableVersionedLongList<T>
|
||||
{
|
||||
public VersionedEnumerator GetVersionedEnumerator() => new(this);
|
||||
VersionedEnumerator IRecyclableVersionedLongList<T>.GetEnumerator() => new(this);
|
||||
[VersionedCollectionsGenerator.CloneForVersioned]
|
||||
public VersionedEnumerator GetVersionedEnumerator() => new(this);
|
||||
[VersionedCollectionsGenerator.CloneForVersioned]
|
||||
VersionedEnumerator IRecyclableVersionedLongList<T>.GetEnumerator() => new(this);
|
||||
|
||||
public struct VersionedEnumerator : IEnumerator<T>
|
||||
{
|
||||
[VersionedCollectionsGenerator.CloneForVersioned]
|
||||
// TODO: confirm if enumerator should implement a versioned interface for generated types
|
||||
public struct VersionedEnumerator : IEnumerator<T>
|
||||
{
|
||||
#nullable disable
|
||||
private static readonly T _default = default;
|
||||
#nullable restore
|
||||
|
||||
@@ -372,9 +372,15 @@ namespace Recyclable.Collections
|
||||
|
||||
public void CopyTo(T[] array, int arrayIndex) => Helpers.CopyTo(_memoryBlocks, 0, _blockSize, _longCount, array, arrayIndex);
|
||||
|
||||
public Enumerator GetEnumerator() => new(this);
|
||||
IEnumerator IEnumerable.GetEnumerator() => new Enumerator(this);
|
||||
IEnumerator<T> IEnumerable<T>.GetEnumerator() => new Enumerator(this);
|
||||
[VersionedCollectionsGenerator.CloneForVersioned]
|
||||
// TODO: review if returned enumerator type should change for versioned list
|
||||
public Enumerator GetEnumerator() => new(this);
|
||||
[VersionedCollectionsGenerator.CloneForVersioned]
|
||||
// TODO: review if returned enumerator type should change for versioned list
|
||||
IEnumerator IEnumerable.GetEnumerator() => new Enumerator(this);
|
||||
[VersionedCollectionsGenerator.CloneForVersioned]
|
||||
// TODO: review if returned enumerator type should change for versioned list
|
||||
IEnumerator<T> IEnumerable<T>.GetEnumerator() => new Enumerator(this);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public int IndexOf(T item)
|
||||
|
||||
Reference in new issue
Block a user