Browse Source

Added overload for MemoryGroupView<T> in MemoryGroupEnumerator<T>

pull/1574/head
Sergio Pedri 6 years ago
parent
commit
b3db3382d5
  1. 14
      src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupEnumerator{T}.cs

14
src/ImageSharp/Memory/DiscontiguousBuffers/MemoryGroupEnumerator{T}.cs

@ -2,18 +2,20 @@
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
using System.ComponentModel;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.Memory.DiscontiguousBuffers namespace SixLabors.ImageSharp.Memory
{ {
/// <summary> /// <summary>
/// A value-type enumerator for <see cref="MemoryGroup{T}"/> instances. /// A value-type enumerator for <see cref="MemoryGroup{T}"/> instances.
/// </summary> /// </summary>
/// <typeparam name="T">The element type.</typeparam> /// <typeparam name="T">The element type.</typeparam>
[EditorBrowsable(EditorBrowsableState.Never)]
public ref struct MemoryGroupEnumerator<T> public ref struct MemoryGroupEnumerator<T>
where T : struct where T : struct
{ {
private readonly MemoryGroup<T> memoryGroup; private readonly IMemoryGroup<T> memoryGroup;
private readonly int count; private readonly int count;
private int index; private int index;
@ -33,6 +35,14 @@ namespace SixLabors.ImageSharp.Memory.DiscontiguousBuffers
this.index = -1; this.index = -1;
} }
[MethodImpl(InliningOptions.ShortMethod)]
internal MemoryGroupEnumerator(MemoryGroupView<T> memoryGroup)
{
this.memoryGroup = memoryGroup;
this.count = memoryGroup.Count;
this.index = -1;
}
/// <inheritdoc cref="System.Collections.Generic.IEnumerator{T}.Current"/> /// <inheritdoc cref="System.Collections.Generic.IEnumerator{T}.Current"/>
public Memory<T> Current public Memory<T> Current
{ {

Loading…
Cancel
Save