namespace UglyToad.PdfPig.Core
{
using System.Collections.Generic;
using System.Linq;
///
/// This class will be used to signify a range. a(min) <= a* <= a(max)
///
public readonly struct PdfRange
{
private readonly IReadOnlyList rangeArray;
private readonly int startingIndex;
///
/// Constructor assumes a starting index of 0.
///
/// The array that describes the range.
public PdfRange(IEnumerable range)
: this(range, 0)
{
}
///
/// Constructor with an index into an array. Because some arrays specify
/// multiple ranges ie [0, 1, 0, 2, 2, 3]. It is convenient for this
/// class to take an index into an array. So if you want this range to
/// represent 0, 2 in the above example then you would say new PDRange(array, 1).
///
/// The array that describes the index
/// The range index into the array for the start of the range.
public PdfRange(IEnumerable range, int index)
{
rangeArray = range.ToArray();
startingIndex = index;
}
///
/// The minimum value of the range.
///
public double Min => rangeArray[startingIndex * 2];
///
/// The maximum value of the range.
///
public double Max => rangeArray[startingIndex * 2 + 1];
}
}