/// <summary> /// Initializes a new instance of the <see cref="ImmutableDictionary{TKey, TValue}.Enumerator"/> struct. /// </summary> /// <param name="root">The root.</param> /// <param name="builder">The builder, if applicable.</param> internal Enumerator(SortedInt32KeyNode<HashBucket> root, Builder? builder = null) { _builder = builder; _mapEnumerator = new SortedInt32KeyNode<HashBucket>.Enumerator(root); _bucketEnumerator = default(HashBucket.Enumerator); _enumeratingBuilderVersion = builder != null ? builder.Version : -1; }
/// <summary> /// Initializes a new instance of the <see cref="ImmutableDictionary<TKey, TValue>.Enumerator"/> struct. /// </summary> /// <param name="root">The root.</param> /// <param name="builder">The builder, if applicable.</param> internal Enumerator(ImmutableSortedDictionary <int, HashBucket> .Node root, Builder builder = null) { this.builder = builder; this.mapEnumerator = new ImmutableSortedDictionary <int, HashBucket> .Enumerator(root); this.bucketEnumerator = default(HashBucket.Enumerator); this.enumeratingBuilderVersion = builder != null ? builder.Version : -1; }
/// <summary> /// Sets the enumerator to its initial position, which is before the first element in the collection. /// </summary> /// <exception cref="T:System.InvalidOperationException">The collection was modified after the enumerator was created. </exception> public void Reset() { this.enumeratingBuilderVersion = builder != null ? builder.Version : -1; this.mapEnumerator.Reset(); // Reseting the bucket enumerator is pointless because we'll start on a new bucket later anyway. this.bucketEnumerator.Dispose(); this.bucketEnumerator = default(HashBucket.Enumerator); }
/// <summary> /// Advances the enumerator to the next element of the collection. /// </summary> /// <returns> /// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection. /// </returns> /// <exception cref="T:System.InvalidOperationException">The collection was modified after the enumerator was created. </exception> public bool MoveNext() { this.ThrowIfChanged(); if (this.bucketEnumerator.MoveNext()) { return(true); } if (this.mapEnumerator.MoveNext()) { this.bucketEnumerator = new HashBucket.Enumerator(this.mapEnumerator.Current.Value); return(this.bucketEnumerator.MoveNext()); } return(false); }
/// <summary> /// Advances the enumerator to the next element of the collection. /// </summary> /// <returns> /// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection. /// </returns> /// <exception cref="InvalidOperationException">The collection was modified after the enumerator was created. </exception> public bool MoveNext() { this.ThrowIfChanged(); if (_bucketEnumerator.MoveNext()) { return true; } if (_mapEnumerator.MoveNext()) { _bucketEnumerator = new HashBucket.Enumerator(_mapEnumerator.Current.Value); return _bucketEnumerator.MoveNext(); } return false; }