ObservableCollections icon indicating copy to clipboard operation
ObservableCollections copied to clipboard

fix ResizableArray

Open prozolic opened this issue 1 year ago • 0 comments

IndexOutOfRangeException was thrown in some cases when executing ObservableHashSet.AddRange.

static IEnumerable<int> Range(int count)
{
    foreach (var i in Enumerable.Range(0, count))
    {
        yield return i;
    }
}

var set = new ObservableHashSet<int>();
set.AddRange(Range(20));

The reason is that when ResizableArray<T>.EnsureCapacity is executed, the capacity of the new array equals the capacity of the old array. Therefore, I modified it to create a new array with twice the capacity of the old one.

prozolic avatar Jun 26 '24 15:06 prozolic