java.util.function.LongToIntFunction#java.util.function.LongFunction源码实例Demo

下面列出了java.util.function.LongToIntFunction#java.util.function.LongFunction 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: incubator-tuweni   文件: BytesSSZReader.java
private List<Bytes> readList(LongFunction<Bytes> bytesSupplier) {
  ensureBytes(4, () -> "SSZ encoded data is not a list");
  int originalIndex = this.index;
  List<Bytes> elements;
  try {
    // use a long to simulate reading unsigned
    long listSize = consumeBytes(4).toLong(LITTLE_ENDIAN);
    elements = new ArrayList<>();
    while (listSize > 0) {
      Bytes bytes = bytesSupplier.apply(listSize);
      elements.add(bytes);
      listSize -= bytes.size();
      listSize -= 4;
      if (listSize < 0) {
        throw new InvalidSSZTypeException("SSZ encoded list length does not align with lengths of its elements");
      }
    }
  } catch (Exception e) {
    this.index = originalIndex;
    throw e;
  }
  return elements;
}
 
源代码2 项目: incubator-tuweni   文件: BytesSSZReader.java
private <T> List<T> readFixedList(int listSize, LongFunction<byte[]> bytesSupplier, Function<byte[], T> converter) {
  int originalIndex = this.index;
  List<T> elements;
  try {
    elements = new ArrayList<>();
    while (listSize > 0) {
      byte[] bytes = bytesSupplier.apply(listSize);
      elements.add(converter.apply(bytes));
      // When lists have lengths passed in, the listSize argument is the number of
      // elements in the list, instead of the number of bytes in the list, so
      // we only subtract one each time an element is processed in this case.
      listSize -= 1;
      if (listSize < 0) {
        throw new InvalidSSZTypeException("SSZ encoded list length does not align with lengths of its elements");
      }
    }
  } catch (Exception e) {
    this.index = originalIndex;
    throw e;
  }
  return elements;
}
 
源代码3 项目: Flink-CEPplus   文件: OrcBatchReader.java
private static <T> void readNonNullLongColumn(Object[] vals, int fieldIdx, LongColumnVector vector,
												int childCount, LongFunction<T> reader) {

	if (vector.isRepeating) { // fill complete column with first value
		T repeatingValue = reader.apply(vector.vector[0]);
		fillColumnWithRepeatingValue(vals, fieldIdx, repeatingValue, childCount);
	} else {
		if (fieldIdx == -1) { // set as an object
			for (int i = 0; i < childCount; i++) {
				vals[i] = reader.apply(vector.vector[i]);
			}
		} else { // set as a field of Row
			Row[] rows = (Row[]) vals;
			for (int i = 0; i < childCount; i++) {
				rows[i].setField(fieldIdx, reader.apply(vector.vector[i]));
			}
		}
	}
}
 
源代码4 项目: jdk1.8-source-analysis   文件: LongPipeline.java
@Override
public final <U> Stream<U> mapToObj(LongFunction<? extends U> mapper) {
    Objects.requireNonNull(mapper);
    return new ReferencePipeline.StatelessOp<Long, U>(this, StreamShape.LONG_VALUE,
                                                      StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Long> opWrapSink(int flags, Sink<U> sink) {
            return new Sink.ChainedLong<U>(sink) {
                @Override
                public void accept(long t) {
                    downstream.accept(mapper.apply(t));
                }
            };
        }
    };
}
 
源代码5 项目: jdk1.8-source-analysis   文件: LongPipeline.java
@Override
public final LongStream flatMap(LongFunction<? extends LongStream> mapper) {
    return new StatelessOp<Long>(this, StreamShape.LONG_VALUE,
                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
        @Override
        Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedLong<Long>(sink) {
                @Override
                public void begin(long size) {
                    downstream.begin(-1);
                }

                @Override
                public void accept(long t) {
                    try (LongStream result = mapper.apply(t)) {
                        // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it
                        if (result != null)
                            result.sequential().forEach(i -> downstream.accept(i));
                    }
                }
            };
        }
    };
}
 
