Cleanup
This commit is contained in:
1 parent
a7317f5230
commit
273ef8a3b0
3 files changed
+2
-113
No files matched your search
@@ -1,90 +0,0 @@
|
|||||||
using System.Runtime.CompilerServices;
|
|
||||||
|
|
||||||
namespace Recyclable.Collections
|
|
||||||
{
|
|
||||||
public delegate void VersionChangedEventHandler();
|
|
||||||
|
|
||||||
public sealed class RecyclableCollectionVersion
|
|
||||||
{
|
|
||||||
//private ulong _enumeratorCount;
|
|
||||||
|
|
||||||
//private ulong _version;
|
|
||||||
//public ulong Version
|
|
||||||
//{
|
|
||||||
// get => _version;
|
|
||||||
|
|
||||||
// set
|
|
||||||
// {
|
|
||||||
// _version = value;
|
|
||||||
// _versionChanged?.Invoke(this, EventArgs.Empty);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//public uint Version { get; set; }
|
|
||||||
|
|
||||||
public bool IsVersioned;
|
|
||||||
|
|
||||||
private VersionChangedEventHandler? _versionChanged;
|
|
||||||
public event VersionChangedEventHandler VersionChanged
|
|
||||||
{
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
add
|
|
||||||
{
|
|
||||||
_versionChanged += value;
|
|
||||||
if (!IsVersioned)
|
|
||||||
{
|
|
||||||
IsVersioned = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
remove
|
|
||||||
{
|
|
||||||
_versionChanged -= value;
|
|
||||||
if (_versionChanged == null)
|
|
||||||
{
|
|
||||||
IsVersioned = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public void Inc()
|
|
||||||
{
|
|
||||||
if (IsVersioned)
|
|
||||||
{
|
|
||||||
_versionChanged!();
|
|
||||||
}
|
|
||||||
//_ = unchecked(Version++);
|
|
||||||
}
|
|
||||||
|
|
||||||
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
//public RecyclableCollectionVersion AddEnumerator()
|
|
||||||
//{
|
|
||||||
// if (unchecked(_enumeratorCount++) == 0)
|
|
||||||
// {
|
|
||||||
// IsVersioned = true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return this;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
//public void RemoveEnumerator()
|
|
||||||
//{
|
|
||||||
// if (unchecked(--_enumeratorCount) == 0)
|
|
||||||
// {
|
|
||||||
// IsVersioned = false;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public RecyclableCollectionVersion Reset()
|
|
||||||
{
|
|
||||||
IsVersioned = false;
|
|
||||||
//Version = 0;
|
|
||||||
//_enumeratorCount = 0;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using Recyclable.Collections.Pools;
|
using System.Buffers;
|
||||||
using System.Buffers;
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
|||||||
@@ -4,31 +4,11 @@ namespace Recyclable.Collections
|
|||||||
{
|
{
|
||||||
internal static class ThrowHelper
|
internal static class ThrowHelper
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// This is a helper method to throw <see cref="InvalidOperationException"/>, thrown when the collection was modified during enumeration.
|
|
||||||
/// </summary>
|
|
||||||
/// <exception cref="InvalidOperationException">Always</exception>
|
|
||||||
public static void ThrowListModifiedException()
|
|
||||||
{
|
|
||||||
Contract.EnsuresOnThrow<InvalidOperationException>(false);
|
|
||||||
throw new InvalidOperationException("Can't move to the next item, because the collection was modified. You must restart the enumeration by calling Reset(), if you want to enumerate the collection again");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This is a helper method to throw <see cref="InvalidOperationException"/> with the given message.
|
|
||||||
/// </summary>
|
|
||||||
/// <exception cref="InvalidOperationException">Always</exception>
|
|
||||||
public static void ThrowInvalidOperationException(in string message)
|
|
||||||
{
|
|
||||||
Contract.EnsuresOnThrow<InvalidOperationException>(false);
|
|
||||||
throw new InvalidOperationException(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is a helper method to throw <see cref="ArgumentOutOfRangeException"/> with the given message.
|
/// This is a helper method to throw <see cref="ArgumentOutOfRangeException"/> with the given message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="ArgumentOutOfRangeException">Always</exception>
|
/// <exception cref="ArgumentOutOfRangeException">Always</exception>
|
||||||
public static void ThrowArgumentOutOfRangeException(in string argumentName, in string message)
|
public static void ThrowArgumentOutOfRangeException(string argumentName, string message)
|
||||||
{
|
{
|
||||||
Contract.EnsuresOnThrow<ArgumentOutOfRangeException>(false);
|
Contract.EnsuresOnThrow<ArgumentOutOfRangeException>(false);
|
||||||
throw new ArgumentOutOfRangeException(argumentName, message);
|
throw new ArgumentOutOfRangeException(argumentName, message);
|
||||||
|
|||||||
Reference in new issue
Block a user