Skip to content

Commit 498126e

Browse files
committed
ListChain stores IReadOnlyCollection
1 parent 59ebe06 commit 498126e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/InformationRetrieval.Test/Utility/ListChainTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void ListChainSortTest()
3333
new[] { 3 }
3434
};
3535

36-
chain.Sort((a, b) => a[0].CompareTo(b[0]));
36+
chain.Sort((a, b) => a.First().CompareTo(b.First()));
3737

3838
Assert.Equal(7, chain.Count);
3939
Assert.Equal(new[] { 1, 2, 3, 4, 5, 6, 7 }, chain.ToArray());

src/InformationRetrieval/Utility/ListChain.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ namespace InformationRetrieval.Utility
1010
/// <typeparam name="T">The type of elements in the collection.</typeparam>
1111
public class ListChain<T> : IEnumerable<T>, IReadOnlyCollection<T>
1212
{
13-
private readonly List<IList<T>> chain;
13+
private readonly List<IReadOnlyCollection<T>> chain;
1414

1515
public ListChain(): this(0) { }
1616

1717
public ListChain(int capacity)
1818
{
19-
chain = new List<IList<T>>(capacity);
19+
chain = new List<IReadOnlyCollection<T>>(capacity);
2020
Count = 0;
2121
}
2222

23-
public void Add(IList<T> node)
23+
public void Add(IReadOnlyCollection<T> node)
2424
{
2525
chain.Add(node);
2626
Count += node.Count;
2727
}
2828

29-
public void Sort(Comparison<IList<T>> comparison) =>
29+
public void Sort(Comparison<IReadOnlyCollection<T>> comparison) =>
3030
chain.Sort(comparison);
3131

3232
public int Count { get; private set; }

0 commit comments

Comments
 (0)