源代码6 项目: incubator-ratis   文件: OrderedAsync.java
CompletableFuture<RaftClientReply> send(RaftClientRequest.Type type, Message message, RaftPeerId server) {
  if (!type.is(TypeCase.WATCH) && !type.is(TypeCase.STREAM)) {
    Objects.requireNonNull(message, "message == null");
  }
  try {
    requestSemaphore.acquire();
  } catch (InterruptedException e) {
    return JavaUtils.completeExceptionally(IOUtils.toInterruptedIOException(
        "Interrupted when sending " + type + ", message=" + message, e));
  }

  final long callId = RaftClientImpl.nextCallId();
  final LongFunction<PendingOrderedRequest> constructor = seqNum -> new PendingOrderedRequest(callId, seqNum,
      slidingWindowEntry -> client.newRaftClientRequest(server, callId, message, type, slidingWindowEntry));
  return getSlidingWindow(server).submitNewRequest(constructor, this::sendRequestWithRetry
  ).getReplyFuture(
  ).thenApply(reply -> RaftClientImpl.handleRaftException(reply, CompletionException::new)
  ).whenComplete((r, e) -> requestSemaphore.release());
}
 
源代码7 项目: flink   文件: OrcBatchReader.java
private static <T> void readNonNullLongColumn(Object[] vals, int fieldIdx, LongColumnVector vector,
												int childCount, LongFunction<T> reader) {

	if (vector.isRepeating) { // fill complete column with first value
		T repeatingValue = reader.apply(vector.vector[0]);
		fillColumnWithRepeatingValue(vals, fieldIdx, repeatingValue, childCount);
	} else {
		if (fieldIdx == -1) { // set as an object
			for (int i = 0; i < childCount; i++) {
				vals[i] = reader.apply(vector.vector[i]);
			}
		} else { // set as a field of Row
			Row[] rows = (Row[]) vals;
			for (int i = 0; i < childCount; i++) {
				rows[i].setField(fieldIdx, reader.apply(vector.vector[i]));
			}
		}
	}
}
 
源代码8 项目: openjdk-jdk9   文件: IntegralPrimitiveToString.java
public <N extends Number> N[] numberProvider(LongFunction<N> boxer, int bits, N... extras) {
    List<N> numbers = new ArrayList<>();

    for(int bitmag = 0; bitmag < bits; bitmag++) {
        long value = 1L << bitmag;
        numbers.add(boxer.apply(value));
        numbers.add(boxer.apply(value - 1));
        numbers.add(boxer.apply(value + 1));
        numbers.add(boxer.apply(-value));
        for(int divisor = 0; divisor < SOME_PRIMES.length && value < SOME_PRIMES[divisor]; divisor++) {
            numbers.add(boxer.apply(value - SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value + SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value * SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value / SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value | SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value & SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value ^ SOME_PRIMES[divisor]));
        }
    }

    numbers.addAll(Arrays.asList(extras));

    return (N[]) numbers.toArray(new Number[numbers.size()]);
}
 
源代码9 项目: stateful-functions   文件: FlinkUniverse.java
private SingleOutputStreamOperator<Void> feedbackOperator(
    SingleOutputStreamOperator<Message> functionOut) {

  LongFunction<Message> toMessage = new CheckpointToMessage(universe.messageFactoryType());

  FeedbackSinkOperator<Message> sinkOperator =
      new FeedbackSinkOperator<>(FEEDBACK_KEY, toMessage);

  return functionOut
      .keyBy(new MessageKeySelector())
      .transform(
          StatefulFunctionsJobConstants.WRITE_BACK_OPERATOR_NAME,
          TypeInformation.of(Void.class),
          sinkOperator)
      .uid(StatefulFunctionsJobConstants.WRITE_BACK_OPERATOR_UID);
}
 
