Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE]: IKeyValueCollection as IReadOnlyList #874

Original file line number Diff line number Diff line change
Expand Up @@ -861,11 +861,9 @@ namespace DynamicData
{
void Edit(System.Action<DynamicData.ICacheUpdater<TObject, TKey>> updateAction);
}
public interface IKeyValueCollection<TObject, TKey> : System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, TObject>>, System.Collections.IEnumerable
public interface IKeyValueCollection<TObject, TKey> : System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, TObject>>, System.Collections.Generic.IReadOnlyCollection<System.Collections.Generic.KeyValuePair<TKey, TObject>>, System.Collections.Generic.IReadOnlyList<System.Collections.Generic.KeyValuePair<TKey, TObject>>, System.Collections.IEnumerable
{
System.Collections.Generic.IComparer<System.Collections.Generic.KeyValuePair<TKey, TObject>> Comparer { get; }
int Count { get; }
System.Collections.Generic.KeyValuePair<TKey, TObject> this[int index] { get; }
DynamicData.SortOptimisations Optimisations { get; }
DynamicData.SortReason SortReason { get; }
}
Expand Down
16 changes: 8 additions & 8 deletions src/DynamicData.Tests/Cache/SortFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public void RemoveFirst()
_source.AddOrUpdate(people);

//create age 0 to ensure it is inserted first
var remove = _results.Messages[0].SortedItems.First();
var remove = _results.Messages[0].SortedItems[0];

_source.Remove(remove.Key);

Expand All @@ -323,7 +323,7 @@ public void RemoveFromEnd()
_source.AddOrUpdate(people);

//create age 0 to ensure it is inserted first
var remove = _results.Messages[0].SortedItems.Last();
var remove = _results.Messages[0].SortedItems[^1];

_source.Remove(remove.Key);

Expand Down Expand Up @@ -421,7 +421,7 @@ public void UpdateFirst()
var people = _generator.Take(100).ToArray();
_source.AddOrUpdate(people);

var toupdate = _results.Messages[0].SortedItems.First().Value;
var toupdate = _results.Messages[0].SortedItems[0].Value;
var update = new Person(toupdate.Name, toupdate.Age + 5);

_source.AddOrUpdate(update);
Expand All @@ -444,7 +444,7 @@ public void UpdateLast()
var people = _generator.Take(100).ToArray();
_source.AddOrUpdate(people);

var toupdate = _results.Messages[0].SortedItems.Last().Value;
var toupdate = _results.Messages[0].SortedItems[^1].Value;
var update = new Person(toupdate.Name, toupdate.Age + 5);

_source.AddOrUpdate(update);
Expand Down Expand Up @@ -828,7 +828,7 @@ public void RemoveFirst()
_source.AddOrUpdate(people);

//create age 0 to ensure it is inserted first
var remove = _results.Messages[0].SortedItems.First();
var remove = _results.Messages[0].SortedItems[0];

_source.Remove(remove.Key);

Expand All @@ -849,7 +849,7 @@ public void RemoveFromEnd()
_source.AddOrUpdate(people);

//create age 0 to ensure it is inserted first
var remove = _results.Messages[0].SortedItems.Last();
var remove = _results.Messages[0].SortedItems[^1];

_source.Remove(remove.Key);

Expand Down Expand Up @@ -947,7 +947,7 @@ public void UpdateFirst()
var people = _generator.Take(100).ToArray();
_source.AddOrUpdate(people);

var toupdate = _results.Messages[0].SortedItems.First().Value;
var toupdate = _results.Messages[0].SortedItems[0].Value;
var update = new Person(toupdate.Name, toupdate.Age + 5);

_source.AddOrUpdate(update);
Expand All @@ -970,7 +970,7 @@ public void UpdateLast()
var people = _generator.Take(100).ToArray();
_source.AddOrUpdate(people);

var toupdate = _results.Messages[0].SortedItems.Last().Value;
var toupdate = _results.Messages[0].SortedItems[^1].Value;
var update = new Person(toupdate.Name, toupdate.Age + 5);

_source.AddOrUpdate(update);
Expand Down
21 changes: 1 addition & 20 deletions src/DynamicData/Cache/IKeyValueCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace DynamicData;
/// </summary>
/// <typeparam name="TObject">The type of the object.</typeparam>
/// <typeparam name="TKey">The type of the key.</typeparam>
public interface IKeyValueCollection<TObject, TKey> : IEnumerable<KeyValuePair<TKey, TObject>>
public interface IKeyValueCollection<TObject, TKey> : IReadOnlyList<KeyValuePair<TKey, TObject>>
{
/// <summary>
/// Gets the comparer used to perform the sort.
Expand All @@ -20,14 +20,6 @@ public interface IKeyValueCollection<TObject, TKey> : IEnumerable<KeyValuePair<T
/// </value>
IComparer<KeyValuePair<TKey, TObject>> Comparer { get; }

/// <summary>
/// Gets the count of items.
/// </summary>
/// <value>
/// The count.
/// </value>
int Count { get; }

/// <summary>
/// Gets the optimisations used to produce the sort.
/// </summary>
Expand All @@ -43,15 +35,4 @@ public interface IKeyValueCollection<TObject, TKey> : IEnumerable<KeyValuePair<T
/// The sort reason.
/// </value>
SortReason SortReason { get; }

/// <summary>
/// Gets the element at the specified index in the read-only list.
/// </summary>
///
/// <returns>
/// The element at the specified index in the read-only list.
/// </returns>
/// <param name="index">The zero-based index of the element to get. </param>
/// <returns>The key value pair.</returns>
KeyValuePair<TKey, TObject> this[int index] { get; }
}