mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
DOCUMENTATION: Added XML documentation to DiscImageChef.Helpers.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user