コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldDeduplicateWithRandomArrays()
        internal virtual void ShouldDeduplicateWithRandomArrays()
        {
            int arrayLength = 5000;
            int iterations  = 10;

            for (int i = 0; i < iterations; i++)
            {
                long[]           array         = ThreadLocalRandom.current().longs(arrayLength, 0, arrayLength).sorted().toArray();
                long[]           dedupedActual = PrimitiveLongCollections.Deduplicate(array);
                SortedSet <long> set           = new SortedSet <long>();
                foreach (long value in array)
                {
                    set.Add(value);
                }
                long[]             dedupedExpected = new long[set.Count];
                IEnumerator <long> itr             = set.GetEnumerator();
                for (int j = 0; j < dedupedExpected.Length; j++)
                {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    assertTrue(itr.hasNext());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    dedupedExpected[j] = itr.next();
                }
                assertArrayEquals(dedupedExpected, dedupedActual);
            }
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldDeduplicate()
        internal virtual void ShouldDeduplicate()
        {
            // GIVEN
            long[] array = new long[] { 1L, 1L, 2L, 5L, 6L, 6L };

            // WHEN
            long[] deduped = PrimitiveLongCollections.Deduplicate(array);

            // THEN
            assertArrayEquals(new long[] { 1L, 2L, 5L, 6L }, deduped);
        }