Exemplo n.º 1
0
        public void Simple()
        {
            var associationKeyComparer = new AssociationKeyComparer <int, string>();

            var association1 = new Association <int, string>(5, "5");
            var association2 = new Association <int, string>(5, "6");
            var association3 = new Association <int, string>(3, "5");
            var association4 = new Association <int, string>(5, "5");

            Assert.AreEqual(associationKeyComparer.Compare(association1, association2), 0);
            Assert.AreEqual(associationKeyComparer.Compare(association1, association3), 1);
            Assert.AreEqual(associationKeyComparer.Compare(association1, association4), 0);

            Assert.AreEqual(associationKeyComparer.Compare(association2, association1), 0);
            Assert.AreEqual(associationKeyComparer.Compare(association3, association1), -1);
            Assert.AreEqual(associationKeyComparer.Compare(association4, association1), 0);
        }
Exemplo n.º 2
0
        public void Simple()
        {
            var associationKeyComparer = new AssociationKeyComparer<int, string>();

            var association1 = new Association<int, string>(5, "5");
            var association2 = new Association<int, string>(5, "6");
            var association3 = new Association<int, string>(3, "5");
            var association4 = new Association<int, string>(5, "5");

            Assert.AreEqual(associationKeyComparer.Compare(association1, association2), 0);
            Assert.AreEqual(associationKeyComparer.Compare(association1, association3), 1);
            Assert.AreEqual(associationKeyComparer.Compare(association1, association4), 0);

            Assert.AreEqual(associationKeyComparer.Compare(association2, association1), 0);
            Assert.AreEqual(associationKeyComparer.Compare(association3, association1), -1);
            Assert.AreEqual(associationKeyComparer.Compare(association4, association1), 0);
        }
Exemplo n.º 3
0
 /// <param name="capacity">The initial capacity of the sorted list.</param>
 /// <param name="comparer">The comparer to use.</param>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="capacity"/> is less than 0.</exception>.
 public Curve(int capacity, IComparer <TKey> comparer)
 {
     data          = new List <Association <TKey, TValue> >(capacity);
     comparerToUse = new AssociationKeyComparer <TKey, TValue>(comparer);
 }
Exemplo n.º 4
0
 /// <param name="capacity">The initial capacity of the sorted list.</param>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="capacity"/> is less than 0.</exception>.
 /// <example>
 /// <code source="..\..\Source\Examples\ExampleLibraryCSharp\DataStructures\General\SortedListExamples.cs" region="ConstructorCapacity" lang="cs" title="The following example shows how to use the constructor with an initial capacity."/>
 /// <code source="..\..\Source\Examples\ExampleLibraryVB\DataStructures\General\SortedListExamples.vb" region="ConstructorCapacity" lang="vbnet" title="The following example shows how to use the constructor with an initial capacity."/>
 /// </example>
 public Curve(int capacity)
 {
     data          = new List <Association <TKey, TValue> >(capacity);
     comparerToUse = AssociationKeyComparer <TKey, TValue> .DefaultComparer;
 }