Пример #1
0
            internal virtual ImmutableLongList GenerateCollisions(int n)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long seed = rnd.nextLong();
                long seed = outerInstance.rnd.NextLong();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.list.primitive.MutableLongList elements;
                MutableLongList elements;

                using (MutableLinearProbeLongHashSet s = new MutableLinearProbeLongHashSet(outerInstance.memoryAllocator))
                {
                    long v = s.HashAndMask(seed);
                    while (s.HashAndMask(v) != 0 || v == 0 || v == 1)
                    {
                        ++v;
                    }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int h = s.hashAndMask(v);
                    int h = s.HashAndMask(v);
                    elements = LongLists.mutable.with(v);

                    while (elements.size() < n)
                    {
                        ++v;
                        if (s.HashAndMask(v) == h)
                        {
                            elements.add(v);
                        }
                    }
                }
                return(elements.toImmutable());
            }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void rehashWhenTooManyRemovals()
        internal virtual void RehashWhenTooManyRemovals()
        {
            _set = spy(_set);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int numOfElements = DEFAULT_CAPACITY / 2;
            int numOfElements = DEFAULT_CAPACITY / 2;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int removalsToTriggerRehashing = DEFAULT_CAPACITY / REMOVALS_RATIO;
            int removalsToTriggerRehashing = DEFAULT_CAPACITY / REMOVALS_RATIO;

            for (int i = 0; i < numOfElements; i++)
            {
                assertTrue(_set.add(100 + i));
            }

            assertEquals(numOfElements, _set.size());
            verify(_set, never()).rehashWithoutGrow();
            verify(_set, never()).growAndRehash();

            for (int i = 0; i < removalsToTriggerRehashing; i++)
            {
                assertTrue(_set.remove(100 + i));
            }

            assertEquals(numOfElements - removalsToTriggerRehashing, _set.size());
            verify(_set).rehashWithoutGrow();
            verify(_set, never()).growAndRehash();
        }
Пример #3
0
        public override MutableLongSet NewLongSet()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final MutableLinearProbeLongHashSet set = new MutableLinearProbeLongHashSet(allocator);
            MutableLinearProbeLongHashSet set = new MutableLinearProbeLongHashSet(_allocator);

            _resources.Add(set);
            return(set);
        }
Пример #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void grow()
        internal virtual void Grow()
        {
            _set = spy(_set);

            for (int i = 0; i < DEFAULT_CAPACITY; i++)
            {
                assertTrue(_set.add(100 + i));
            }
            verify(_set).growAndRehash();
        }
Пример #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void freeFrozenMemory()
        internal virtual void FreeFrozenMemory()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.memory.MemoryAllocationTracker memoryTrackerSpy = spy(new org.neo4j.memory.LocalMemoryTracker());
            MemoryAllocationTracker memoryTrackerSpy = spy(new LocalMemoryTracker());
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final MutableLinearProbeLongHashSet set2 = new MutableLinearProbeLongHashSet(new OffHeapMemoryAllocator(memoryTrackerSpy, blockAllocator));
            MutableLinearProbeLongHashSet set2 = new MutableLinearProbeLongHashSet(new OffHeapMemoryAllocator(memoryTrackerSpy, _blockAllocator));

            verify(memoryTrackerSpy).allocated(anyLong());

            set2.AddAll(100, 200, 300);
            set2.Freeze();
            set2.Remove(100);
            set2.Freeze();
            set2.Clear();
            set2.Close();
            verify(memoryTrackerSpy, times(3)).deallocated(anyLong());
        }
Пример #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void testEquals()
        internal virtual void TestEquals()
        {
            _set.addAll(1, 2, 3, 100, 200, 300);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final MutableLinearProbeLongHashSet set2 = new MutableLinearProbeLongHashSet(memoryAllocator);
            MutableLinearProbeLongHashSet set2 = new MutableLinearProbeLongHashSet(_memoryAllocator);

            set2.AddAll(300, 200, 100, 3, 2, 1);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.impl.set.mutable.primitive.LongHashSet set3 = newSetWith(300, 200, 100, 3, 2, 1);
            LongHashSet set3 = newSetWith(300, 200, 100, 3, 2, 1);

            assertEquals(_set, set2);
            assertEquals(_set, set3);

            _set.removeAll(1, 100);
            assertNotEquals(_set, set2);
            assertNotEquals(_set, set3);

            set2.Close();
        }
Пример #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void allocateFreeMemory()
        internal virtual void AllocateFreeMemory()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.memory.MemoryAllocationTracker memoryTrackerSpy = spy(new org.neo4j.memory.LocalMemoryTracker());
            MemoryAllocationTracker memoryTrackerSpy = spy(new LocalMemoryTracker());
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final MutableLinearProbeLongHashSet set2 = new MutableLinearProbeLongHashSet(new OffHeapMemoryAllocator(memoryTrackerSpy, blockAllocator));
            MutableLinearProbeLongHashSet set2 = new MutableLinearProbeLongHashSet(new OffHeapMemoryAllocator(memoryTrackerSpy, _blockAllocator));

            verify(memoryTrackerSpy).allocated(anyLong());

            for (int i = 0; i < DEFAULT_CAPACITY; i++)
            {
                set2.Add(100 + i);
            }
            verify(memoryTrackerSpy).deallocated(anyLong());
            verify(memoryTrackerSpy, times(2)).allocated(anyLong());

            set2.Close();
            verify(memoryTrackerSpy, times(2)).deallocated(anyLong());
        }
Пример #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void addRemoveContains()
        internal virtual void AddRemoveContains()
        {
            _set = spy(_set);

            assertFalse(_set.contains(0));
            assertTrue(_set.add(0));
            assertTrue(_set.contains(0));
            assertFalse(_set.add(0));
            assertEquals(1, _set.size());

            assertFalse(_set.contains(1));
            assertTrue(_set.add(1));
            assertTrue(_set.contains(1));
            assertFalse(_set.add(1));
            assertEquals(2, _set.size());

            assertFalse(_set.contains(2));
            assertTrue(_set.add(2));
            assertTrue(_set.contains(2));
            assertFalse(_set.add(2));
            assertEquals(3, _set.size());

            assertFalse(_set.contains(3));
            assertFalse(_set.remove(3));
            assertEquals(3, _set.size());

            assertEquals(newSetWith(0, 1, 2), _set);

            assertTrue(_set.remove(0));
            assertFalse(_set.contains(0));
            assertEquals(2, _set.size());

            assertTrue(_set.remove(1));
            assertFalse(_set.contains(1));
            assertEquals(1, _set.size());

            assertTrue(_set.remove(2));
            assertFalse(_set.contains(2));
            assertEquals(0, _set.size());
        }
Пример #9
0
 private void InitializeInstanceFields()
 {
     _memoryAllocator = new OffHeapMemoryAllocator(_memoryTracker, _blockAllocator);
     _set             = new MutableLinearProbeLongHashSet(_memoryAllocator);
 }
Пример #10
0
 internal FrozenCopy(MutableLinearProbeLongHashSet outerInstance) : base(outerInstance)
 {
     this._outerInstance = outerInstance;
 }