Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void convertCollectionToLongArray()
        internal virtual void ConvertCollectionToLongArray()
        {
            PrimitiveIntSet heapSet       = PrimitiveIntCollections.AsSet(new int[] { 1, 2, 3 });
            PrimitiveIntSet offHeapIntSet = Primitive.OffHeapIntSet(GlobalMemoryTracker.INSTANCE);

            offHeapIntSet.Add(7);
            offHeapIntSet.Add(8);
            assertArrayEquals(new long[] { 1, 2, 3 }, PrimitiveIntCollections.AsLongArray(heapSet));
            assertArrayEquals(new long[] { 7, 8 }, PrimitiveIntCollections.AsLongArray(offHeapIntSet));
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void intVisitorShouldNotSeeEntriesAfterRequestingBreakOut()
        internal virtual void IntVisitorShouldNotSeeEntriesAfterRequestingBreakOut()
        {
            // GIVEN
            PrimitiveIntSet map = Primitive.intSet();

            map.Add(1);
            map.Add(2);
            map.Add(3);
            map.Add(4);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicInteger counter = new java.util.concurrent.atomic.AtomicInteger();
            AtomicInteger counter = new AtomicInteger();

            // WHEN
            map.VisitKeys(value => counter.incrementAndGet() > 2);

            // THEN
            assertThat(counter.get(), @is(3));
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") @Test void intVisitorShouldSeeAllEntriesIfItDoesNotBreakOut()
        internal virtual void IntVisitorShouldSeeAllEntriesIfItDoesNotBreakOut()
        {
            // GIVEN
            PrimitiveIntSet set = Primitive.intSet();

            set.Add(1);
            set.Add(2);
            set.Add(3);
            PrimitiveIntVisitor <Exception> visitor = mock(typeof(PrimitiveIntVisitor));

            // WHEN
            set.VisitKeys(visitor);

            // THEN
            verify(visitor).visited(1);
            verify(visitor).visited(2);
            verify(visitor).visited(3);
            verifyNoMoreInteractions(visitor);
        }
Ejemplo n.º 4
0
        public static PrimitiveIntSet AsSet(long[] values, System.Func <long, int> converter)
        {
            PrimitiveIntSet set = Primitive.IntSet(values.Length);

            foreach (long value in values)
            {
                set.Add(converter(value));
            }
            return(set);
        }
Ejemplo n.º 5
0
        public static PrimitiveIntSet AsSet(int[] values)
        {
            PrimitiveIntSet set = Primitive.IntSet(values.Length);

            foreach (int value in values)
            {
                set.Add(value);
            }
            return(set);
        }
Ejemplo n.º 6
0
        public static PrimitiveIntSet AsSet(PrimitiveIntIterator iterator)
        {
            PrimitiveIntSet set = Primitive.IntSet();

            while (iterator.HasNext())
            {
                int next = iterator.Next();
                if (!set.Add(next))
                {
                    throw new System.InvalidOperationException("Duplicate " + next + " from " + iterator);
                }
            }
            return(set);
        }
Ejemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void trackPrimitiveMemoryOnResize()
        internal virtual void TrackPrimitiveMemoryOnResize()
        {
            LocalMemoryTracker memoryTracker = new LocalMemoryTracker();
            PrimitiveIntSet    offHeapIntSet = Primitive.OffHeapIntSet(memoryTracker);
            long originalSetMemory           = memoryTracker.UsedDirectMemory();

            for (int i = 0; i < Primitive.DefaultOffheapCapacity + 1; i++)
            {
                offHeapIntSet.Add(i);
            }

            assertTrue(memoryTracker.UsedDirectMemory() > originalSetMemory);

            offHeapIntSet.Close();
            assertEquals(0, memoryTracker.UsedDirectMemory());
        }
Ejemplo n.º 8
0
 public void add(PrimitiveIntSet coll)
 {
     coll.Add(x);
 }