From bcaea74953c033afc5aa6a1d826439d6db9ee20d Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Thu, 21 Sep 2017 18:31:17 +0100 Subject: [PATCH] Added support to get the start of an extent from any item in them. --- Extents/ExtentsByte.cs | 14 ++++++++++++++ Extents/ExtentsInt.cs | 14 ++++++++++++++ Extents/ExtentsLong.cs | 14 ++++++++++++++ Extents/ExtentsSByte.cs | 14 ++++++++++++++ Extents/ExtentsShort.cs | 14 ++++++++++++++ Extents/ExtentsUInt.cs | 14 ++++++++++++++ Extents/ExtentsULong.cs | 14 ++++++++++++++ Extents/ExtentsUShort.cs | 14 ++++++++++++++ 8 files changed, 112 insertions(+) diff --git a/Extents/ExtentsByte.cs b/Extents/ExtentsByte.cs index 2e6717a9e..a4ac19149 100644 --- a/Extents/ExtentsByte.cs +++ b/Extents/ExtentsByte.cs @@ -201,5 +201,19 @@ namespace Extents { return backend.ToArray(); } + + public bool GetStart(byte item, out byte start) + { + start = 0; + foreach(Tuple extent in backend) + { + if(item >= extent.Item1 && item <= extent.Item2) + { + start = extent.Item1; + return true; + } + } + return false; + } } } diff --git a/Extents/ExtentsInt.cs b/Extents/ExtentsInt.cs index 91604f116..2b9d46fb9 100644 --- a/Extents/ExtentsInt.cs +++ b/Extents/ExtentsInt.cs @@ -201,5 +201,19 @@ namespace Extents { return backend.ToArray(); } + + public bool GetStart(int item, out int start) + { + start = 0; + foreach(Tuple extent in backend) + { + if(item >= extent.Item1 && item <= extent.Item2) + { + start = extent.Item1; + return true; + } + } + return false; + } } } diff --git a/Extents/ExtentsLong.cs b/Extents/ExtentsLong.cs index 11e1c7f03..eae4ca61e 100644 --- a/Extents/ExtentsLong.cs +++ b/Extents/ExtentsLong.cs @@ -201,5 +201,19 @@ namespace Extents { return backend.ToArray(); } + + public bool GetStart(long item, out long start) + { + start = 0; + foreach(Tuple extent in backend) + { + if(item >= extent.Item1 && item <= extent.Item2) + { + start = extent.Item1; + return true; + } + } + return false; + } } } diff --git a/Extents/ExtentsSByte.cs b/Extents/ExtentsSByte.cs index bfc07ac9e..25af736e7 100644 --- a/Extents/ExtentsSByte.cs +++ b/Extents/ExtentsSByte.cs @@ -201,5 +201,19 @@ namespace Extents { return backend.ToArray(); } + + public bool GetStart(sbyte item, out sbyte start) + { + start = 0; + foreach(Tuple extent in backend) + { + if(item >= extent.Item1 && item <= extent.Item2) + { + start = extent.Item1; + return true; + } + } + return false; + } } } diff --git a/Extents/ExtentsShort.cs b/Extents/ExtentsShort.cs index f508ace86..079c34642 100644 --- a/Extents/ExtentsShort.cs +++ b/Extents/ExtentsShort.cs @@ -201,5 +201,19 @@ namespace Extents { return backend.ToArray(); } + + public bool GetStart(short item, out short start) + { + start = 0; + foreach(Tuple extent in backend) + { + if(item >= extent.Item1 && item <= extent.Item2) + { + start = extent.Item1; + return true; + } + } + return false; + } } } diff --git a/Extents/ExtentsUInt.cs b/Extents/ExtentsUInt.cs index 3d0988da9..bd24b6db2 100644 --- a/Extents/ExtentsUInt.cs +++ b/Extents/ExtentsUInt.cs @@ -201,5 +201,19 @@ namespace Extents { return backend.ToArray(); } + + public bool GetStart(uint item, out uint start) + { + start = 0; + foreach(Tuple extent in backend) + { + if(item >= extent.Item1 && item <= extent.Item2) + { + start = extent.Item1; + return true; + } + } + return false; + } } } diff --git a/Extents/ExtentsULong.cs b/Extents/ExtentsULong.cs index c9f457060..fcb7a40bc 100644 --- a/Extents/ExtentsULong.cs +++ b/Extents/ExtentsULong.cs @@ -201,5 +201,19 @@ namespace Extents { return backend.ToArray(); } + + public bool GetStart(ulong item, out ulong start) + { + start = 0; + foreach(Tuple extent in backend) + { + if(item >= extent.Item1 && item <= extent.Item2) + { + start = extent.Item1; + return true; + } + } + return false; + } } } diff --git a/Extents/ExtentsUShort.cs b/Extents/ExtentsUShort.cs index 9f7da19bc..3e019e2ab 100644 --- a/Extents/ExtentsUShort.cs +++ b/Extents/ExtentsUShort.cs @@ -201,5 +201,19 @@ namespace Extents { return backend.ToArray(); } + + public bool GetStart(ushort item, out ushort start) + { + start = 0; + foreach(Tuple extent in backend) + { + if(item >= extent.Item1 && item <= extent.Item2) + { + start = extent.Item1; + return true; + } + } + return false; + } } }