using System.Collections.Generic;
namespace BizHawk.Client.Common
{
///
/// This class hold a collection
/// Different memory domain can be mixed
///
public sealed partial class WatchList
{
///
/// Nested private class that define how to compare two
/// based on their address
///
private sealed class WatchAddressComparer
: WatchEqualityComparer, IComparer
{
///
/// Compares two between them
/// and determines which one comes first.
/// If they are equals, comparison will done one the domain and next on size
///
/// First
/// Second
/// 0 for equality, 1 if x comes first; -1 if y comes first
public int Compare(Watch x, Watch y)
{
if (Equals(x, y))
{
return 0;
}
if (x.Address.Equals(y.Address))
{
if (x.Domain.Name.Equals(y.Domain.Name))
{
return x.Size.CompareTo(y.Size);
}
return x.Domain.Name.CompareTo(y.Domain.Name);
}
return x.Address.CompareTo(y.Address);
}
}
}
}