本文整理了Java中java.util.stream.IntStream.asLongStream()
方法的一些代码示例,展示了IntStream.asLongStream()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IntStream.asLongStream()
方法的具体详情如下:
包路径:java.util.stream.IntStream
类名称:IntStream
方法名:asLongStream
[英]Returns a LongStream consisting of the elements of this stream, converted to long.
This is an intermediate operation.
[中]返回由此流的元素组成的LongStream,并转换为long。
这是一个intermediate operation。
代码示例来源:origin: speedment/speedment
public IntAsLongAction() {
super(s -> s.asLongStream(), LongStream.class, AS);
}
代码示例来源:origin: speedment/speedment
@Override
public LongStream asLongStream() {
return wrap(stream().asLongStream());
}
代码示例来源:origin: apache/geode
@Test
public void basicEqualsReturnsFalseWhenCompareTwoNotEqualLongArrays() {
assertThat(ValueComparisonHelper.basicEquals(Arrays.stream(INT_ARRAY3).asLongStream().toArray(),
Arrays.stream(INT_ARRAY2).asLongStream().toArray())).isFalse();
}
代码示例来源:origin: apache/geode
@Test
public void basicEqualsReturnsTrueWhenCompareTwoEqualLongArrays() {
assertThat(ValueComparisonHelper.basicEquals(Arrays.stream(INT_ARRAY).asLongStream().toArray(),
Arrays.stream(INT_ARRAY2).asLongStream().toArray())).isTrue();
}
代码示例来源:origin: apache/geode
@Test
public void basicEqualsReturnsFalseWhenOnlyFirstObjectIsAStringArray() {
assertThat(ValueComparisonHelper.basicEquals(STRING_ARRAY,
Arrays.stream(INT_ARRAY).asLongStream().toArray())).isFalse();
}
代码示例来源:origin: com.speedment.runtime/runtime-core
public IntAsLongAction() {
super(s -> s.asLongStream(), LongStream.class, AS);
}
代码示例来源:origin: stackoverflow.com
int[] iArr = new int[]{2147483646 , 1 , 1};
System.out.println(Arrays.stream(iArr).asLongStream().sum());
代码示例来源:origin: nroduit/Weasis
public ExtendSegmentedInputImageStream(File file, long[] segmentPositions, int[] segmentLengths) {
this.file = file;
this.segmentPositions = segmentPositions;
this.segmentLengths = segmentLengths == null ? null : Arrays.stream(segmentLengths).asLongStream().toArray();
}
代码示例来源:origin: se.ugli.ugli-commons/ugli-commons
@Override
public LongStream asLongStream() {
return new LongResourceStream(stream.asLongStream(), closeOnTerminalOperation, resources);
}
代码示例来源:origin: net.dongliu/commons-lang
@Override
public ExLongStream asLongStream() {
return ExLongStream.of(stream.asLongStream());
}
代码示例来源:origin: stackoverflow.com
int[] intArray = {1, 2, 3};
long[] longArray = Arrays.stream(intArray).asLongStream().toArray();
代码示例来源:origin: stackoverflow.com
import java.util.stream.IntStream;
public class TapeEquilibrium {
public static int diffIndex( int[] A ) {
long lower = 0, diff = 0, higher = IntStream.of( A ).asLongStream().sum(), minDiff = Integer.MAX_VALUE;
for(int i = 0; i < A.length-1; i++) {
lower += A[i];
higher -= A[i];
diff = Math.abs( higher - lower);
if( diff < minDiff ) {
minDiff = diff;
}
}
return (int) minDiff;
}
public static void main( String[] args ) {
int[] A = { 3, 1, 2, 4, 3 };
System.out.println( diffIndex( A ) );
}
}
代码示例来源:origin: stackoverflow.com
int[] iArr = new int[10000000];
Arrays.fill(iArr , 3132);
long iStart = System.nanoTime();
long lSum1 = Arrays.stream(iArr).mapToLong(Long::valueOf).sum();
long iEnd = System.nanoTime();
System.out.println("Sum-: " + lSum1);
System.out.println("Time in nanoseconds-: " + (iEnd - iStart) + "ns using \"mapToLong\"\n");
long iStart1 = System.nanoTime();
long lSum2 = Arrays.stream(iArr).asLongStream().sum();
long iEnd1 = System.nanoTime();
System.out.println("Sum-: " + lSum2);
System.out.println("Time in nanoseconds-: " + (iEnd1 - iStart1) + "ns using \"asLongStream\"\n");
long iStart2 = System.nanoTime();
long lSum3 = Arrays.stream(iArr).boxed().collect(Collectors.summingLong(Integer::longValue));
long iEnd2 = System.nanoTime();
System.out.println("Sum-: " + lSum3);
System.out.println("Time in nanoseconds-: " + (iEnd2 - iStart2) + "ns using \"Collectors\"\n");
代码示例来源:origin: stackoverflow.com
int numbers[] = new int[5];
for(int count = 0; count < numbers.length; count++){
System.out.print("Please enter a number: ");
int number=s.nextInt();
numbers[count] = number;
}
LongSummaryStatistics statistics = Arrays.stream(numbers).asLongStream().summaryStatistics();
System.out.println("Highest: " + statistics.getMax());
System.out.println("Lowest: " + statistics.getMin());
System.out.println("The average of all number is: " + statistics.getAverage());
代码示例来源:origin: com.speedment.runtime/runtime-core
@Override
public LongStream asLongStream() {
return wrap(stream().asLongStream());
}
代码示例来源:origin: one.util/streamex
@Override
public LongStreamEx asLongStream() {
return new LongStreamEx(stream().asLongStream(), context);
}
代码示例来源:origin: org.eclipse.microprofile.metrics/microprofile-metrics-api-tck
@Test
public void testSnapshotValues() throws Exception {
Assert.assertArrayEquals(
"The histogramInt does not contain the expected values: " + Arrays.toString(SAMPLE_INT_DATA),
Arrays.stream(SAMPLE_INT_DATA).asLongStream().toArray(), histogramInt.getSnapshot().getValues());
Assert.assertArrayEquals(
"The histogramLong does not contain the expected values: " + Arrays.toString(SAMPLE_LONG_DATA),
SAMPLE_LONG_DATA, histogramLong.getSnapshot().getValues());
}
代码示例来源:origin: CorfuDB/CorfuDB
@Test
@SuppressWarnings("unchecked")
public void multipleTXesAreAppliedWOAccessors()
throws Exception {
Map<String, String> testMap = getRuntime().getObjectsView()
.build()
.setStreamName("test")
.setTypeToken(new TypeToken<SMRMap<String, String>>() {})
.open();
IntStream.range(0, PARAMETERS.NUM_ITERATIONS_LOW).asLongStream()
.forEach(l -> {
try {
getRuntime().getObjectsView().TXBegin();
assertThat(testMap.put(Long.toString(l), Long.toString(l)))
.isNull();
getRuntime().getObjectsView().TXEnd();
} catch (TransactionAbortedException tae) {
throw new RuntimeException(tae);
}
});
assertThat(testMap)
.hasSize(PARAMETERS.NUM_ITERATIONS_LOW);
}
代码示例来源:origin: CorfuDB/CorfuDB
@Test
@SuppressWarnings("unchecked")
public void multipleTXesAreApplied()
throws Exception {
Map<String, String> testMap = getRuntime().getObjectsView()
.build()
.setStreamName("test")
.setTypeToken(CorfuTable.<String,String>getMapType())
.open();
IntStream.range(0, PARAMETERS.NUM_ITERATIONS_LOW).asLongStream()
.forEach(l -> {
try {
assertThat(testMap)
.hasSize((int) l);
getRuntime().getObjectsView().TXBegin();
assertThat(testMap.put(Long.toString(l), Long.toString(l)))
.isNull();
assertThat(testMap)
.hasSize((int) l + 1);
getRuntime().getObjectsView().TXEnd();
assertThat(testMap)
.hasSize((int) l + 1);
} catch (TransactionAbortedException tae) {
throw new RuntimeException(tae);
}
});
assertThat(testMap)
.hasSize(PARAMETERS.NUM_ITERATIONS_LOW);
}
代码示例来源:origin: CorfuDB/CorfuDB
@Test
@SuppressWarnings("unchecked")
public void multipleTXesAreAppliedWOAccessors()
throws Exception {
Map<String, String> testMap = getRuntime().getObjectsView()
.build()
.setStreamName("test")
.setTypeToken(CorfuTable.<String,String>getMapType())
.open();
IntStream.range(0, PARAMETERS.NUM_ITERATIONS_LOW).asLongStream()
.forEach(l -> {
try {
getRuntime().getObjectsView().TXBegin();
assertThat(testMap.put(Long.toString(l), Long.toString(l)))
.isNull();
getRuntime().getObjectsView().TXEnd();
} catch (TransactionAbortedException tae) {
throw new RuntimeException(tae);
}
});
assertThat(testMap)
.hasSize(PARAMETERS.NUM_ITERATIONS_LOW);
}
内容来源于网络,如有侵权,请联系作者删除!