From 9cd2096783d6e63db340c2429cb30ffa471dda61 Mon Sep 17 00:00:00 2001 From: mlemanczyk Date: Sun, 10 Sep 2023 12:28:29 +0200 Subject: [PATCH] RecyclableLongList.Enumerator restored as the issue was somewhere else. --- Recyclable.Collections/RecyclableLongList.Enumerator.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Recyclable.Collections/RecyclableLongList.Enumerator.cs b/Recyclable.Collections/RecyclableLongList.Enumerator.cs index 6fb02cc..353f2d3 100644 --- a/Recyclable.Collections/RecyclableLongList.Enumerator.cs +++ b/Recyclable.Collections/RecyclableLongList.Enumerator.cs @@ -26,7 +26,7 @@ namespace Recyclable.Collections { var list = _list; - if (_currentBlockIndex <= list._lastBlockWithData && _currentItemIndex <= (_currentBlockIndex == list._lastBlockWithData && list._nextItemIndex > 0 ? list._nextItemIndex - 1: list._blockSizeMinus1)) + if (_currentBlockIndex < list._lastBlockWithData) { _current = list._memoryBlocks[_currentBlockIndex][_currentItemIndex]; if (_currentItemIndex + 1 < list._blockSize) @@ -41,7 +41,14 @@ namespace Recyclable.Collections return true; } + // Move to the next item if we're within block boundaries, otherwise report end of collection. + if (list._longCount > 0 && _currentItemIndex < (list._nextItemIndex > 0 ? list._nextItemIndex : list._blockSize)) + { + _current = list._memoryBlocks[_currentBlockIndex][_currentItemIndex]; + _currentItemIndex++; + return true; + } return false; }