コード例 #1
0
 private static void MTSafeInPlaceIntersectSorted(object syncObject, IntArrayList result, IntArrayList list2)
 {
     if (syncObject == null)
     {
         result.IntersectSorted(list2);
     }
     else
     {
         lock ( syncObject )
         {
             result.IntersectSorted(list2);
         }
     }
 }
コード例 #2
0
ファイル: IntArrayListTests.cs プロジェクト: mo5h/omeo
        [Test] public void SameValuesInIntersectSortedInplace()
        {
            IntArrayList list1 = new IntArrayList();

            list1.AddRange(new int[] { 0, 1, 2, 3, 3 });
            IntArrayList list2 = new IntArrayList();

            list2.AddRange(new int[] { 0, 1, 2, 3 });
            list1.IntersectSorted(list2);
            Assert.AreEqual(4, list1.Count);
            AssertEquals(0, list1[0]);
            AssertEquals(1, list1[1]);
            AssertEquals(2, list1[2]);
            AssertEquals(3, list1[3]);

            list1.Clear(); list2.Clear();
            list1.AddRange(new int[] { 3, 3 });
            list2.AddRange(new int[] { 0, 1, 2, 3 });
            list1.IntersectSorted(list2);
            Assert.AreEqual(1, list1.Count);
            AssertEquals(3, list1[0]);

            list1.Clear(); list2.Clear();
            list2.AddRange(new int[] { 3, 3 });
            list1.AddRange(new int[] { 0, 1, 2, 3 });
            list1.IntersectSorted(list2);
            Assert.AreEqual(1, list1.Count);
            AssertEquals(3, list1[0]);

            list1.Clear(); list2.Clear();
            list2.AddRange(new int[] { 0, 0, 3, 3 });
            list1.AddRange(new int[] { 0, 1, 2 });
            list1.IntersectSorted(list2);
            Assert.AreEqual(1, list1.Count);
            AssertEquals(0, list1[0]);

            list1.Clear(); list2.Clear();
            list2.AddRange(new int[] { 0, 0, 3, 3, 7, 8, 9, 12, 12, 13 });
            list1.AddRange(new int[] { 0, 1, 2, 3, 4, 5, 8, 8, 12 });
            list1.IntersectSorted(list2);
            list1 = (IntArrayList)list1.Clone();
            Assert.AreEqual(4, list1.Count);
            AssertEquals(0, list1[0]);
            AssertEquals(3, list1[1]);
            AssertEquals(8, list1[2]);
            AssertEquals(12, list1[3]);
        }
コード例 #3
0
ファイル: IntArrayListTests.cs プロジェクト: mo5h/omeo
        [Test] public void SameValuesInIntersectSorted()
        {
            IntArrayList list1 = new IntArrayList();

            list1.AddRange(new int[] { 0, 1, 2, 3, 3 });

            IntArrayList list2 = new IntArrayList();

            list2.AddRange(new int[] { 0, 1, 2, 3 });

            IntArrayList intersected = IntArrayList.IntersectSorted(list1, list2);

            Assert.AreEqual(4, intersected.Count);

            AssertEquals(0, intersected [0]);
            AssertEquals(1, intersected [1]);
            AssertEquals(2, intersected [2]);
            AssertEquals(3, intersected [3]);
        }