源代码10 项目: dragonwell8_jdk   文件: LongPipeline.java
@Override
public final <U> Stream<U> mapToObj(LongFunction<? extends U> mapper) {
    Objects.requireNonNull(mapper);
    return new ReferencePipeline.StatelessOp<Long, U>(this, StreamShape.LONG_VALUE,
                                                      StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Long> opWrapSink(int flags, Sink<U> sink) {
            return new Sink.ChainedLong<U>(sink) {
                @Override
                public void accept(long t) {
                    downstream.accept(mapper.apply(t));
                }
            };
        }
    };
}
 
源代码11 项目: exonum-java-binding   文件: StorageIterators.java
/**
 * Creates a new iterator over an index.
 *
 * <p>The returned iterator is a {@link ConfigurableRustIter}
 * wrapped in a {@link RustIterAdapter}.
 *
 * @param nativeHandle nativeHandle of this iterator
 * @param nextFunction a function to call to get the next item
 * @param disposeOperation an operation to call to destroy the corresponding native iterator
 * @param collectionAccess a database access of the collection over which to iterate
 * @param modificationCounter a modification counter of the collection
 * @param transformingFunction a function to apply to elements returned by native iterator
 *                             (usually, to an array of bytes)
 */
static <ElementT, NativeT> Iterator<ElementT> createIterator(
    long nativeHandle,
    LongFunction<NativeT> nextFunction,
    LongConsumer disposeOperation,
    AbstractAccess collectionAccess,
    ModificationCounter modificationCounter,
    Function<? super NativeT, ? extends ElementT> transformingFunction) {

  // Register the destructor first.
  NativeHandle handle = new NativeHandle(nativeHandle);
  Cleaner cleaner = collectionAccess.getCleaner();
  cleaner.add(new ProxyDestructor(handle, RustIter.class, disposeOperation));

  Iterator<NativeT> iterator = new RustIterAdapter<>(
      new ConfigurableRustIter<>(
          handle,
          nextFunction,
          modificationCounter
      )
  );

  return Iterators.transform(iterator, transformingFunction::apply);
}
 
public <N extends Number> N[] numberProvider(LongFunction<N> boxer, int bits, N... extras) {
    List<N> numbers = new ArrayList<>();

    for(int bitmag = 0; bitmag < bits; bitmag++) {
        long value = 1L << bitmag;
        numbers.add(boxer.apply(value));
        numbers.add(boxer.apply(value - 1));
        numbers.add(boxer.apply(value + 1));
        numbers.add(boxer.apply(-value));
        for(int divisor = 0; divisor < SOME_PRIMES.length && value < SOME_PRIMES[divisor]; divisor++) {
            numbers.add(boxer.apply(value - SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value + SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value * SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value / SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value | SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value & SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value ^ SOME_PRIMES[divisor]));
        }
    }

    numbers.addAll(Arrays.asList(extras));

    return (N[]) numbers.toArray(new Number[numbers.size()]);
}
 
源代码13 项目: TencentKona-8   文件: LongPipeline.java
@Override
public final <U> Stream<U> mapToObj(LongFunction<? extends U> mapper) {
    Objects.requireNonNull(mapper);
    return new ReferencePipeline.StatelessOp<Long, U>(this, StreamShape.LONG_VALUE,
                                                      StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Long> opWrapSink(int flags, Sink<U> sink) {
            return new Sink.ChainedLong<U>(sink) {
                @Override
                public void accept(long t) {
                    downstream.accept(mapper.apply(t));
                }
            };
        }
    };
}
 
源代码14 项目: flink-statefun   文件: FlinkUniverse.java
private SingleOutputStreamOperator<Void> feedbackOperator(
    SingleOutputStreamOperator<Message> functionOut) {

  LongFunction<Message> toMessage = new CheckpointToMessage(universe.messageFactoryType());

  FeedbackSinkOperator<Message> sinkOperator =
      new FeedbackSinkOperator<>(FEEDBACK_KEY, toMessage);

  return functionOut
      .keyBy(new MessageKeySelector())
      .transform(
          StatefulFunctionsJobConstants.WRITE_BACK_OPERATOR_NAME,
          TypeInformation.of(Void.class),
          sinkOperator)
      .uid(StatefulFunctionsJobConstants.WRITE_BACK_OPERATOR_UID);
}
 
