コード例 #1
0
            internal Enumerator(ImmutableTrieListBase <T> list, int startIndex = -1, int count = -1, bool reversed = false)
            {
                Requires.NotNull(list, nameof(list));
                Requires.Range(startIndex >= -1, nameof(startIndex));
                Requires.Range(count >= -1, nameof(count));
                Requires.Argument(reversed || count == -1 || (startIndex == -1 ? 0 : startIndex) + count <= list.Count, nameof(count), "The specified {0} and {1} do not produce a enumerable range.", nameof(startIndex), nameof(count));
                Requires.Argument(!reversed || count == -1 || (startIndex == -1 ? list.Count - 1 : startIndex) - count + 1 >= 0, nameof(count), "The specified {0} and {1} do not produce a enumerable range.", nameof(startIndex), nameof(count));

                _list = list;
                _enumeratingBuilderVersion = GetCurrentVersion(list);

                count       = count == -1 ? list.Count : count;
                _startIndex = startIndex >= 0 ? startIndex : (reversed ? list.Count - 1 : 0);
                _endIndex   = reversed ? _startIndex - count + 1 : _startIndex + count - 1;

                _runningIndex = reversed ? _startIndex + 1 : _startIndex - 1;

                _reversed = reversed;
                _disposed = false;
            }
コード例 #2
0
 private static int GetCurrentVersion(ImmutableTrieListBase <T> list) =>
 (list is Builder builder) ? builder.Version : -1;