BlockUpdateEvent & UnblockUpdateEvent methods removed in favor for BeginUpdate & EndUpdate

This commit is contained in:
mlemanczyk committed 2023-01-03 01:00:39 +01:00
1 parent bf07e05488
commit 674aa00509
1 file changed
+6 -24
+6 -24
View File
@@ -13,19 +13,6 @@ namespace Recyclable.Collections
private long _capacity; private long _capacity;
protected uint _isUpdating; protected uint _isUpdating;
protected virtual void BlockUpdateEvent()
{
_isUpdating++;
}
protected virtual void UnblockUpdateEvent()
{
if (_isUpdating > 0)
{
_isUpdating--;
}
}
private static IEnumerable<T> EnumerateElements(List<T[]> arrays, int chunkSize, long totalCount) private static IEnumerable<T> EnumerateElements(List<T[]> arrays, int chunkSize, long totalCount)
{ {
long currentCount = 0; long currentCount = 0;
@@ -67,7 +54,7 @@ namespace Recyclable.Collections
public RecyclableList(IEnumerable<T> source, int blockSize = RecyclableDefaults.BlockSize) public RecyclableList(IEnumerable<T> source, int blockSize = RecyclableDefaults.BlockSize)
{ {
_blockSize = blockSize; _blockSize = blockSize;
BlockUpdateEvent(); BeginUpdate();
try try
{ {
foreach (var item in source) foreach (var item in source)
@@ -77,7 +64,7 @@ namespace Recyclable.Collections
} }
finally finally
{ {
UnblockUpdateEvent(); EndUpdate();
} }
} }
@@ -118,7 +105,7 @@ namespace Recyclable.Collections
var newIndex = LongCount; var newIndex = LongCount;
// We don't want this[newIndex] set to raise the update event, because // We don't want this[newIndex] set to raise the update event, because
// the count would be wrong. We need to increase it, first. // the count would be wrong. We need to increase it, first.
BlockUpdateEvent(); BeginUpdate();
try try
{ {
this[newIndex] = item; this[newIndex] = item;
@@ -126,18 +113,13 @@ namespace Recyclable.Collections
} }
finally finally
{ {
UnblockUpdateEvent(); EndUpdate();
}
if (!IsUpdating)
{
ListUpdated();
} }
} }
public void Clear() public void Clear()
{ {
BlockUpdateEvent(); BeginUpdate();
try try
{ {
for (var arrayIdx = 0; arrayIdx < _arrays.Count; arrayIdx++) for (var arrayIdx = 0; arrayIdx < _arrays.Count; arrayIdx++)
@@ -163,7 +145,7 @@ namespace Recyclable.Collections
} }
finally finally
{ {
UnblockUpdateEvent(); EndUpdate();
} }
} }
} }