public override void Each(LongProcedure procedure)
        {
            if (_hasZeroKey)
            {
                procedure.value(0);
            }
            if (_hasOneKey)
            {
                procedure.value(1);
            }

            int left = _entriesInMemory;

            for (int i = 0; i < _capacity && left > 0; i++)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long key = getKeyAt(i);
                long key = GetKeyAt(i);
                if (!IsSentinelKey(key))
                {
                    procedure.value(key);
                    --left;
                }
            }
        }
        public override void Each(LongProcedure procedure)
        {
            if (HasZero)
            {
                procedure.accept(0);
            }
            if (HasOne)
            {
                procedure.accept(1);
            }

            int visited = 0;

            for (int i = 0; i < Capacity && visited < ElementsInMemory; i++)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long value = valueAt(i);
                long value = ValueAt(i);
                if (IsRealValue(value))
                {
                    procedure.accept(value);
                    ++visited;
                }
            }
        }
Example #3
0
 /// <summary>
 /// Applies a procedure to each element of the receiver, if any.
 /// Starts at index 0, moving rightwards.
 /// <summary>
 /// <param name="procedure">   the procedure to be appliedd Stops iteration if the procedure returns <i>false</i>, otherwise continuesd</param>
 /// <returns><i>false</i> if the procedure stopped before all elements where iterated over, <i>true</i> otherwised</returns>
 public virtual Boolean ForEach(LongProcedure procedure)
 {
     for (int i = 0; i < _size;)
     {
         if (!procedure(Get(i++)))
         {
             return(false);
         }
     }
     return(true);
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void forEachValue()
        internal virtual void ForEachValue()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.collections.api.block.procedure.primitive.LongProcedure consumer = mock(org.eclipse.collections.api.block.procedure.primitive.LongProcedure.class);
            LongProcedure consumer = mock(typeof(LongProcedure));

            _map.putAll(newWithKeysValues(0, 10, 1, 11, 2, 12));

            _map.forEachValue(consumer);

            verify(consumer).value(eq(10L));
            verify(consumer).value(eq(11L));
            verify(consumer).value(eq(12L));
            verifyNoMoreInteractions(consumer);
        }
Example #5
0
        /// <summary>
        /// Applies a procedure to each element of the receiver, if any.
        /// Starts at index 0, moving rightwards.
        /// <summary>
        /// <param name="procedure">   the procedure to be appliedd Stops iteration if the procedure returns <i>false</i>, otherwise continuesd</param>
        /// <returns><i>false</i> if the procedure stopped before all elements where iterated over, <i>true</i> otherwised</returns>
        public override Boolean ForEach(LongProcedure procedure)
        {
            // overridden for performance only.
            var theElements = _elements;
            int theSize     = Size;

            for (int i = 0; i < theSize;)
            {
                if (!procedure(theElements[i++]))
                {
                    return(false);
                }
            }
            return(true);
        }
 public override void ForEach(LongProcedure procedure)
 {
     Each(procedure);
 }
Example #7
0
 public override MutableLongSet Tap(LongProcedure procedure)
 {
     Each(procedure);
     return(this);
 }
 public override void ForEachValue(LongProcedure procedure)
 {
     ForEachKeyValue((key, value) => procedure.value(value));
 }