Create and use SortedKeys

This commit is contained in:
Matt Nadareski
2020-07-26 21:00:30 -07:00
parent 0112821a72
commit efc90457e5
18 changed files with 49 additions and 83 deletions

View File

@@ -134,11 +134,8 @@ namespace SabreTools.Library.DatFiles
// Write out each of the machines and roms
string lastgame = null;
// Get a properly sorted set of keys
List<string> keys = Keys;
keys.Sort(new NaturalComparer());
foreach (string key in keys)
// Use a sorted list of games to output
foreach (string key in SortedKeys)
{
List<DatItem> roms = this[key];

View File

@@ -464,11 +464,8 @@ namespace SabreTools.Library.DatFiles
// Write out each of the machines and roms
string lastgame = null;
// Get a properly sorted set of keys
List<string> keys = Keys;
keys.Sort(new NaturalComparer());
foreach (string key in keys)
// Use a sorted list of games to output
foreach (string key in SortedKeys)
{
List<DatItem> roms = this[key];

View File

@@ -239,6 +239,20 @@ namespace SabreTools.Library.DatFiles
DatHeader.Type = type;
}
/// <summary>
/// Get the keys in sorted order from the file dictionary
/// </summary>
/// <returns>List of the keys in sorted order</returns>
public List<string> SortedKeys
{
get
{
var keys = Items.Keys.ToList();
keys.Sort(new NaturalComparer());
return keys;
}
}
/// <summary>
/// Ensure the key exists in the items dictionary
/// </summary>
@@ -1335,8 +1349,8 @@ namespace SabreTools.Library.DatFiles
// Now, loop through the dictionary and populate the correct DATs
watch.Start("Populating all output DATs");
List<string> keys = Keys;
List<string> keys = Keys;
Parallel.ForEach(keys, Globals.ParallelOptions, key =>
{
List<DatItem> items = DatItem.Merge(this[key]);

View File

@@ -290,11 +290,8 @@ namespace SabreTools.Library.DatFiles
// Write out each of the machines and roms
string lastgame = null;
// Get a properly sorted set of keys
List<string> keys = Keys;
keys.Sort(new NaturalComparer());
foreach (string key in keys)
// Use a sorted list of games to output
foreach (string key in SortedKeys)
{
List<DatItem> roms = this[key];

View File

@@ -110,11 +110,8 @@ namespace SabreTools.Library.DatFiles
VerifyFieldCount = true
};
// Get a properly sorted set of keys
List<string> keys = Keys;
keys.Sort(new NaturalComparer());
foreach (string key in keys)
// Use a sorted list of games to output
foreach (string key in SortedKeys)
{
List<DatItem> roms = this[key];

View File

@@ -125,11 +125,8 @@ namespace SabreTools.Library.DatFiles
VerifyFieldCount = true
};
// Get a properly sorted set of keys
List<string> keys = Keys;
keys.Sort(new NaturalComparer());
foreach (string key in keys)
// Use a sorted list of games to output
foreach (string key in SortedKeys)
{
List<DatItem> roms = this[key];

View File

@@ -776,11 +776,8 @@ namespace SabreTools.Library.DatFiles
// Write out each of the machines and roms
string lastgame = null;
// Get a properly sorted set of keys
List<string> keys = Keys;
keys.Sort(new NaturalComparer());
foreach (string key in keys)
// Use a sorted list of games to output
foreach (string key in SortedKeys)
{
List<DatItem> roms = this[key];

View File

@@ -253,11 +253,8 @@ namespace SabreTools.Library.DatFiles
// Write out each of the machines and roms
string lastgame = null;
// Get a properly sorted set of keys
List<string> keys = Keys;
keys.Sort(new NaturalComparer());
foreach (string key in keys)
// Use a sorted list of games to output
foreach (string key in SortedKeys)
{
List<DatItem> roms = this[key];

View File

@@ -574,11 +574,8 @@ namespace SabreTools.Library.DatFiles
// Write out each of the machines and roms
string lastgame = null;
// Get a properly sorted set of keys
List<string> keys = Keys;
keys.Sort(new NaturalComparer());
foreach (string key in keys)
// Use a sorted list of games to output
foreach (string key in SortedKeys)
{
List<DatItem> roms = this[key];

View File

@@ -671,11 +671,8 @@ namespace SabreTools.Library.DatFiles
// Write out each of the machines and roms
string lastgame = null;
// Get a properly sorted set of keys
List<string> keys = Keys;
keys.Sort(new NaturalComparer());
foreach (string key in keys)
// Use a sorted list of games to output
foreach (string key in SortedKeys)
{
List<DatItem> roms = this[key];

View File

@@ -67,11 +67,8 @@ namespace SabreTools.Library.DatFiles
// Write out each of the machines and roms
string lastgame = null;
// Get a properly sorted set of keys
List<string> keys = Keys;
keys.Sort(new NaturalComparer());
foreach (string key in keys)
// Use a sorted list of games to output
foreach (string key in SortedKeys)
{
List<DatItem> roms = this[key];

View File

@@ -757,11 +757,8 @@ namespace SabreTools.Library.DatFiles
// Write out each of the machines and roms
string lastgame = null;
// Get a properly sorted set of keys
List<string> keys = Keys;
keys.Sort(new NaturalComparer());
foreach (string key in keys)
// Use a sorted list of games to output
foreach (string key in SortedKeys)
{
List<DatItem> roms = this[key];

View File

@@ -501,11 +501,8 @@ namespace SabreTools.Library.DatFiles
// Write out each of the machines and roms
string lastgame = null;
// Get a properly sorted set of keys
List<string> keys = Keys;
keys.Sort(new NaturalComparer());
foreach (string key in keys)
// Use a sorted list of games to output
foreach (string key in SortedKeys)
{
List<DatItem> roms = this[key];

View File

@@ -392,11 +392,8 @@ namespace SabreTools.Library.DatFiles
string lastgame = null;
List<string> splitpath = new List<string>();
// Get a properly sorted set of keys
List<string> keys = Keys;
keys.Sort(new NaturalComparer());
foreach (string key in keys)
// Use a sorted list of games to output
foreach (string key in SortedKeys)
{
List<DatItem> roms = this[key];

View File

@@ -563,11 +563,8 @@ namespace SabreTools.Library.DatFiles
string lastgame = null;
List<string> splitpath = new List<string>();
// Get a properly sorted set of keys
List<string> keys = Keys;
keys.Sort(new NaturalComparer());
foreach (string key in keys)
// Use a sorted list of games to output
foreach (string key in SortedKeys)
{
List<DatItem> roms = this[key];

View File

@@ -882,11 +882,8 @@ namespace SabreTools.Library.DatFiles
// Write out the header
WriteHeader(svw);
// Get a properly sorted set of keys
List<string> keys = Keys;
keys.Sort(new NaturalComparer());
foreach (string key in keys)
// Use a sorted list of games to output
foreach (string key in SortedKeys)
{
List<DatItem> roms = this[key];

View File

@@ -554,11 +554,8 @@ namespace SabreTools.Library.DatFiles
// Write out each of the machines and roms
string lastgame = null;
// Get a properly sorted set of keys
List<string> keys = Keys;
keys.Sort(new NaturalComparer());
foreach (string key in keys)
// Use a sorted list of games to output
foreach (string key in SortedKeys)
{
List<DatItem> roms = this[key];

View File

@@ -12,8 +12,8 @@ namespace SabreTools.Library.Data
/// <summary>
/// The current toolset version to be used by all child applications
/// </summary>
public readonly static string Version = $"v1.0.2";
//public readonly static string Version = $"v1.0.2-{File.GetCreationTime(Assembly.GetExecutingAssembly().Location):yyyy-MM-dd HH:mm:ss}";
///public readonly static string Version = $"v1.0.2";
public readonly static string Version = $"v1.0.2-{File.GetCreationTime(Assembly.GetExecutingAssembly().Location):yyyy-MM-dd HH:mm:ss}";
public const int HeaderHeight = 3;
#region 0-byte file constants