//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void getIfAbsentPut_Supplier() internal virtual void getIfAbsentPut_Supplier() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.block.function.primitive.LongFunction0 supplier = mock(org.eclipse.collections.api.block.function.primitive.LongFunction0.class); LongFunction0 supplier = mock(typeof(LongFunction0)); doReturn(10L, 11L, 12L).when(supplier).value(); assertEquals(10, _map.getIfAbsentPut(0, supplier)); assertEquals(11, _map.getIfAbsentPut(1, supplier)); assertEquals(12, _map.getIfAbsentPut(2, supplier)); verify(supplier, times(3)).value(); assertEquals(10, _map.getIfAbsentPut(0, supplier)); assertEquals(11, _map.getIfAbsentPut(1, supplier)); assertEquals(12, _map.getIfAbsentPut(2, supplier)); verifyNoMoreInteractions(supplier); }
public override long GetIfAbsentPut(long key, LongFunction0 supplier) { if (IsSentinelKey(key)) { return(GetIfAbsentPutForSentinelKey(key, supplier)); } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int idx = indexOf(key); int idx = IndexOf(key); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long keyAtIdx = getKeyAt(idx); long keyAtIdx = GetKeyAt(idx); if (keyAtIdx == key) { return(GetValueAt(idx)); } ++_modCount; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long value = supplier.value(); long value = supplier.value(); if (keyAtIdx == REMOVED_KEY) { --_removals; } SetKeyAt(idx, key); SetValueAt(idx, value); ++_entriesInMemory; if (_entriesInMemory >= _resizeOccupancyThreshold) { GrowAndRehash(); } return(value); }
private long GetIfAbsentPutForSentinelKey(long key, LongFunction0 supplier) { if (key == EMPTY_KEY) { if (!_hasZeroKey) { ++_modCount; _hasZeroKey = true; _zeroValue = supplier.value(); } return(_zeroValue); } if (key == REMOVED_KEY) { if (!_hasOneKey) { ++_modCount; _hasOneKey = true; _oneValue = supplier.value(); } return(_oneValue); } throw new AssertionError("Invalid sentinel key: " + key); }