_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q21800
User.addAttributes
train
public final void addAttributes(final Map<String,String> attributes) { if(attributes != null) { this.attributes.putAll(attributes); } }
java
{ "resource": "" }
q21801
WildcardMatcher.matchAny
train
public static boolean matchAny(final Collection<String> pattern, final String[] candidate, boolean ignoreCase) { for (String string: pattern) { if (matchAny(string, candidate, ignoreCase)) { return true; } } return false; }
java
{ "resource": "" }
q21802
WildcardMatcher.matchAny
train
public static boolean matchAny(final String pattern, final String[] candidate, boolean ignoreCase) { for (int i = 0; i < candidate.length; i++) { final String string = candidate[i]; if (match(pattern, string, ignoreCase)) { return true; } } r...
java
{ "resource": "" }
q21803
SgUtils.forEN
train
private static Locale forEN() { if ("en".equalsIgnoreCase(Locale.getDefault().getLanguage())) { return Locale.getDefault(); } Locale[] locales = Locale.getAvailableLocales(); for (int i = 0; i != locales.length; i++) { if ("en".equalsIgnoreCas...
java
{ "resource": "" }
q21804
RemoteIpDetector.commaDelimitedListToStringArray
train
protected static String[] commaDelimitedListToStringArray(String commaDelimitedStrings) { return (commaDelimitedStrings == null || commaDelimitedStrings.length() == 0) ? new String[0] : commaSeparatedValuesPattern .split(commaDelimitedStrings); }
java
{ "resource": "" }
q21805
RemoteIpDetector.listToCommaDelimitedString
train
protected static String listToCommaDelimitedString(List<String> stringList) { if (stringList == null) { return ""; } StringBuilder result = new StringBuilder(); for (Iterator<String> it = stringList.iterator(); it.hasNext();) { Object element = it.next(); ...
java
{ "resource": "" }
q21806
LicenseHelper.validateLicense
train
public static String validateLicense(String licenseText) throws PGPException { licenseText = licenseText.trim().replaceAll("\\r|\\n", ""); licenseText = licenseText.replace("---- SCHNIPP (Armored PGP signed JSON as base64) ----",""); licenseText = licenseText.replace("---- SCHNAPP ----",""...
java
{ "resource": "" }
q21807
ComplianceConfig.writeHistoryEnabledForIndex
train
public boolean writeHistoryEnabledForIndex(String index) { if(index == null) { return false; } if(searchguardIndex.equals(index)) { return logInternalConfig; } if(auditLogIndex != null && auditLogIndex.equalsIgnoreCase(index)) { retu...
java
{ "resource": "" }
q21808
SqlRetryPolicy.getSqlRetryAbleExceptions
train
private static Map<Class<? extends Throwable>, Boolean> getSqlRetryAbleExceptions() { Map<Class<? extends Throwable>, Boolean> retryableExceptions = new HashMap<>(); retryableExceptions.put(SQLTransientException.class, true); retryableExceptions.put(SQLRecoverableException.class, true); retryableExceptions.put(...
java
{ "resource": "" }
q21809
AmazonRdsDataSourceFactoryBean.createDataSourceInstance
train
protected DataSource createDataSourceInstance(String identifier) throws Exception { DBInstance instance = getDbInstance(identifier); return this.dataSourceFactory.createDataSource(fromRdsInstance(instance)); }
java
{ "resource": "" }
q21810
StackResourceRegistryDetectingResourceIdResolver.resolveToPhysicalResourceId
train
@Override public String resolveToPhysicalResourceId(String logicalResourceId) { if (this.stackResourceRegistry != null) { String physicalResourceId = this.stackResourceRegistry .lookupPhysicalResourceId(logicalResourceId); if (physicalResourceId != null) { return physicalResourceId; } } retur...
java
{ "resource": "" }
q21811
AmazonRdsDataSourceUserTagsFactoryBean.getDbInstanceResourceName
train
private String getDbInstanceResourceName() { String userArn = this.identityManagement.getUser().getUser().getArn(); AmazonResourceName userResourceName = AmazonResourceName.fromString(userArn); AmazonResourceName dbResourceArn = new AmazonResourceName.Builder() .withService("rds").withRegion(getRegion()) ...
java
{ "resource": "" }
q21812
ContextCredentialsBeanDefinitionParser.getCredentials
train
private static BeanDefinition getCredentials(Element credentialsProviderElement, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder .rootBeanDefinition("com.amazonaws.auth.BasicAWSCredentials"); builder.addConstructorArgValue(getAttributeValue(ACCESS_KEY_ATTRIBUTE_NAME, ...
java
{ "resource": "" }
q21813
MapBasedDatabasePlatformSupport.getDriverClassNameForDatabase
train
@Override public String getDriverClassNameForDatabase(DatabaseType databaseType) { Assert.notNull(databaseType, "databaseType must not be null"); String candidate = this.getDriverClassNameMappings().get(databaseType); Assert.notNull(candidate, String.format( "No driver class name found for database :'%s'", d...
java
{ "resource": "" }
q21814
CopyBroadcastReceiver.receive
train
public int receive(final MessageHandler handler) { int messagesReceived = 0; final BroadcastReceiver receiver = this.receiver; final long lastSeenLappedCount = receiver.lappedCount(); if (receiver.receiveNext()) { if (lastSeenLappedCount != receiver.lappedCount()...
java
{ "resource": "" }
q21815
Strings.parseIntOrDefault
train
public static int parseIntOrDefault(final String value, final int defaultValue) { if (null == value) { return defaultValue; } return Integer.parseInt(value); }
java
{ "resource": "" }
q21816
HighResolutionClock.epochMicros
train
public static long epochMicros() { final Instant now = Instant.now(); final long seconds = now.getEpochSecond(); final long nanosFromSecond = now.getNano(); return (seconds * 1_000_000) + (nanosFromSecond / 1_000); }
java
{ "resource": "" }
q21817
HighResolutionClock.epochNanos
train
public static long epochNanos() { final Instant now = Instant.now(); final long seconds = now.getEpochSecond(); final long nanosFromSecond = now.getNano(); return (seconds * 1_000_000_000) + nanosFromSecond; }
java
{ "resource": "" }
q21818
References.isReferringTo
train
public static <T> boolean isReferringTo(final Reference<T> ref, final T obj) { return ref.get() == obj; }
java
{ "resource": "" }
q21819
SystemUtil.isDebuggerAttached
train
public static boolean isDebuggerAttached() { final RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean(); for (final String arg : runtimeMXBean.getInputArguments()) { if (arg.contains("-agentlib:jdwp")) { return true; } ...
java
{ "resource": "" }
q21820
SystemUtil.threadDump
train
public static String threadDump() { final StringBuilder sb = new StringBuilder(); final ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean(); for (final ThreadInfo info : threadMXBean.getThreadInfo(threadMXBean.getAllThreadIds(), Integer.MAX_VALUE)) { sb.appen...
java
{ "resource": "" }
q21821
SystemUtil.getSizeAsInt
train
public static int getSizeAsInt(final String propertyName, final int defaultValue) { final String propertyValue = getProperty(propertyName); if (propertyValue != null) { final long value = parseSize(propertyName, propertyValue); if (value < 0 || value > Integer.MAX_VAL...
java
{ "resource": "" }
q21822
SystemUtil.getSizeAsLong
train
public static long getSizeAsLong(final String propertyName, final long defaultValue) { final String propertyValue = getProperty(propertyName); if (propertyValue != null) { final long value = parseSize(propertyName, propertyValue); if (value < 0) { ...
java
{ "resource": "" }
q21823
SystemUtil.parseSize
train
public static long parseSize(final String propertyName, final String propertyValue) { final int lengthMinusSuffix = propertyValue.length() - 1; final char lastCharacter = propertyValue.charAt(lengthMinusSuffix); if (Character.isDigit(lastCharacter)) { return Long.valueOf(...
java
{ "resource": "" }
q21824
IoUtil.fill
train
public static void fill(final FileChannel fileChannel, final long position, final long length, final byte value) { try { final byte[] filler; if (0 != value) { filler = new byte[BLOCK_SIZE]; Arrays.fill(filler, value); }...
java
{ "resource": "" }
q21825
IoUtil.delete
train
public static void delete(final File file, final boolean ignoreFailures) { if (file.isDirectory()) { final File[] files = file.listFiles(); if (null != files) { for (final File f : files) { delete(f, ignoreFailur...
java
{ "resource": "" }
q21826
IoUtil.ensureDirectoryExists
train
public static void ensureDirectoryExists(final File directory, final String descriptionLabel) { if (!directory.exists()) { if (!directory.mkdirs()) { throw new IllegalArgumentException("could not create " + descriptionLabel + " directory: " + directory); ...
java
{ "resource": "" }
q21827
IoUtil.deleteIfExists
train
public static void deleteIfExists(final File file) { if (file.exists()) { try { Files.delete(file.toPath()); } catch (final IOException ex) { LangUtil.rethrowUnchecked(ex); } } }
java
{ "resource": "" }
q21828
IoUtil.checkFileExists
train
public static void checkFileExists(final File file, final String name) { if (!file.exists()) { final String msg = "missing file for " + name + " : " + file.getAbsolutePath(); throw new IllegalStateException(msg); } }
java
{ "resource": "" }
q21829
IoUtil.map
train
public static long map( final FileChannel fileChannel, final FileChannel.MapMode mode, final long offset, final long length) { try { return (long)MappingMethods.MAP_ADDRESS.invoke(fileChannel, getMode(mode), offset, length); } catch (final IllegalAccessException |...
java
{ "resource": "" }
q21830
IoUtil.unmap
train
public static void unmap(final FileChannel fileChannel, final long address, final long length) { try { MappingMethods.UNMAP_ADDRESS.invoke(fileChannel, address, length); } catch (final IllegalAccessException | InvocationTargetException ex) { LangUtil.r...
java
{ "resource": "" }
q21831
CountersManager.allocate
train
public int allocate(final String label, final int typeId) { final int counterId = nextCounterId(); checkCountersCapacity(counterId); final int recordOffset = metaDataOffset(counterId); checkMetaDataCapacity(recordOffset); try { metaDataBuffer.putInt(reco...
java
{ "resource": "" }
q21832
CountersManager.free
train
public void free(final int counterId) { final int recordOffset = metaDataOffset(counterId); metaDataBuffer.putLong( recordOffset + FREE_FOR_REUSE_DEADLINE_OFFSET, epochClock.time() + freeToReuseTimeoutMs); metaDataBuffer.putIntOrdered(recordOffset, RECORD_RECLAIMED); fre...
java
{ "resource": "" }
q21833
BitUtil.fromHexByteArray
train
public static byte[] fromHexByteArray(final byte[] buffer) { final byte[] outputBuffer = new byte[buffer.length >> 1]; for (int i = 0; i < buffer.length; i += 2) { final int hi = FROM_HEX_DIGIT_TABLE[buffer[i]] << 4; final int lo = FROM_HEX_DIGIT_TABLE[buffer[i + 1]]...
java
{ "resource": "" }
q21834
BitUtil.toHexByteArray
train
public static byte[] toHexByteArray(final byte[] buffer, final int offset, final int length) { final byte[] outputBuffer = new byte[length << 1]; for (int i = 0; i < (length << 1); i += 2) { final byte b = buffer[offset + (i >> 1)]; outputBuffer[i] = HEX_DIGIT_TABLE...
java
{ "resource": "" }
q21835
BitUtil.toHex
train
public static String toHex(final byte[] buffer, final int offset, final int length) { return new String(toHexByteArray(buffer, offset, length), UTF_8); }
java
{ "resource": "" }
q21836
BitUtil.isAligned
train
public static boolean isAligned(final long address, final int alignment) { if (!BitUtil.isPowerOfTwo(alignment)) { throw new IllegalArgumentException("alignment must be a power of 2: alignment=" + alignment); } return (address & (alignment - 1)) == 0; }
java
{ "resource": "" }
q21837
AtomicCounter.incrementOrdered
train
public long incrementOrdered() { final long currentValue = UnsafeAccess.UNSAFE.getLong(byteArray, addressOffset); UnsafeAccess.UNSAFE.putOrderedLong(byteArray, addressOffset, currentValue + 1); return currentValue; }
java
{ "resource": "" }
q21838
AtomicCounter.getAndAddOrdered
train
public long getAndAddOrdered(final long increment) { final long currentValue = UnsafeAccess.UNSAFE.getLong(byteArray, addressOffset); UnsafeAccess.UNSAFE.putOrderedLong(byteArray, addressOffset, currentValue + increment); return currentValue; }
java
{ "resource": "" }
q21839
AtomicCounter.compareAndSet
train
public boolean compareAndSet(final long expectedValue, final long updateValue) { return UnsafeAccess.UNSAFE.compareAndSwapLong(byteArray, addressOffset, expectedValue, updateValue); }
java
{ "resource": "" }
q21840
CollectionUtil.getOrDefault
train
public static <K, V> V getOrDefault(final Map<K, V> map, final K key, final Function<K, V> supplier) { V value = map.get(key); if (value == null) { value = supplier.apply(key); map.put(key, value); } return value; }
java
{ "resource": "" }
q21841
MappedResizeableBuffer.wrap
train
public void wrap(final long offset, final long length) { if (offset == addressOffset && length == capacity) { return; } wrap(fileChannel, offset, length); }
java
{ "resource": "" }
q21842
MappedResizeableBuffer.wrap
train
public void wrap(final FileChannel fileChannel, final long offset, final long length) { unmap(); this.fileChannel = fileChannel; map(offset, length); }
java
{ "resource": "" }
q21843
MappedResizeableBuffer.wrap
train
public void wrap( final FileChannel fileChannel, final FileChannel.MapMode mapMode, final long offset, final long length) { unmap(); this.fileChannel = fileChannel; this.mapMode = mapMode; map(offset, length); }
java
{ "resource": "" }
q21844
DistinctErrorLog.record
train
public boolean record(final Throwable observation) { final long timestamp = clock.time(); DistinctObservation distinctObservation; synchronized (this) { distinctObservation = find(distinctObservations, observation); if (null == distinctObservation) ...
java
{ "resource": "" }
q21845
CountersReader.forEach
train
public void forEach(final IntObjConsumer<String> consumer) { int counterId = 0; final AtomicBuffer metaDataBuffer = this.metaDataBuffer; for (int i = 0, capacity = metaDataBuffer.capacity(); i < capacity; i += METADATA_LENGTH) { final int recordStatus = metaDataBuffer.ge...
java
{ "resource": "" }
q21846
CountersReader.forEach
train
public void forEach(final CounterConsumer consumer) { int counterId = 0; final AtomicBuffer metaDataBuffer = this.metaDataBuffer; final AtomicBuffer valuesBuffer = this.valuesBuffer; for (int i = 0, capacity = metaDataBuffer.capacity(); i < capacity; i += METADATA_LENGTH) {...
java
{ "resource": "" }
q21847
CountersReader.forEach
train
public void forEach(final MetaData metaData) { int counterId = 0; final AtomicBuffer metaDataBuffer = this.metaDataBuffer; for (int i = 0, capacity = metaDataBuffer.capacity(); i < capacity; i += METADATA_LENGTH) { final int recordStatus = metaDataBuffer.getIntVolatile(...
java
{ "resource": "" }
q21848
ExpandableDirectBufferOutputStream.wrap
train
public void wrap(final MutableDirectBuffer buffer, final int offset) { Objects.requireNonNull(buffer, "Buffer must not be null"); if (!buffer.isExpandable()) { throw new IllegalStateException("buffer must be expandable."); } this.buffer = buffer; this.off...
java
{ "resource": "" }
q21849
Verify.present
train
public static void present(final Map<?, ?> map, final Object key, final String name) { if (null == map.get(key)) { throw new IllegalStateException(name + " not found in map for key: " + key); } }
java
{ "resource": "" }
q21850
BufferUtil.address
train
public static long address(final ByteBuffer buffer) { if (!buffer.isDirect()) { throw new IllegalArgumentException("buffer.isDirect() must be true"); } return UNSAFE.getLong(buffer, BYTE_BUFFER_ADDRESS_FIELD_OFFSET); }
java
{ "resource": "" }
q21851
TransportPoller.close
train
public void close() { selector.wakeup(); try { selector.close(); } catch (final IOException ex) { LangUtil.rethrowUnchecked(ex); } }
java
{ "resource": "" }
q21852
TransportPoller.selectNowWithoutProcessing
train
public void selectNowWithoutProcessing() { try { selector.selectNow(); selectedKeySet.reset(); } catch (final IOException ex) { LangUtil.rethrowUnchecked(ex); } }
java
{ "resource": "" }
q21853
ArrayUtil.add
train
public static <T> T[] add(final T[] oldElements, final T elementToAdd) { final int length = oldElements.length; final T[] newElements = Arrays.copyOf(oldElements, length + 1); newElements[length] = elementToAdd; return newElements; }
java
{ "resource": "" }
q21854
ArrayUtil.newArray
train
@SuppressWarnings("unchecked") public static <T> T[] newArray(final T[] oldElements, final int length) { return (T[])Array.newInstance(oldElements.getClass().getComponentType(), length); }
java
{ "resource": "" }
q21855
ArrayUtil.ensureCapacity
train
public static <T> T[] ensureCapacity(final T[] oldElements, final int requiredLength) { T[] result = oldElements; if (oldElements.length < requiredLength) { result = Arrays.copyOf(oldElements, requiredLength); } return result; }
java
{ "resource": "" }
q21856
Object2ObjectHashMap.put
train
public V put(final Object key, final Object value) { final Object val = mapNullValue(value); requireNonNull(val, "value cannot be null"); final Object[] entries = this.entries; final int mask = entries.length - 1; int index = Hashing.evenHash(key.hashCode(), mask); O...
java
{ "resource": "" }
q21857
AgentRunner.startOnThread
train
public static Thread startOnThread(final AgentRunner runner, final ThreadFactory threadFactory) { final Thread thread = threadFactory.newThread(runner); thread.setName(runner.agent().roleName()); thread.start(); return thread; }
java
{ "resource": "" }
q21858
BroadcastBufferDescriptor.checkCapacity
train
public static void checkCapacity(final int capacity) { if (!BitUtil.isPowerOfTwo(capacity)) { final String msg = "capacity must be a positive power of 2 + TRAILER_LENGTH: capacity=" + capacity; throw new IllegalStateException(msg); } }
java
{ "resource": "" }
q21859
DirectBufferOutputStream.write
train
public void write(final int b) { if (position == length) { throw new IllegalStateException("position has reached the end of underlying buffer"); } buffer.putByte(offset + position, (byte)b); ++position; }
java
{ "resource": "" }
q21860
DeadlineTimerWheel.cancelTimer
train
public boolean cancelTimer(final long timerId) { final int wheelIndex = tickForTimerId(timerId); final int arrayIndex = indexInTickArray(timerId); if (wheelIndex < wheel.length) { final long[] array = wheel[wheelIndex]; if (arrayIndex < array.length && NULL_...
java
{ "resource": "" }
q21861
DeadlineTimerWheel.poll
train
public int poll(final long now, final TimerHandler handler, final int maxTimersToExpire) { int timersExpired = 0; if (timerCount > 0) { final long[] array = wheel[currentTick & wheelMask]; for (int i = 0, length = array.length; i < length && maxTimersToExpire > time...
java
{ "resource": "" }
q21862
DeadlineTimerWheel.forEach
train
public void forEach(final TimerConsumer consumer) { long numTimersLeft = timerCount; for (int j = currentTick, end = currentTick + wheel.length; j <= end; j++) { final long[] array = wheel[j & wheelMask]; for (int i = 0, length = array.length; i < length; i++) ...
java
{ "resource": "" }
q21863
DeadlineTimerWheel.deadline
train
public long deadline(final long timerId) { final int wheelIndex = tickForTimerId(timerId); final int arrayIndex = indexInTickArray(timerId); if (wheelIndex < wheel.length) { final long[] array = wheel[wheelIndex]; if (arrayIndex < array.length) {...
java
{ "resource": "" }
q21864
AsciiSequenceView.wrap
train
public AsciiSequenceView wrap(final DirectBuffer buffer, final int offset, final int length) { this.buffer = buffer; this.offset = offset; this.length = length; return this; }
java
{ "resource": "" }
q21865
Hashing.hash
train
public static <K> int hash(final K value, final int mask) { final int hash = value.hashCode(); return hash & mask; }
java
{ "resource": "" }
q21866
Hashing.hash
train
public static int hash(final long value, final int mask) { long hash = value * 31; hash = (int)hash ^ (int)(hash >>> 32); return (int)hash & mask; }
java
{ "resource": "" }
q21867
Hashing.evenHash
train
public static int evenHash(final long value, final int mask) { int hash = (int)value ^ (int)(value >>> 32); hash = (hash << 1) - (hash << 8); return hash & mask; }
java
{ "resource": "" }
q21868
RecordBuffer.forEach
train
public void forEach(final RecordHandler handler) { int offset = endOfPositionField; final int position = position(); while (offset < position) { if (statusVolatile(offset) == COMMITTED) { final int key = key(offset); handler.on...
java
{ "resource": "" }
q21869
RecordBuffer.get
train
public int get(final int key) { int offset = endOfPositionField; final int position = position(); while (offset < position) { if (statusVolatile(offset) == COMMITTED && key == key(offset)) { return offset + SIZE_OF_RECORD_FRAME; } ...
java
{ "resource": "" }
q21870
RecordBuffer.withRecord
train
public boolean withRecord(final int key, final RecordWriter writer) { final int claimedOffset = claimRecord(key); if (claimedOffset == DID_NOT_CLAIM_RECORD) { return false; } try { writer.writeRecord(claimedOffset); } finally ...
java
{ "resource": "" }
q21871
RecordBuffer.claimRecord
train
public int claimRecord(final int key) { int offset = endOfPositionField; while (offset < position()) { if (key == key(offset)) { // If someone else is writing something with the same key then abort if (statusVolatile(offset) == PENDING...
java
{ "resource": "" }
q21872
SemanticVersion.compose
train
public static int compose(final int major, final int minor, final int patch) { if (major < 0 || major > 255) { throw new IllegalArgumentException("major must be 0-255: " + major); } if (minor < 0 || minor > 255) { throw new IllegalArgumentException("m...
java
{ "resource": "" }
q21873
NioSelectedKeySet.forEach
train
public int forEach(final ToIntFunction<SelectionKey> function) { int handledFrames = 0; final SelectionKey[] keys = this.keys; for (int i = size - 1; i >= 0; i--) { handledFrames += function.applyAsInt(keys[i]); } size = 0; return handledFrames;...
java
{ "resource": "" }
q21874
BiInt2ObjectMap.compact
train
public void compact() { final int idealCapacity = (int)Math.round(size() * (1.0 / loadFactor)); rehash(findNextPositivePowerOfTwo(Math.max(MIN_CAPACITY, idealCapacity))); }
java
{ "resource": "" }
q21875
ContinueBarrier.await
train
public boolean await() { System.out.format("%n%s (y/n): ", label).flush(); final Scanner in = new Scanner(System.in); final String line = in.nextLine(); return "y".equalsIgnoreCase(line); }
java
{ "resource": "" }
q21876
IntArrayList.addInt
train
public void addInt( @DoNotSub final int index, final int element) { checkIndexForAdd(index); @DoNotSub final int requiredSize = size + 1; ensureCapacityPrivate(requiredSize); if (index < size) { System.arraycopy(elements, index, elements, index +...
java
{ "resource": "" }
q21877
IntArrayList.setInt
train
public int setInt( @DoNotSub final int index, final int element) { checkIndex(index); final int previous = elements[index]; elements[index] = element; return previous; }
java
{ "resource": "" }
q21878
IntArrayList.remove
train
public Integer remove( @DoNotSub final int index) { checkIndex(index); final int value = elements[index]; @DoNotSub final int moveCount = size - index - 1; if (moveCount > 0) { System.arraycopy(elements, index + 1, elements, index, moveCount); } ...
java
{ "resource": "" }
q21879
IntArrayList.fastUnorderedRemove
train
public int fastUnorderedRemove( @DoNotSub final int index) { checkIndex(index); final int value = elements[index]; elements[index] = elements[--size]; return value; }
java
{ "resource": "" }
q21880
IntArrayList.removeInt
train
public boolean removeInt(final int value) { @DoNotSub final int index = indexOf(value); if (-1 != index) { remove(index); return true; } return false; }
java
{ "resource": "" }
q21881
IntArrayList.fastUnorderedRemoveInt
train
public boolean fastUnorderedRemoveInt(final int value) { @DoNotSub final int index = indexOf(value); if (-1 != index) { elements[index] = elements[--size]; return true; } return false; }
java
{ "resource": "" }
q21882
IntArrayList.toIntArray
train
public int[] toIntArray(final int[] dst) { if (dst.length == size) { System.arraycopy(elements, 0, dst, 0, dst.length); return dst; } else { return Arrays.copyOf(elements, size); } }
java
{ "resource": "" }
q21883
ErrorLogReader.read
train
public static int read(final AtomicBuffer buffer, final ErrorConsumer consumer, final long sinceTimestamp) { int entries = 0; int offset = 0; final int capacity = buffer.capacity(); while (offset < capacity) { final int length = buffer.getIntVolatile(offset + LEN...
java
{ "resource": "" }
q21884
ArrayListUtil.fastUnorderedRemove
train
public static <T> void fastUnorderedRemove(final ArrayList<T> list, final int index) { final int lastIndex = list.size() - 1; if (index != lastIndex) { list.set(index, list.remove(lastIndex)); } else { list.remove(index); } }
java
{ "resource": "" }
q21885
ArrayListUtil.fastUnorderedRemove
train
public static <T> boolean fastUnorderedRemove(final ArrayList<T> list, final T e) { for (int i = 0, size = list.size(); i < size; i++) { if (e == list.get(i)) { fastUnorderedRemove(list, i, size - 1); return true; } } ...
java
{ "resource": "" }
q21886
HighResolutionTimer.enable
train
public static synchronized void enable() { if (null != thread) { thread = new Thread(HighResolutionTimer::run); thread.setDaemon(true); thread.setName("high-resolution-timer-hack"); thread.start(); } }
java
{ "resource": "" }
q21887
GeoQuery.addGeoQueryDataEventListener
train
public synchronized void addGeoQueryDataEventListener(final GeoQueryDataEventListener listener) { if (eventListeners.contains(listener)) { throw new IllegalArgumentException("Added the same listener twice to a GeoQuery!"); } eventListeners.add(listener); if (this.queries == n...
java
{ "resource": "" }
q21888
GeoQuery.removeGeoQueryEventListener
train
public synchronized void removeGeoQueryEventListener(final GeoQueryDataEventListener listener) { if (!eventListeners.contains(listener)) { throw new IllegalArgumentException("Trying to remove listener that was removed or not added!"); } eventListeners.remove(listener); if (!t...
java
{ "resource": "" }
q21889
GeoFire.setLocation
train
public void setLocation(final String key, final GeoLocation location, final CompletionListener completionListener) { if (key == null) { throw new NullPointerException(); } DatabaseReference keyRef = this.getDatabaseRefForKey(key); GeoHash geoHash = new GeoHash(location); ...
java
{ "resource": "" }
q21890
GeoFire.removeLocation
train
public void removeLocation(final String key, final CompletionListener completionListener) { if (key == null) { throw new NullPointerException(); } DatabaseReference keyRef = this.getDatabaseRefForKey(key); if (completionListener != null) { keyRef.setValue(null, ne...
java
{ "resource": "" }
q21891
GeoFire.getLocation
train
public void getLocation(String key, LocationCallback callback) { DatabaseReference keyRef = this.getDatabaseRefForKey(key); LocationValueEventListener valueListener = new LocationValueEventListener(callback); keyRef.addListenerForSingleValueEvent(valueListener); }
java
{ "resource": "" }
q21892
SFVehiclesActivity.animateMarkerTo
train
private void animateMarkerTo(final Marker marker, final double lat, final double lng) { final Handler handler = new Handler(); final long start = SystemClock.uptimeMillis(); final long DURATION_MS = 3000; final Interpolator interpolator = new AccelerateDecelerateInterpolator(); f...
java
{ "resource": "" }
q21893
Modules.loadModules
train
public static Map<ModuleAdapter<?>, Object> loadModules(Loader loader, Object[] seedModulesOrClasses) { Map<ModuleAdapter<?>, Object> seedAdapters = new LinkedHashMap<ModuleAdapter<?>, Object>(seedModulesOrClasses.length); for (int i = 0; i < seedModulesOrClasses.length; i++) { if (seedModul...
java
{ "resource": "" }
q21894
Linker.linkRequested
train
public void linkRequested() { assertLockHeld(); Binding<?> binding; while ((binding = toLink.poll()) != null) { if (binding instanceof DeferredBinding) { DeferredBinding deferred = (DeferredBinding) binding; String key = deferred.deferredKey; boolean mustHaveInjections = deferr...
java
{ "resource": "" }
q21895
AdapterJavadocs.bindingTypeDocs
train
static CodeBlock bindingTypeDocs( TypeName type, boolean abstrakt, boolean members, boolean dependent) { CodeBlock.Builder result = CodeBlock.builder() .add("A {@code Binding<$T>} implementation which satisfies\n", type) .add("Dagger's infrastructure requirements including:\n"); if (depend...
java
{ "resource": "" }
q21896
ArrayQueue.add
train
@Override public boolean add(E e) { if (e == null) throw new NullPointerException("e == null"); elements[tail] = e; if ((tail = (tail + 1) & (elements.length - 1)) == head) doubleCapacity(); return true; }
java
{ "resource": "" }
q21897
ArrayQueue.remove
train
@Override public E remove() { E x = poll(); if (x == null) throw new NoSuchElementException(); return x; }
java
{ "resource": "" }
q21898
ArrayQueue.delete
train
private boolean delete(int i) { //checkInvariants(); final Object[] elements = this.elements; final int mask = elements.length - 1; final int h = head; final int t = tail; final int front = (i - h) & mask; final int back = (t - i) & mask; // Invariant: h...
java
{ "resource": "" }
q21899
ArrayQueue.writeObject
train
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { s.defaultWriteObject(); // Write out size s.writeInt(size()); // Write out elements in order. int mask = elements.length - 1; for (int i = head; i != tail; i = (i + 1) & mask...
java
{ "resource": "" }