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 2e6717a..a4ac191 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 91604f1..2b9d46f 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 11e1c7f..eae4ca6 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 bfc07ac..25af736 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 f508ace..079c346 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 3d0988d..bd24b6d 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 c9f4570..fcb7a40 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 9f7da19..3e019e2 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; + } } }