源代码15 项目: jdk8u60   文件: LongPipeline.java
@Override
public final <U> Stream<U> mapToObj(LongFunction<? extends U> mapper) {
    Objects.requireNonNull(mapper);
    return new ReferencePipeline.StatelessOp<Long, U>(this, StreamShape.LONG_VALUE,
                                                      StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Long> opWrapSink(int flags, Sink<U> sink) {
            return new Sink.ChainedLong<U>(sink) {
                @Override
                public void accept(long t) {
                    downstream.accept(mapper.apply(t));
                }
            };
        }
    };
}
 
源代码16 项目: jdk8u60   文件: LongPipeline.java
@Override
public final LongStream flatMap(LongFunction<? extends LongStream> mapper) {
    return new StatelessOp<Long>(this, StreamShape.LONG_VALUE,
                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
        @Override
        Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedLong<Long>(sink) {
                @Override
                public void begin(long size) {
                    downstream.begin(-1);
                }

                @Override
                public void accept(long t) {
                    try (LongStream result = mapper.apply(t)) {
                        // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it
                        if (result != null)
                            result.sequential().forEach(i -> downstream.accept(i));
                    }
                }
            };
        }
    };
}
 
源代码17 项目: jdk8u60   文件: IntegralPrimitiveToString.java
public <N extends Number> N[] numberProvider(LongFunction<N> boxer, int bits, N... extras) {
    List<N> numbers = new ArrayList<>();

    for(int bitmag = 0; bitmag < bits; bitmag++) {
        long value = 1L << bitmag;
        numbers.add(boxer.apply(value));
        numbers.add(boxer.apply(value - 1));
        numbers.add(boxer.apply(value + 1));
        numbers.add(boxer.apply(-value));
        for(int divisor = 0; divisor < SOME_PRIMES.length && value < SOME_PRIMES[divisor]; divisor++) {
            numbers.add(boxer.apply(value - SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value + SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value * SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value / SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value | SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value & SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value ^ SOME_PRIMES[divisor]));
        }
    }

    numbers.addAll(Arrays.asList(extras));

    return (N[]) numbers.toArray(new Number[numbers.size()]);
}
 
源代码18 项目: cava   文件: BytesSSZReader.java
private <T> List<T> readList(LongFunction<byte[]> bytesSupplier, Function<byte[], T> converter) {
  ensureBytes(4, () -> "SSZ encoded data is not a list");
  int originalIndex = this.index;
  List<T> elements;
  try {
    // use a long to simulate reading unsigned
    long listSize = consumeBytes(4).toLong(LITTLE_ENDIAN);
    elements = new ArrayList<>();
    while (listSize > 0) {
      byte[] bytes = bytesSupplier.apply(listSize);
      elements.add(converter.apply(bytes));
      listSize -= bytes.length;
      listSize -= 4;
      if (listSize < 0) {
        throw new InvalidSSZTypeException("SSZ encoded list length does not align with lengths of its elements");
      }
    }
  } catch (Exception e) {
    this.index = originalIndex;
    throw e;
  }
  return elements;
}
 
源代码19 项目: JDKSourceCode1.8   文件: LongPipeline.java
@Override
public final <U> Stream<U> mapToObj(LongFunction<? extends U> mapper) {
    Objects.requireNonNull(mapper);
    return new ReferencePipeline.StatelessOp<Long, U>(this, StreamShape.LONG_VALUE,
                                                      StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Long> opWrapSink(int flags, Sink<U> sink) {
            return new Sink.ChainedLong<U>(sink) {
                @Override
                public void accept(long t) {
                    downstream.accept(mapper.apply(t));
                }
            };
        }
    };
}
 
