예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldSupportIteratingThroughResize()
        internal virtual void ShouldSupportIteratingThroughResize()
        {
            // GIVEN
            int threshold = FigureOutGrowthThreshold();
            TableGrowthAwareMonitor monitor = new TableGrowthAwareMonitor();
            PrimitiveLongSet        set     = new PrimitiveLongHashSet(new LongKeyTable <object>(DEFAULT_H, VALUE_MARKER), VALUE_MARKER, monitor);
            ISet <long>             added   = new HashSet <long>();

            for (long i = 0; i < threshold - 1; i++)
            {
                long value = i * 3;
                set.Add(value);
                added.Add(value);
            }

            // WHEN
            PrimitiveLongIterator iterator = set.GetEnumerator();
            ISet <long>           iterated = new HashSet <long>();

            for (int i = 0; i < threshold / 2; i++)
            {
                iterated.Add(iterator.Next());
            }
            assertFalse(monitor.CheckAndReset());
            // will push it over the edge, to grow the table
            set.Add((threshold - 1) * 3);
            assertTrue(monitor.CheckAndReset());
            while (iterator.HasNext())
            {
                iterated.Add(iterator.Next());
            }

            // THEN
            assertEquals(added, iterated);
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") @Override public boolean equals(Object other)
        public override bool Equals(object other)
        {
            if (TypeAndSizeEqual(other))
            {
                PrimitiveLongHashSet that     = ( PrimitiveLongHashSet )other;
                LongKeyEquality      equality = new LongKeyEquality(that);
                VisitKeys(equality);
                return(equality.Equal);
            }
            return(false);
        }
예제 #3
0
        private static int FigureOutGrowthThreshold()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicBoolean grew = new java.util.concurrent.atomic.AtomicBoolean();
            AtomicBoolean grew    = new AtomicBoolean();
            Monitor       monitor = new Monitor_AdapterAnonymousInnerClass(grew);

            using (PrimitiveLongSet set = new PrimitiveLongHashSet(new LongKeyTable <object>(DEFAULT_H, VALUE_MARKER), VALUE_MARKER, monitor))
            {
                int i = 0;
                for (i = 0; !grew.get(); i++)
                {
                    set.Add(i * 3);
                }
                return(i);
            }
        }
예제 #4
0
 internal LongKeyEquality(PrimitiveLongHashSet that)
 {
     this.Other = that;
 }