mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Fix extents creation from a list of extents to prevent overlapping extents to be added.
This commit is contained in:
@@ -52,7 +52,14 @@ namespace Aaru.CommonTypes.Extents
|
||||
|
||||
/// <summary>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) => _backend = list.OrderBy(t => t.Item1).ToList();
|
||||
public ExtentsSByte(IEnumerable<Tuple<sbyte, sbyte>> list)
|
||||
{
|
||||
_backend = new List<Tuple<sbyte, sbyte>>();
|
||||
|
||||
// This ensure no overlapping extents are added on creation
|
||||
foreach(Tuple<sbyte, sbyte> t in list)
|
||||
Add(t.Item1, t.Item2);
|
||||
}
|
||||
|
||||
/// <summary>Gets a count of how many extents are stored</summary>
|
||||
public int Count => _backend.Count;
|
||||
@@ -234,8 +241,8 @@ namespace Aaru.CommonTypes.Extents
|
||||
{
|
||||
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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user