Refine search
public Node getNode(Split split) { int bucket = splitToBucket.applyAsInt(split); int partition = bucketToPartition[bucket]; return requireNonNull(partitionToNode.get(partition)); }
@Override public int size() { return sizeFn.applyAsInt(null); }
static <T> int linearSearch(LinearSeq<T> seq, ToIntFunction<T> comparison) { int idx = 0; for (T current : seq) { final int cmp = comparison.applyAsInt(current); if (cmp == 0) { return idx; } else if (cmp < 0) { return -(idx + 1); } idx += 1; } return -(idx + 1); } }
/** {@inheritDoc} */ @Override public int computeIntIfAbsent(final K k, final java.util.function.ToIntFunction<? super K> mappingFunction) { java.util.Objects.requireNonNull(mappingFunction); final int pos = find(k); if (pos >= 0) return value[pos]; final int newValue = mappingFunction.applyAsInt(k); insert(-pos - 1, k, newValue); return newValue; } /** {@inheritDoc} */
public int applyAsInt(final V argument) { return indexer.applyAsInt(argument); }
/** {@inheritDoc} */ @Override public int computeIntIfAbsent(final K k, final java.util.function.ToIntFunction<? super K> mappingFunction) { java.util.Objects.requireNonNull(mappingFunction); final int pos = find(k); if (pos >= 0) return value[pos]; final int newValue = mappingFunction.applyAsInt(k); insert(-pos - 1, k, newValue); return newValue; } /** {@inheritDoc} */
/** * Iterate over the key set and apply the given function. * * @param function to apply to each {@link java.nio.channels.SelectionKey} * @return number of handled frames */ 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; }
/** {@inheritDoc} */ @Override public int computeIntIfAbsent(final K k, final java.util.function.ToIntFunction<? super K> mappingFunction) { java.util.Objects.requireNonNull(mappingFunction); final int pos = find(k); if (pos >= 0) return value[pos]; final int newValue = mappingFunction.applyAsInt(k); insert(-pos - 1, k, newValue); return newValue; } /** {@inheritDoc} */
@Override public void writeObject(ObjectOutput output, T object) throws IOException { output.writeInt(this.writer.applyAsInt(object)); }
/** {@inheritDoc} */ @Override public int computeIntIfAbsent(final K k, final java.util.function.ToIntFunction<? super K> mappingFunction) { java.util.Objects.requireNonNull(mappingFunction); final int pos = find(k); if (pos >= 0) return value[pos]; final int newValue = mappingFunction.applyAsInt(k); insert(-pos - 1, k, newValue); return newValue; } /** {@inheritDoc} */
private static Pair<Integer, Integer> getSpan(List<CoreLabel> tokens, ToIntFunction<CoreLabel> toMin, ToIntFunction<CoreLabel> toMax) { int min = Integer.MAX_VALUE; int max = Integer.MIN_VALUE; for (CoreLabel token : tokens) { min = Math.min(min, toMin.applyAsInt(token)); max = Math.max(max, toMax.applyAsInt(token) + 1); } return Pair.makePair(min, max); }
/** {@inheritDoc} */ @Override public int computeIntIfAbsent(final K k, final java.util.function.ToIntFunction<? super K> mappingFunction) { java.util.Objects.requireNonNull(mappingFunction); final int pos = find(k); if (pos >= 0) return value[pos]; final int newValue = mappingFunction.applyAsInt(k); insert(-pos - 1, k, newValue); return newValue; } /** {@inheritDoc} */
@Override public int applyAsInt(T object) throws NullPointerException { final A intermediate = before.apply(object); return after.applyAsInt(intermediate); }
/** {@inheritDoc} */ @Override public short computeShortIfAbsent(final K k, final java.util.function.ToIntFunction<? super K> mappingFunction) { java.util.Objects.requireNonNull(mappingFunction); final int pos = find(k); if (pos >= 0) return value[pos]; final short newValue = it.unimi.dsi.fastutil.SafeMath.safeIntToShort(mappingFunction.applyAsInt(k)); insert(-pos - 1, k, newValue); return newValue; } /** {@inheritDoc} */
@Override public Integer apply(T object) { final A intermediate = before.apply(object); if (intermediate == null) return null; return after.applyAsInt(intermediate); } }
/** {@inheritDoc} */ @Override public byte computeByteIfAbsent(final K k, final java.util.function.ToIntFunction<? super K> mappingFunction) { java.util.Objects.requireNonNull(mappingFunction); final int pos = find(k); if (pos >= 0) return value[pos]; final byte newValue = it.unimi.dsi.fastutil.SafeMath.safeIntToByte(mappingFunction.applyAsInt(k)); insert(-pos - 1, k, newValue); return newValue; } /** {@inheritDoc} */
public final Optional<Node> getAssignedNode(Split split) { return getAssignedNode(splitToBucket.applyAsInt(split)); } }
/** {@inheritDoc} */ @Override public short computeShortIfAbsent(final K k, final java.util.function.ToIntFunction<? super K> mappingFunction) { java.util.Objects.requireNonNull(mappingFunction); final int pos = find(k); if (pos >= 0) return value[pos]; final short newValue = it.unimi.dsi.fastutil.SafeMath.safeIntToShort(mappingFunction.applyAsInt(k)); insert(-pos - 1, k, newValue); return newValue; } /** {@inheritDoc} */
public boolean replace(final V oldValue, final V newValue) { if (indexer.applyAsInt(oldValue) != indexer.applyAsInt(newValue)) { throw new IllegalArgumentException("Can only replace with value which has the same key"); } return doReplace(oldValue, newValue, table); }
/** {@inheritDoc} */ @Override public byte computeByteIfAbsent(final K k, final java.util.function.ToIntFunction<? super K> mappingFunction) { java.util.Objects.requireNonNull(mappingFunction); final int pos = find(k); if (pos >= 0) return value[pos]; final byte newValue = it.unimi.dsi.fastutil.SafeMath.safeIntToByte(mappingFunction.applyAsInt(k)); insert(-pos - 1, k, newValue); return newValue; } /** {@inheritDoc} */