mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Move other stats dictionaries private
This commit is contained in:
@@ -803,8 +803,8 @@ namespace SabreTools.DatFiles.Test
|
|||||||
Assert.Equal(1, dict.DatStatistics.TotalCount);
|
Assert.Equal(1, dict.DatStatistics.TotalCount);
|
||||||
Assert.Equal(1, dict.DatStatistics.GetItemCount(ItemType.Rom));
|
Assert.Equal(1, dict.DatStatistics.GetItemCount(ItemType.Rom));
|
||||||
Assert.Equal(12345, dict.DatStatistics.TotalSize);
|
Assert.Equal(12345, dict.DatStatistics.TotalSize);
|
||||||
Assert.Equal(1, dict.DatStatistics.HashCounts[HashType.CRC32]);
|
Assert.Equal(1, dict.DatStatistics.GetHashCount(HashType.CRC32));
|
||||||
Assert.Equal(0, dict.DatStatistics.HashCounts[HashType.MD5]);
|
Assert.Equal(0, dict.DatStatistics.GetHashCount(HashType.MD5));
|
||||||
|
|
||||||
item.SetFieldValue<string?>(Models.Metadata.Rom.MD5Key, "deadbeef");
|
item.SetFieldValue<string?>(Models.Metadata.Rom.MD5Key, "deadbeef");
|
||||||
|
|
||||||
@@ -813,8 +813,8 @@ namespace SabreTools.DatFiles.Test
|
|||||||
Assert.Equal(1, dict.DatStatistics.TotalCount);
|
Assert.Equal(1, dict.DatStatistics.TotalCount);
|
||||||
Assert.Equal(1, dict.DatStatistics.GetItemCount(ItemType.Rom));
|
Assert.Equal(1, dict.DatStatistics.GetItemCount(ItemType.Rom));
|
||||||
Assert.Equal(12345, dict.DatStatistics.TotalSize);
|
Assert.Equal(12345, dict.DatStatistics.TotalSize);
|
||||||
Assert.Equal(1, dict.DatStatistics.HashCounts[HashType.CRC32]);
|
Assert.Equal(1, dict.DatStatistics.GetHashCount(HashType.CRC32));
|
||||||
Assert.Equal(1, dict.DatStatistics.HashCounts[HashType.MD5]);
|
Assert.Equal(1, dict.DatStatistics.GetHashCount(HashType.MD5));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -640,8 +640,8 @@ namespace SabreTools.DatFiles.Test
|
|||||||
Assert.Equal(1, dict.DatStatistics.TotalCount);
|
Assert.Equal(1, dict.DatStatistics.TotalCount);
|
||||||
Assert.Equal(1, dict.DatStatistics.GetItemCount(ItemType.Rom));
|
Assert.Equal(1, dict.DatStatistics.GetItemCount(ItemType.Rom));
|
||||||
Assert.Equal(12345, dict.DatStatistics.TotalSize);
|
Assert.Equal(12345, dict.DatStatistics.TotalSize);
|
||||||
Assert.Equal(1, dict.DatStatistics.HashCounts[HashType.CRC32]);
|
Assert.Equal(1, dict.DatStatistics.GetHashCount(HashType.CRC32));
|
||||||
Assert.Equal(0, dict.DatStatistics.HashCounts[HashType.MD5]);
|
Assert.Equal(0, dict.DatStatistics.GetHashCount(HashType.MD5));
|
||||||
|
|
||||||
item.SetFieldValue<string?>(Models.Metadata.Rom.MD5Key, "deadbeef");
|
item.SetFieldValue<string?>(Models.Metadata.Rom.MD5Key, "deadbeef");
|
||||||
|
|
||||||
@@ -650,8 +650,8 @@ namespace SabreTools.DatFiles.Test
|
|||||||
Assert.Equal(1, dict.DatStatistics.TotalCount);
|
Assert.Equal(1, dict.DatStatistics.TotalCount);
|
||||||
Assert.Equal(1, dict.DatStatistics.GetItemCount(ItemType.Rom));
|
Assert.Equal(1, dict.DatStatistics.GetItemCount(ItemType.Rom));
|
||||||
Assert.Equal(12345, dict.DatStatistics.TotalSize);
|
Assert.Equal(12345, dict.DatStatistics.TotalSize);
|
||||||
Assert.Equal(1, dict.DatStatistics.HashCounts[HashType.CRC32]);
|
Assert.Equal(1, dict.DatStatistics.GetHashCount(HashType.CRC32));
|
||||||
Assert.Equal(1, dict.DatStatistics.HashCounts[HashType.MD5]);
|
Assert.Equal(1, dict.DatStatistics.GetHashCount(HashType.MD5));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -13,11 +13,21 @@ namespace SabreTools.DatFiles
|
|||||||
{
|
{
|
||||||
#region Private instance variables
|
#region Private instance variables
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Number of items for each hash type
|
||||||
|
/// </summary>
|
||||||
|
private readonly Dictionary<HashType, long> _hashCounts = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of items for each item type
|
/// Number of items for each item type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly Dictionary<ItemType, long> _itemCounts = [];
|
private readonly Dictionary<ItemType, long> _itemCounts = [];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Number of items for each item status
|
||||||
|
/// </summary>
|
||||||
|
private readonly Dictionary<ItemStatus, long> _statusCounts = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Lock for statistics calculation
|
/// Lock for statistics calculation
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -43,16 +53,6 @@ namespace SabreTools.DatFiles
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public long TotalSize { get; private set; } = 0;
|
public long TotalSize { get; private set; } = 0;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of items for each hash type
|
|
||||||
/// </summary>
|
|
||||||
public Dictionary<HashType, long> HashCounts { get; } = [];
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Number of items for each item status
|
|
||||||
/// </summary>
|
|
||||||
public Dictionary<ItemStatus, long> StatusCounts { get; } = [];
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of items with the remove flag
|
/// Number of items with the remove flag
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -183,13 +183,13 @@ namespace SabreTools.DatFiles
|
|||||||
TotalSize += stats.TotalSize;
|
TotalSize += stats.TotalSize;
|
||||||
|
|
||||||
// Individual hash counts
|
// Individual hash counts
|
||||||
foreach (var hashCountKvp in stats.HashCounts)
|
foreach (var hashCountKvp in stats._hashCounts)
|
||||||
{
|
{
|
||||||
AddHashCount(hashCountKvp.Key, hashCountKvp.Value);
|
AddHashCount(hashCountKvp.Key, hashCountKvp.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Individual status counts
|
// Individual status counts
|
||||||
foreach (var statusCountKvp in stats.StatusCounts)
|
foreach (var statusCountKvp in stats._statusCounts)
|
||||||
{
|
{
|
||||||
AddStatusCount(statusCountKvp.Key, statusCountKvp.Value);
|
AddStatusCount(statusCountKvp.Key, statusCountKvp.Value);
|
||||||
}
|
}
|
||||||
@@ -204,12 +204,12 @@ namespace SabreTools.DatFiles
|
|||||||
/// <returns>The number of items with that hash, if it exists</returns>
|
/// <returns>The number of items with that hash, if it exists</returns>
|
||||||
public long GetHashCount(HashType hashType)
|
public long GetHashCount(HashType hashType)
|
||||||
{
|
{
|
||||||
lock (HashCounts)
|
lock (_hashCounts)
|
||||||
{
|
{
|
||||||
if (!HashCounts.ContainsKey(hashType))
|
if (!_hashCounts.ContainsKey(hashType))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return HashCounts[hashType];
|
return _hashCounts[hashType];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,12 +236,12 @@ namespace SabreTools.DatFiles
|
|||||||
/// <returns>The number of items of that type, if it exists</returns>
|
/// <returns>The number of items of that type, if it exists</returns>
|
||||||
public long GetStatusCount(ItemStatus itemStatus)
|
public long GetStatusCount(ItemStatus itemStatus)
|
||||||
{
|
{
|
||||||
lock (StatusCounts)
|
lock (_statusCounts)
|
||||||
{
|
{
|
||||||
if (!StatusCounts.ContainsKey(itemStatus))
|
if (!_statusCounts.ContainsKey(itemStatus))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return StatusCounts[itemStatus];
|
return _statusCounts[itemStatus];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,14 +252,14 @@ namespace SabreTools.DatFiles
|
|||||||
/// <param name="interval">Amount to increment by, defaults to 1</param>
|
/// <param name="interval">Amount to increment by, defaults to 1</param>
|
||||||
private void AddHashCount(HashType hashType, long interval = 1)
|
private void AddHashCount(HashType hashType, long interval = 1)
|
||||||
{
|
{
|
||||||
lock (HashCounts)
|
lock (_hashCounts)
|
||||||
{
|
{
|
||||||
if (!HashCounts.ContainsKey(hashType))
|
if (!_hashCounts.ContainsKey(hashType))
|
||||||
HashCounts[hashType] = 0;
|
_hashCounts[hashType] = 0;
|
||||||
|
|
||||||
HashCounts[hashType] += interval;
|
_hashCounts[hashType] += interval;
|
||||||
if (HashCounts[hashType] < 0)
|
if (_hashCounts[hashType] < 0)
|
||||||
HashCounts[hashType] = 0;
|
_hashCounts[hashType] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,14 +288,14 @@ namespace SabreTools.DatFiles
|
|||||||
/// <param name="interval">Amount to increment by, defaults to 1</param>
|
/// <param name="interval">Amount to increment by, defaults to 1</param>
|
||||||
private void AddStatusCount(ItemStatus itemStatus, long interval = 1)
|
private void AddStatusCount(ItemStatus itemStatus, long interval = 1)
|
||||||
{
|
{
|
||||||
lock (StatusCounts)
|
lock (_statusCounts)
|
||||||
{
|
{
|
||||||
if (!StatusCounts.ContainsKey(itemStatus))
|
if (!_statusCounts.ContainsKey(itemStatus))
|
||||||
StatusCounts[itemStatus] = 0;
|
_statusCounts[itemStatus] = 0;
|
||||||
|
|
||||||
StatusCounts[itemStatus] += interval;
|
_statusCounts[itemStatus] += interval;
|
||||||
if (StatusCounts[itemStatus] < 0)
|
if (_statusCounts[itemStatus] < 0)
|
||||||
StatusCounts[itemStatus] = 0;
|
_statusCounts[itemStatus] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,8 +375,8 @@ namespace SabreTools.DatFiles
|
|||||||
_itemCounts.Clear();
|
_itemCounts.Clear();
|
||||||
GameCount = 0;
|
GameCount = 0;
|
||||||
TotalSize = 0;
|
TotalSize = 0;
|
||||||
HashCounts.Clear();
|
_hashCounts.Clear();
|
||||||
StatusCounts.Clear();
|
_statusCounts.Clear();
|
||||||
RemovedCount = 0;
|
RemovedCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,14 +387,14 @@ namespace SabreTools.DatFiles
|
|||||||
/// <param name="interval">Amount to increment by, defaults to 1</param>
|
/// <param name="interval">Amount to increment by, defaults to 1</param>
|
||||||
private void RemoveHashCount(HashType hashType, long interval = 1)
|
private void RemoveHashCount(HashType hashType, long interval = 1)
|
||||||
{
|
{
|
||||||
lock (HashCounts)
|
lock (_hashCounts)
|
||||||
{
|
{
|
||||||
if (!HashCounts.ContainsKey(hashType))
|
if (!_hashCounts.ContainsKey(hashType))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
HashCounts[hashType] -= interval;
|
_hashCounts[hashType] -= interval;
|
||||||
if (HashCounts[hashType] < 0)
|
if (_hashCounts[hashType] < 0)
|
||||||
HashCounts[hashType] = 0;
|
_hashCounts[hashType] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,14 +423,14 @@ namespace SabreTools.DatFiles
|
|||||||
/// <param name="interval">Amount to increment by, defaults to 1</param>
|
/// <param name="interval">Amount to increment by, defaults to 1</param>
|
||||||
private void RemoveStatusCount(ItemStatus itemStatus, long interval = 1)
|
private void RemoveStatusCount(ItemStatus itemStatus, long interval = 1)
|
||||||
{
|
{
|
||||||
lock (StatusCounts)
|
lock (_statusCounts)
|
||||||
{
|
{
|
||||||
if (!StatusCounts.ContainsKey(itemStatus))
|
if (!_statusCounts.ContainsKey(itemStatus))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StatusCounts[itemStatus] -= interval;
|
_statusCounts[itemStatus] -= interval;
|
||||||
if (StatusCounts[itemStatus] < 0)
|
if (_statusCounts[itemStatus] < 0)
|
||||||
StatusCounts[itemStatus] = 0;
|
_statusCounts[itemStatus] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user