mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
REFACTOR: Final cleanup of DiscImageChef.Helpers.
This commit is contained in:
@@ -37,14 +37,14 @@ using System.Linq;
|
||||
namespace Extents
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements extents for <see cref="byte"/>
|
||||
/// Implements extents for <see cref="byte" />
|
||||
/// </summary>
|
||||
public class ExtentsByte
|
||||
{
|
||||
List<Tuple<byte, byte>> backend;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an empty list of extents
|
||||
/// Initialize an empty list of extents
|
||||
/// </summary>
|
||||
public ExtentsByte()
|
||||
{
|
||||
@@ -52,7 +52,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes extents with an specific list
|
||||
/// Initializes extents with an specific list
|
||||
/// </summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsByte(IEnumerable<Tuple<byte, byte>> list)
|
||||
@@ -61,12 +61,12 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a count of how many extents are stored
|
||||
/// Gets a count of how many extents are stored
|
||||
/// </summary>
|
||||
public int Count => backend.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(byte item)
|
||||
@@ -123,11 +123,14 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new extent
|
||||
/// Adds a new extent
|
||||
/// </summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">Last element of the extent or if <see cref="run"/> is <c>true</c> how many elements the extent runs for</param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
/// for
|
||||
/// </param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
|
||||
public void Add(byte start, byte end, bool run = false)
|
||||
{
|
||||
byte realEnd;
|
||||
@@ -139,7 +142,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// </summary>
|
||||
/// <param name="item">Item to seach for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
@@ -149,7 +152,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all extents from this instance
|
||||
/// Removes all extents from this instance
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
@@ -157,7 +160,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the extents in this instance
|
||||
/// Removes an item from the extents in this instance
|
||||
/// </summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
@@ -215,16 +218,17 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple"/> where T1 is first element of the extent and T2 is last element
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
|
||||
/// last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple"/></returns>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<byte, byte>[] ToArray()
|
||||
{
|
||||
return backend.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// </summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
@@ -232,7 +236,8 @@ namespace Extents
|
||||
public bool GetStart(byte item, out byte start)
|
||||
{
|
||||
start = 0;
|
||||
foreach(Tuple<byte, byte> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) {
|
||||
foreach(Tuple<byte, byte> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -37,14 +37,14 @@ using System.Linq;
|
||||
namespace Extents
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements extents for <see cref="int"/>
|
||||
/// Implements extents for <see cref="int" />
|
||||
/// </summary>
|
||||
public class ExtentsInt
|
||||
{
|
||||
List<Tuple<int, int>> backend;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an empty list of extents
|
||||
/// Initialize an empty list of extents
|
||||
/// </summary>
|
||||
public ExtentsInt()
|
||||
{
|
||||
@@ -52,7 +52,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes extents with an specific list
|
||||
/// Initializes extents with an specific list
|
||||
/// </summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsInt(IEnumerable<Tuple<int, int>> list)
|
||||
@@ -61,12 +61,12 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a count of how many extents are stored
|
||||
/// Gets a count of how many extents are stored
|
||||
/// </summary>
|
||||
public int Count => backend.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(int item)
|
||||
@@ -123,11 +123,14 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new extent
|
||||
/// Adds a new extent
|
||||
/// </summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">Last element of the extent or if <see cref="run"/> is <c>true</c> how many elements the extent runs for</param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
/// for
|
||||
/// </param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
|
||||
public void Add(int start, int end, bool run = false)
|
||||
{
|
||||
int realEnd;
|
||||
@@ -139,7 +142,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// </summary>
|
||||
/// <param name="item">Item to seach for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
@@ -149,7 +152,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all extents from this instance
|
||||
/// Removes all extents from this instance
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
@@ -157,7 +160,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the extents in this instance
|
||||
/// Removes an item from the extents in this instance
|
||||
/// </summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
@@ -215,16 +218,17 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple"/> where T1 is first element of the extent and T2 is last element
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
|
||||
/// last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple"/></returns>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<int, int>[] ToArray()
|
||||
{
|
||||
return backend.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// </summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
@@ -232,7 +236,8 @@ namespace Extents
|
||||
public bool GetStart(int item, out int start)
|
||||
{
|
||||
start = 0;
|
||||
foreach(Tuple<int, int> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) {
|
||||
foreach(Tuple<int, int> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -37,14 +37,14 @@ using System.Linq;
|
||||
namespace Extents
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements extents for <see cref="long"/>
|
||||
/// Implements extents for <see cref="long" />
|
||||
/// </summary>
|
||||
public class ExtentsLong
|
||||
{
|
||||
List<Tuple<long, long>> backend;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an empty list of extents
|
||||
/// Initialize an empty list of extents
|
||||
/// </summary>
|
||||
public ExtentsLong()
|
||||
{
|
||||
@@ -52,7 +52,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes extents with an specific list
|
||||
/// Initializes extents with an specific list
|
||||
/// </summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsLong(IEnumerable<Tuple<long, long>> list)
|
||||
@@ -61,12 +61,12 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a count of how many extents are stored
|
||||
/// Gets a count of how many extents are stored
|
||||
/// </summary>
|
||||
public int Count => backend.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(long item)
|
||||
@@ -123,11 +123,14 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new extent
|
||||
/// Adds a new extent
|
||||
/// </summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">Last element of the extent or if <see cref="run"/> is <c>true</c> how many elements the extent runs for</param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
/// for
|
||||
/// </param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
|
||||
public void Add(long start, long end, bool run = false)
|
||||
{
|
||||
long realEnd;
|
||||
@@ -139,7 +142,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// </summary>
|
||||
/// <param name="item">Item to seach for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
@@ -149,7 +152,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all extents from this instance
|
||||
/// Removes all extents from this instance
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
@@ -157,7 +160,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the extents in this instance
|
||||
/// Removes an item from the extents in this instance
|
||||
/// </summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
@@ -215,16 +218,17 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple"/> where T1 is first element of the extent and T2 is last element
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
|
||||
/// last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple"/></returns>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<long, long>[] ToArray()
|
||||
{
|
||||
return backend.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// </summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
@@ -232,7 +236,8 @@ namespace Extents
|
||||
public bool GetStart(long item, out long start)
|
||||
{
|
||||
start = 0;
|
||||
foreach(Tuple<long, long> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) {
|
||||
foreach(Tuple<long, long> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -37,14 +37,14 @@ using System.Linq;
|
||||
namespace Extents
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements extents for <see cref="sbyte"/>
|
||||
/// Implements extents for <see cref="sbyte" />
|
||||
/// </summary>
|
||||
public class ExtentsSByte
|
||||
{
|
||||
List<Tuple<sbyte, sbyte>> backend;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an empty list of extents
|
||||
/// Initialize an empty list of extents
|
||||
/// </summary>
|
||||
public ExtentsSByte()
|
||||
{
|
||||
@@ -52,7 +52,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes extents with an specific list
|
||||
/// Initializes extents with an specific list
|
||||
/// </summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsSByte(IEnumerable<Tuple<sbyte, sbyte>> list)
|
||||
@@ -61,12 +61,12 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a count of how many extents are stored
|
||||
/// Gets a count of how many extents are stored
|
||||
/// </summary>
|
||||
public int Count => backend.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(sbyte item)
|
||||
@@ -123,11 +123,14 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new extent
|
||||
/// Adds a new extent
|
||||
/// </summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">Last element of the extent or if <see cref="run"/> is <c>true</c> how many elements the extent runs for</param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
/// for
|
||||
/// </param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
|
||||
public void Add(sbyte start, sbyte end, bool run = false)
|
||||
{
|
||||
sbyte realEnd;
|
||||
@@ -139,7 +142,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// </summary>
|
||||
/// <param name="item">Item to seach for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
@@ -149,7 +152,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all extents from this instance
|
||||
/// Removes all extents from this instance
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
@@ -157,7 +160,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the extents in this instance
|
||||
/// Removes an item from the extents in this instance
|
||||
/// </summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
@@ -215,16 +218,17 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple"/> where T1 is first element of the extent and T2 is last element
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
|
||||
/// last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple"/></returns>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<sbyte, sbyte>[] ToArray()
|
||||
{
|
||||
return backend.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// </summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
@@ -232,7 +236,8 @@ namespace Extents
|
||||
public bool GetStart(sbyte item, out sbyte start)
|
||||
{
|
||||
start = 0;
|
||||
foreach(Tuple<sbyte, sbyte> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) {
|
||||
foreach(Tuple<sbyte, sbyte> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -37,14 +37,14 @@ using System.Linq;
|
||||
namespace Extents
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements extents for <see cref="short"/>
|
||||
/// Implements extents for <see cref="short" />
|
||||
/// </summary>
|
||||
public class ExtentsShort
|
||||
{
|
||||
List<Tuple<short, short>> backend;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an empty list of extents
|
||||
/// Initialize an empty list of extents
|
||||
/// </summary>
|
||||
public ExtentsShort()
|
||||
{
|
||||
@@ -52,7 +52,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes extents with an specific list
|
||||
/// Initializes extents with an specific list
|
||||
/// </summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsShort(IEnumerable<Tuple<short, short>> list)
|
||||
@@ -61,12 +61,12 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a count of how many extents are stored
|
||||
/// Gets a count of how many extents are stored
|
||||
/// </summary>
|
||||
public int Count => backend.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(short item)
|
||||
@@ -123,11 +123,14 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new extent
|
||||
/// Adds a new extent
|
||||
/// </summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">Last element of the extent or if <see cref="run"/> is <c>true</c> how many elements the extent runs for</param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
/// for
|
||||
/// </param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
|
||||
public void Add(short start, short end, bool run = false)
|
||||
{
|
||||
short realEnd;
|
||||
@@ -139,7 +142,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// </summary>
|
||||
/// <param name="item">Item to seach for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
@@ -149,7 +152,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all extents from this instance
|
||||
/// Removes all extents from this instance
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
@@ -157,7 +160,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the extents in this instance
|
||||
/// Removes an item from the extents in this instance
|
||||
/// </summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
@@ -215,16 +218,17 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple"/> where T1 is first element of the extent and T2 is last element
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
|
||||
/// last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple"/></returns>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<short, short>[] ToArray()
|
||||
{
|
||||
return backend.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// </summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
@@ -232,7 +236,8 @@ namespace Extents
|
||||
public bool GetStart(short item, out short start)
|
||||
{
|
||||
start = 0;
|
||||
foreach(Tuple<short, short> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) {
|
||||
foreach(Tuple<short, short> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -37,14 +37,14 @@ using System.Linq;
|
||||
namespace Extents
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements extents for <see cref="uint"/>
|
||||
/// Implements extents for <see cref="uint" />
|
||||
/// </summary>
|
||||
public class ExtentsUInt
|
||||
{
|
||||
List<Tuple<uint, uint>> backend;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an empty list of extents
|
||||
/// Initialize an empty list of extents
|
||||
/// </summary>
|
||||
public ExtentsUInt()
|
||||
{
|
||||
@@ -52,7 +52,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes extents with an specific list
|
||||
/// Initializes extents with an specific list
|
||||
/// </summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsUInt(IEnumerable<Tuple<uint, uint>> list)
|
||||
@@ -61,12 +61,12 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a count of how many extents are stored
|
||||
/// Gets a count of how many extents are stored
|
||||
/// </summary>
|
||||
public int Count => backend.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(uint item)
|
||||
@@ -123,11 +123,14 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new extent
|
||||
/// Adds a new extent
|
||||
/// </summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">Last element of the extent or if <see cref="run"/> is <c>true</c> how many elements the extent runs for</param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
/// for
|
||||
/// </param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
|
||||
public void Add(uint start, uint end, bool run = false)
|
||||
{
|
||||
uint realEnd;
|
||||
@@ -139,7 +142,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// </summary>
|
||||
/// <param name="item">Item to seach for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
@@ -149,7 +152,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all extents from this instance
|
||||
/// Removes all extents from this instance
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
@@ -157,7 +160,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the extents in this instance
|
||||
/// Removes an item from the extents in this instance
|
||||
/// </summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
@@ -215,16 +218,17 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple"/> where T1 is first element of the extent and T2 is last element
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
|
||||
/// last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple"/></returns>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<uint, uint>[] ToArray()
|
||||
{
|
||||
return backend.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// </summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
@@ -232,7 +236,8 @@ namespace Extents
|
||||
public bool GetStart(uint item, out uint start)
|
||||
{
|
||||
start = 0;
|
||||
foreach(Tuple<uint, uint> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) {
|
||||
foreach(Tuple<uint, uint> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -37,14 +37,14 @@ using System.Linq;
|
||||
namespace Extents
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements extents for <see cref="ulong"/>
|
||||
/// Implements extents for <see cref="ulong" />
|
||||
/// </summary>
|
||||
public class ExtentsULong
|
||||
{
|
||||
List<Tuple<ulong, ulong>> backend;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an empty list of extents
|
||||
/// Initialize an empty list of extents
|
||||
/// </summary>
|
||||
public ExtentsULong()
|
||||
{
|
||||
@@ -52,7 +52,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes extents with an specific list
|
||||
/// Initializes extents with an specific list
|
||||
/// </summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsULong(IEnumerable<Tuple<ulong, ulong>> list)
|
||||
@@ -61,12 +61,12 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a count of how many extents are stored
|
||||
/// Gets a count of how many extents are stored
|
||||
/// </summary>
|
||||
public int Count => backend.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(ulong item)
|
||||
@@ -123,11 +123,14 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new extent
|
||||
/// Adds a new extent
|
||||
/// </summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">Last element of the extent or if <see cref="run"/> is <c>true</c> how many elements the extent runs for</param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
/// for
|
||||
/// </param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
|
||||
public void Add(ulong start, ulong end, bool run = false)
|
||||
{
|
||||
ulong realEnd;
|
||||
@@ -139,7 +142,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// </summary>
|
||||
/// <param name="item">Item to seach for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
@@ -149,7 +152,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all extents from this instance
|
||||
/// Removes all extents from this instance
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
@@ -157,7 +160,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the extents in this instance
|
||||
/// Removes an item from the extents in this instance
|
||||
/// </summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
@@ -215,16 +218,17 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple"/> where T1 is first element of the extent and T2 is last element
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
|
||||
/// last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple"/></returns>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<ulong, ulong>[] ToArray()
|
||||
{
|
||||
return backend.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// </summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
@@ -232,7 +236,8 @@ namespace Extents
|
||||
public bool GetStart(ulong item, out ulong start)
|
||||
{
|
||||
start = 0;
|
||||
foreach(Tuple<ulong, ulong> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) {
|
||||
foreach(Tuple<ulong, ulong> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -37,14 +37,14 @@ using System.Linq;
|
||||
namespace Extents
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements extents for <see cref="ushort"/>
|
||||
/// Implements extents for <see cref="ushort" />
|
||||
/// </summary>
|
||||
public class ExtentsUShort
|
||||
{
|
||||
List<Tuple<ushort, ushort>> backend;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an empty list of extents
|
||||
/// Initialize an empty list of extents
|
||||
/// </summary>
|
||||
public ExtentsUShort()
|
||||
{
|
||||
@@ -52,7 +52,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes extents with an specific list
|
||||
/// Initializes extents with an specific list
|
||||
/// </summary>
|
||||
/// <param name="list">List of extents as tuples "start, end"</param>
|
||||
public ExtentsUShort(IEnumerable<Tuple<ushort, ushort>> list)
|
||||
@@ -61,12 +61,12 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a count of how many extents are stored
|
||||
/// Gets a count of how many extents are stored
|
||||
/// </summary>
|
||||
public int Count => backend.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// Adds the specified number to the corresponding extent, or creates a new one
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public void Add(ushort item)
|
||||
@@ -123,11 +123,14 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new extent
|
||||
/// Adds a new extent
|
||||
/// </summary>
|
||||
/// <param name="start">First element of the extent</param>
|
||||
/// <param name="end">Last element of the extent or if <see cref="run"/> is <c>true</c> how many elements the extent runs for</param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end"/> indicates how many elements the extent runs for</param>
|
||||
/// <param name="end">
|
||||
/// Last element of the extent or if <see cref="run" /> is <c>true</c> how many elements the extent runs
|
||||
/// for
|
||||
/// </param>
|
||||
/// <param name="run">If set to <c>true</c>, <see cref="end" /> indicates how many elements the extent runs for</param>
|
||||
public void Add(ushort start, ushort end, bool run = false)
|
||||
{
|
||||
ushort realEnd;
|
||||
@@ -139,7 +142,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// Checks if the specified item is contained by an extent on this instance
|
||||
/// </summary>
|
||||
/// <param name="item">Item to seach for</param>
|
||||
/// <returns><c>true</c> if any of the extents on this instance contains the item</returns>
|
||||
@@ -149,7 +152,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all extents from this instance
|
||||
/// Removes all extents from this instance
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
@@ -157,7 +160,7 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes an item from the extents in this instance
|
||||
/// Removes an item from the extents in this instance
|
||||
/// </summary>
|
||||
/// <param name="item">Item to remove</param>
|
||||
/// <returns><c>true</c> if the item was contained in a known extent and removed, false otherwise</returns>
|
||||
@@ -215,16 +218,17 @@ namespace Extents
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the list of extents to an array of <see cref="Tuple"/> where T1 is first element of the extent and T2 is last element
|
||||
/// Converts the list of extents to an array of <see cref="Tuple" /> where T1 is first element of the extent and T2 is
|
||||
/// last element
|
||||
/// </summary>
|
||||
/// <returns>Array of <see cref="Tuple"/></returns>
|
||||
/// <returns>Array of <see cref="Tuple" /></returns>
|
||||
public Tuple<ushort, ushort>[] ToArray()
|
||||
{
|
||||
return backend.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// Gets the first element of the extent that contains the specified item
|
||||
/// </summary>
|
||||
/// <param name="item">Item</param>
|
||||
/// <param name="start">First element of extent</param>
|
||||
@@ -232,7 +236,9 @@ namespace Extents
|
||||
public bool GetStart(ushort item, out ushort start)
|
||||
{
|
||||
start = 0;
|
||||
foreach(Tuple<ushort, ushort> extent in backend.Where(extent => item >= extent.Item1 && item <= extent.Item2)) {
|
||||
foreach(Tuple<ushort, ushort> extent in
|
||||
backend.Where(extent => item >= extent.Item1 && item <= extent.Item2))
|
||||
{
|
||||
start = extent.Item1;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user