Skip to content

Commit

Permalink
KeyValuePair.Create
Browse files Browse the repository at this point in the history
  • Loading branch information
Rasmus Lystrøm committed Dec 16, 2015
1 parent 10413c4 commit 8564239
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
1 change: 1 addition & 0 deletions C5.Tests/C5.Tests.csproj
Expand Up @@ -54,6 +54,7 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="InterfacesTest.cs" />
<Compile Include="KeyValuePairTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Records.cs" />
<Compile Include="Sorting.cs">
Expand Down
17 changes: 17 additions & 0 deletions C5.Tests/KeyValuePairTests.cs
@@ -0,0 +1,17 @@
using NUnit.Framework;

namespace C5.Tests
{
[TestFixture]
public class KeyValuePairTests
{
[Test]
public void Create()
{
var p1 = new KeyValuePair<int, string>(42, "The answer");
var p2 = KeyValuePair.Create(42, "The answer");

Assert.AreEqual(p1, p2);
}
}
}
24 changes: 14 additions & 10 deletions C5/Dictionaries.cs
Expand Up @@ -74,16 +74,6 @@ public override bool Equals(object obj)
return Equals(other);
}


/// <summary>
/// Create an instance of the KeyValuePair using type inference.
/// </summary>
public static KeyValuePair<K, V> Create<K, V>(K key, V value)
{
return new KeyValuePair<K, V>(key, value);
}


/// <summary>
/// Get the hash code of the pair.
/// </summary>
Expand Down Expand Up @@ -1262,6 +1252,20 @@ public override bool Show(System.Text.StringBuilder stringbuilder, ref int rest,

}

/// <summary>
/// Static class to allow creation of KeyValuePair using type inference
/// </summary>
public static class KeyValuePair
{
/// <summary>
/// Create an instance of the KeyValuePair using type inference.
/// </summary>
public static KeyValuePair<K, V> Create<K, V>(K key, V value)
{
return new KeyValuePair<K, V>(key, value);
}
}

[Serializable]
class SortedArrayDictionary<K, V> : SortedDictionaryBase<K, V>
{
Expand Down
7 changes: 7 additions & 0 deletions RELEASE-NOTES.txt
@@ -1,6 +1,13 @@
RELEASE NOTES FOR C5 GENERIC COLLECTION LIBRARY FOR C#/CLI
------------------------------

Release 2.4.5828 of 2015-12-15

* KeyValuePair Serializable
* KeyValuePair.Create using type inference.
* Added .NET 4.5 version: IIndexed<T> implements IReadOnlyList<T>.
* Fixed typos.

Release 2.4 of 2015-12-15

* Support for Universal Windows Platform
Expand Down

0 comments on commit 8564239

Please sign in to comment.