源代码20 项目: JDKSourceCode1.8   文件: LongPipeline.java
@Override
public final LongStream flatMap(LongFunction<? extends LongStream> mapper) {
    return new StatelessOp<Long>(this, StreamShape.LONG_VALUE,
                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
        @Override
        Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedLong<Long>(sink) {
                @Override
                public void begin(long size) {
                    downstream.begin(-1);
                }

                @Override
                public void accept(long t) {
                    try (LongStream result = mapper.apply(t)) {
                        // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it
                        if (result != null)
                            result.sequential().forEach(i -> downstream.accept(i));
                    }
                }
            };
        }
    };
}
 
public <N extends Number> N[] numberProvider(LongFunction<N> boxer, int bits, N... extras) {
    List<N> numbers = new ArrayList<>();

    for(int bitmag = 0; bitmag < bits; bitmag++) {
        long value = 1L << bitmag;
        numbers.add(boxer.apply(value));
        numbers.add(boxer.apply(value - 1));
        numbers.add(boxer.apply(value + 1));
        numbers.add(boxer.apply(-value));
        for(int divisor = 0; divisor < SOME_PRIMES.length && value < SOME_PRIMES[divisor]; divisor++) {
            numbers.add(boxer.apply(value - SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value + SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value * SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value / SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value | SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value & SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value ^ SOME_PRIMES[divisor]));
        }
    }

    numbers.addAll(Arrays.asList(extras));

    return (N[]) numbers.toArray(new Number[numbers.size()]);
}
 
源代码22 项目: desugar_jdk_libs   文件: LongPipeline.java
@Override
public final <U> Stream<U> mapToObj(LongFunction<? extends U> mapper) {
    Objects.requireNonNull(mapper);
    return new ReferencePipeline.StatelessOp<Long, U>(this, StreamShape.LONG_VALUE,
                                                      StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Long> opWrapSink(int flags, Sink<U> sink) {
            return new Sink.ChainedLong<U>(sink) {
                @Override
                public void accept(long t) {
                    downstream.accept(mapper.apply(t));
                }
            };
        }
    };
}
 
源代码23 项目: desugar_jdk_libs   文件: LongPipeline.java
@Override
public final LongStream flatMap(LongFunction<? extends LongStream> mapper) {
    return new StatelessOp<Long>(this, StreamShape.LONG_VALUE,
                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
        @Override
        Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedLong<Long>(sink) {
                @Override
                public void begin(long size) {
                    downstream.begin(-1);
                }

                @Override
                public void accept(long t) {
                    try (LongStream result = mapper.apply(t)) {
                        // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it
                        if (result != null)
                            result.sequential().forEach(i -> downstream.accept(i));
                    }
                }
            };
        }
    };
}
 
源代码24 项目: openjdk-jdk9   文件: LongPipeline.java
@Override
public final LongStream flatMap(LongFunction<? extends LongStream> mapper) {
    Objects.requireNonNull(mapper);
    return new StatelessOp<Long>(this, StreamShape.LONG_VALUE,
                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
        @Override
        Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedLong<Long>(sink) {
                @Override
                public void begin(long size) {
                    downstream.begin(-1);
                }

                @Override
                public void accept(long t) {
                    try (LongStream result = mapper.apply(t)) {
                        // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it
                        if (result != null)
                            result.sequential().forEach(i -> downstream.accept(i));
                    }
                }
            };
        }
    };
}
 
源代码25 项目: openjdk-jdk8u-backup   文件: LongPipeline.java
@Override
public final LongStream flatMap(LongFunction<? extends LongStream> mapper) {
    return new StatelessOp<Long>(this, StreamShape.LONG_VALUE,
                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT | StreamOpFlag.NOT_SIZED) {
        @Override
        Sink<Long> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedLong<Long>(sink) {
                @Override
                public void begin(long size) {
                    downstream.begin(-1);
                }

                @Override
                public void accept(long t) {
                    try (LongStream result = mapper.apply(t)) {
                        // We can do better that this too; optimize for depth=0 case and just grab spliterator and forEach it
                        if (result != null)
                            result.sequential().forEach(i -> downstream.accept(i));
                    }
                }
            };
        }
    };
}
 
