DOCUMENTATION: Added XML documentation to DiscImageChef.Helpers.

This commit is contained in:
2017-12-23 03:51:42 +00:00
parent c15207c053
commit eb1cd59a98
17 changed files with 687 additions and 437 deletions

View File

@@ -36,22 +36,39 @@ using System.Linq;
namespace Extents
{
/// <summary>
/// Implements extents for <see cref="byte"/>
/// </summary>
public class ExtentsByte
{
List<Tuple<byte, byte>> backend;
/// <summary>
/// Initialize an empty list of extents
/// </summary>
public ExtentsByte()
{
backend = new List<Tuple<byte, byte>>();
}
/// <summary>
/// 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)
{
backend = list.OrderBy(t => t.Item1).ToList();
}
/// <summary>
/// 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
/// </summary>
/// <param name="item"></param>
public void Add(byte item)
{
Tuple<byte, byte> removeOne = null;
@@ -105,6 +122,12 @@ namespace Extents
backend = backend.OrderBy(t => t.Item1).ToList();
}
/// <summary>
/// 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>
public void Add(byte start, byte end, bool run = false)
{
byte realEnd;
@@ -115,16 +138,29 @@ namespace Extents
for(byte t = start; t <= realEnd; t++) Add(t);
}
/// <summary>
/// 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>
public bool Contains(byte item)
{
return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
}
/// <summary>
/// Removes all extents from this instance
/// </summary>
public void Clear()
{
backend.Clear();
}
/// <summary>
/// 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>
public bool Remove(byte item)
{
Tuple<byte, byte> toRemove = null;
@@ -178,11 +214,21 @@ namespace Extents
return true;
}
/// <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
/// </summary>
/// <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
/// </summary>
/// <param name="item">Item</param>
/// <param name="start">First element of extent</param>
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
public bool GetStart(byte item, out byte start)
{
start = 0;

View File

@@ -36,22 +36,39 @@ using System.Linq;
namespace Extents
{
/// <summary>
/// Implements extents for <see cref="int"/>
/// </summary>
public class ExtentsInt
{
List<Tuple<int, int>> backend;
/// <summary>
/// Initialize an empty list of extents
/// </summary>
public ExtentsInt()
{
backend = new List<Tuple<int, int>>();
}
/// <summary>
/// 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)
{
backend = list.OrderBy(t => t.Item1).ToList();
}
/// <summary>
/// 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
/// </summary>
/// <param name="item"></param>
public void Add(int item)
{
Tuple<int, int> removeOne = null;
@@ -105,6 +122,12 @@ namespace Extents
backend = backend.OrderBy(t => t.Item1).ToList();
}
/// <summary>
/// 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>
public void Add(int start, int end, bool run = false)
{
int realEnd;
@@ -115,16 +138,29 @@ namespace Extents
for(int t = start; t <= realEnd; t++) Add(t);
}
/// <summary>
/// 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>
public bool Contains(int item)
{
return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
}
/// <summary>
/// Removes all extents from this instance
/// </summary>
public void Clear()
{
backend.Clear();
}
/// <summary>
/// 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>
public bool Remove(int item)
{
Tuple<int, int> toRemove = null;
@@ -178,11 +214,21 @@ namespace Extents
return true;
}
/// <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
/// </summary>
/// <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
/// </summary>
/// <param name="item">Item</param>
/// <param name="start">First element of extent</param>
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
public bool GetStart(int item, out int start)
{
start = 0;

View File

@@ -36,22 +36,39 @@ using System.Linq;
namespace Extents
{
/// <summary>
/// Implements extents for <see cref="long"/>
/// </summary>
public class ExtentsLong
{
List<Tuple<long, long>> backend;
/// <summary>
/// Initialize an empty list of extents
/// </summary>
public ExtentsLong()
{
backend = new List<Tuple<long, long>>();
}
/// <summary>
/// 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)
{
backend = list.OrderBy(t => t.Item1).ToList();
}
/// <summary>
/// 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
/// </summary>
/// <param name="item"></param>
public void Add(long item)
{
Tuple<long, long> removeOne = null;
@@ -105,6 +122,12 @@ namespace Extents
backend = backend.OrderBy(t => t.Item1).ToList();
}
/// <summary>
/// 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>
public void Add(long start, long end, bool run = false)
{
long realEnd;
@@ -115,16 +138,29 @@ namespace Extents
for(long t = start; t <= realEnd; t++) Add(t);
}
/// <summary>
/// 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>
public bool Contains(long item)
{
return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
}
/// <summary>
/// Removes all extents from this instance
/// </summary>
public void Clear()
{
backend.Clear();
}
/// <summary>
/// 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>
public bool Remove(long item)
{
Tuple<long, long> toRemove = null;
@@ -178,11 +214,21 @@ namespace Extents
return true;
}
/// <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
/// </summary>
/// <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
/// </summary>
/// <param name="item">Item</param>
/// <param name="start">First element of extent</param>
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
public bool GetStart(long item, out long start)
{
start = 0;

View File

@@ -36,22 +36,39 @@ using System.Linq;
namespace Extents
{
/// <summary>
/// Implements extents for <see cref="sbyte"/>
/// </summary>
public class ExtentsSByte
{
List<Tuple<sbyte, sbyte>> backend;
/// <summary>
/// Initialize an empty list of extents
/// </summary>
public ExtentsSByte()
{
backend = new List<Tuple<sbyte, sbyte>>();
}
/// <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();
}
/// <summary>
/// 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
/// </summary>
/// <param name="item"></param>
public void Add(sbyte item)
{
Tuple<sbyte, sbyte> removeOne = null;
@@ -105,6 +122,12 @@ namespace Extents
backend = backend.OrderBy(t => t.Item1).ToList();
}
/// <summary>
/// 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>
public void Add(sbyte start, sbyte end, bool run = false)
{
sbyte realEnd;
@@ -115,16 +138,29 @@ namespace Extents
for(sbyte t = start; t <= realEnd; t++) Add(t);
}
/// <summary>
/// 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>
public bool Contains(sbyte item)
{
return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
}
/// <summary>
/// Removes all extents from this instance
/// </summary>
public void Clear()
{
backend.Clear();
}
/// <summary>
/// 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>
public bool Remove(sbyte item)
{
Tuple<sbyte, sbyte> toRemove = null;
@@ -178,11 +214,21 @@ namespace Extents
return true;
}
/// <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
/// </summary>
/// <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
/// </summary>
/// <param name="item">Item</param>
/// <param name="start">First element of extent</param>
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
public bool GetStart(sbyte item, out sbyte start)
{
start = 0;

View File

@@ -36,22 +36,39 @@ using System.Linq;
namespace Extents
{
/// <summary>
/// Implements extents for <see cref="short"/>
/// </summary>
public class ExtentsShort
{
List<Tuple<short, short>> backend;
/// <summary>
/// Initialize an empty list of extents
/// </summary>
public ExtentsShort()
{
backend = new List<Tuple<short, short>>();
}
/// <summary>
/// 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)
{
backend = list.OrderBy(t => t.Item1).ToList();
}
/// <summary>
/// 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
/// </summary>
/// <param name="item"></param>
public void Add(short item)
{
Tuple<short, short> removeOne = null;
@@ -105,6 +122,12 @@ namespace Extents
backend = backend.OrderBy(t => t.Item1).ToList();
}
/// <summary>
/// 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>
public void Add(short start, short end, bool run = false)
{
short realEnd;
@@ -115,16 +138,29 @@ namespace Extents
for(short t = start; t <= realEnd; t++) Add(t);
}
/// <summary>
/// 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>
public bool Contains(short item)
{
return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
}
/// <summary>
/// Removes all extents from this instance
/// </summary>
public void Clear()
{
backend.Clear();
}
/// <summary>
/// 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>
public bool Remove(short item)
{
Tuple<short, short> toRemove = null;
@@ -178,11 +214,21 @@ namespace Extents
return true;
}
/// <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
/// </summary>
/// <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
/// </summary>
/// <param name="item">Item</param>
/// <param name="start">First element of extent</param>
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
public bool GetStart(short item, out short start)
{
start = 0;

View File

@@ -36,22 +36,39 @@ using System.Linq;
namespace Extents
{
/// <summary>
/// Implements extents for <see cref="uint"/>
/// </summary>
public class ExtentsUInt
{
List<Tuple<uint, uint>> backend;
/// <summary>
/// Initialize an empty list of extents
/// </summary>
public ExtentsUInt()
{
backend = new List<Tuple<uint, uint>>();
}
/// <summary>
/// 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)
{
backend = list.OrderBy(t => t.Item1).ToList();
}
/// <summary>
/// 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
/// </summary>
/// <param name="item"></param>
public void Add(uint item)
{
Tuple<uint, uint> removeOne = null;
@@ -105,6 +122,12 @@ namespace Extents
backend = backend.OrderBy(t => t.Item1).ToList();
}
/// <summary>
/// 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>
public void Add(uint start, uint end, bool run = false)
{
uint realEnd;
@@ -115,16 +138,29 @@ namespace Extents
for(uint t = start; t <= realEnd; t++) Add(t);
}
/// <summary>
/// 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>
public bool Contains(uint item)
{
return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
}
/// <summary>
/// Removes all extents from this instance
/// </summary>
public void Clear()
{
backend.Clear();
}
/// <summary>
/// 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>
public bool Remove(uint item)
{
Tuple<uint, uint> toRemove = null;
@@ -178,11 +214,21 @@ namespace Extents
return true;
}
/// <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
/// </summary>
/// <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
/// </summary>
/// <param name="item">Item</param>
/// <param name="start">First element of extent</param>
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
public bool GetStart(uint item, out uint start)
{
start = 0;

View File

@@ -36,22 +36,39 @@ using System.Linq;
namespace Extents
{
/// <summary>
/// Implements extents for <see cref="ulong"/>
/// </summary>
public class ExtentsULong
{
List<Tuple<ulong, ulong>> backend;
/// <summary>
/// Initialize an empty list of extents
/// </summary>
public ExtentsULong()
{
backend = new List<Tuple<ulong, ulong>>();
}
/// <summary>
/// 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)
{
backend = list.OrderBy(t => t.Item1).ToList();
}
/// <summary>
/// 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
/// </summary>
/// <param name="item"></param>
public void Add(ulong item)
{
Tuple<ulong, ulong> removeOne = null;
@@ -105,6 +122,12 @@ namespace Extents
backend = backend.OrderBy(t => t.Item1).ToList();
}
/// <summary>
/// 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>
public void Add(ulong start, ulong end, bool run = false)
{
ulong realEnd;
@@ -115,16 +138,29 @@ namespace Extents
for(ulong t = start; t <= realEnd; t++) Add(t);
}
/// <summary>
/// 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>
public bool Contains(ulong item)
{
return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
}
/// <summary>
/// Removes all extents from this instance
/// </summary>
public void Clear()
{
backend.Clear();
}
/// <summary>
/// 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>
public bool Remove(ulong item)
{
Tuple<ulong, ulong> toRemove = null;
@@ -178,11 +214,21 @@ namespace Extents
return true;
}
/// <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
/// </summary>
/// <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
/// </summary>
/// <param name="item">Item</param>
/// <param name="start">First element of extent</param>
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
public bool GetStart(ulong item, out ulong start)
{
start = 0;

View File

@@ -36,22 +36,39 @@ using System.Linq;
namespace Extents
{
/// <summary>
/// Implements extents for <see cref="ushort"/>
/// </summary>
public class ExtentsUShort
{
List<Tuple<ushort, ushort>> backend;
/// <summary>
/// Initialize an empty list of extents
/// </summary>
public ExtentsUShort()
{
backend = new List<Tuple<ushort, ushort>>();
}
/// <summary>
/// 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)
{
backend = list.OrderBy(t => t.Item1).ToList();
}
/// <summary>
/// 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
/// </summary>
/// <param name="item"></param>
public void Add(ushort item)
{
Tuple<ushort, ushort> removeOne = null;
@@ -105,6 +122,12 @@ namespace Extents
backend = backend.OrderBy(t => t.Item1).ToList();
}
/// <summary>
/// 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>
public void Add(ushort start, ushort end, bool run = false)
{
ushort realEnd;
@@ -115,16 +138,29 @@ namespace Extents
for(ushort t = start; t <= realEnd; t++) Add(t);
}
/// <summary>
/// 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>
public bool Contains(ushort item)
{
return backend.Any(extent => item >= extent.Item1 && item <= extent.Item2);
}
/// <summary>
/// Removes all extents from this instance
/// </summary>
public void Clear()
{
backend.Clear();
}
/// <summary>
/// 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>
public bool Remove(ushort item)
{
Tuple<ushort, ushort> toRemove = null;
@@ -178,11 +214,21 @@ namespace Extents
return true;
}
/// <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
/// </summary>
/// <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
/// </summary>
/// <param name="item">Item</param>
/// <param name="start">First element of extent</param>
/// <returns><c>true</c> if item was found in an extent, false otherwise</returns>
public bool GetStart(ushort item, out ushort start)
{
start = 0;