源代码26 项目: jdk8u-jdk   文件: LongPipeline.java
@Override
public final <U> Stream<U> mapToObj(LongFunction<? extends U> mapper) {
    Objects.requireNonNull(mapper);
    return new ReferencePipeline.StatelessOp<Long, U>(this, StreamShape.LONG_VALUE,
                                                      StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Long> opWrapSink(int flags, Sink<U> sink) {
            return new Sink.ChainedLong<U>(sink) {
                @Override
                public void accept(long t) {
                    downstream.accept(mapper.apply(t));
                }
            };
        }
    };
}
 
源代码27 项目: openjdk-jdk8u   文件: IntegralPrimitiveToString.java
public <N extends Number> N[] numberProvider(LongFunction<N> boxer, int bits, N... extras) {
    List<N> numbers = new ArrayList<>();

    for(int bitmag = 0; bitmag < bits; bitmag++) {
        long value = 1L << bitmag;
        numbers.add(boxer.apply(value));
        numbers.add(boxer.apply(value - 1));
        numbers.add(boxer.apply(value + 1));
        numbers.add(boxer.apply(-value));
        for(int divisor = 0; divisor < SOME_PRIMES.length && value < SOME_PRIMES[divisor]; divisor++) {
            numbers.add(boxer.apply(value - SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value + SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value * SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value / SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value | SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value & SOME_PRIMES[divisor]));
            numbers.add(boxer.apply(value ^ SOME_PRIMES[divisor]));
        }
    }

    numbers.addAll(Arrays.asList(extras));

    return (N[]) numbers.toArray(new Number[numbers.size()]);
}
 
源代码28 项目: incubator-ratis   文件: SlidingWindow.java
/**
 * A new request arrives, create it with {@link #nextSeqNum}
 * and then try sending it to the server.
 *
 * @param requestConstructor use seqNum to create a new request.
 * @return the new request.
 */
public synchronized REQUEST submitNewRequest(
    LongFunction<REQUEST> requestConstructor, Consumer<REQUEST> sendMethod) {
  if (!requests.isEmpty()) {
    Preconditions.assertTrue(nextSeqNum == requests.lastSeqNum() + 1,
        () -> "nextSeqNum=" + nextSeqNum + " but " + this);
  }

  final long seqNum = nextSeqNum++;
  final REQUEST r = requestConstructor.apply(seqNum);

  if (exception != null) {
    alreadyClosed(r, exception);
    return r;
  }

  requests.putNewRequest(r);

  final boolean submitted = sendOrDelayRequest(r, sendMethod);
  LOG.debug("{}: submitting a new request {} in {}? {}",
      requests.getName(), r, this, submitted? "submitted": "delayed");
  return r;
}
 
源代码29 项目: morpheus-core   文件: Function2.java
/**
 * Creates an LONG function that wraps to function provided
 * @param function  the function to wrap
 * @param <O>       the output type
 * @return          the newly created function wrapper
 */
public static <O> Function2<Long,O> fromLong(LongFunction<O> function) {
    return new Function2<Long,O>(FunctionStyle.LONG) {
        @Override
        public final O apply(long input) {
            return function.apply(input);
        }
    };
}
 
源代码30 项目: openjdk-jdk9   文件: LongPipeline.java
private <U> Stream<U> mapToObj(LongFunction<? extends U> mapper, int opFlags) {
    return new ReferencePipeline.StatelessOp<Long, U>(this, StreamShape.LONG_VALUE, opFlags) {
        @Override
        Sink<Long> opWrapSink(int flags, Sink<U> sink) {
            return new Sink.ChainedLong<U>(sink) {
                @Override
                public void accept(long t) {
                    downstream.accept(mapper.apply(t));
                }
            };
        }
    };
}