java.util.function.IntToLongFunction Java Examples

The following examples show how to use java.util.function.IntToLongFunction. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: jdk1.8-source-analysis   Author: raysonfang   File: IntPipeline.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public final LongStream mapToLong(IntToLongFunction mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedInt<Long>(sink) {
                @Override
                public void accept(int t) {
                    downstream.accept(mapper.applyAsLong(t));
                }
            };
        }
    };
}
 
Example #2
Source Project: dragonwell8_jdk   Author: alibaba   File: IntPipeline.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public final LongStream mapToLong(IntToLongFunction mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedInt<Long>(sink) {
                @Override
                public void accept(int t) {
                    downstream.accept(mapper.applyAsLong(t));
                }
            };
        }
    };
}
 
Example #3
Source Project: TencentKona-8   Author: Tencent   File: IntPipeline.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public final LongStream mapToLong(IntToLongFunction mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedInt<Long>(sink) {
                @Override
                public void accept(int t) {
                    downstream.accept(mapper.applyAsLong(t));
                }
            };
        }
    };
}
 
Example #4
Source Project: jdk8u60   Author: chenghanpeng   File: IntPipeline.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public final LongStream mapToLong(IntToLongFunction mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedInt<Long>(sink) {
                @Override
                public void accept(int t) {
                    downstream.accept(mapper.applyAsLong(t));
                }
            };
        }
    };
}
 
Example #5
Source Project: JDKSourceCode1.8   Author: wupeixuan   File: IntPipeline.java    License: MIT License 6 votes vote down vote up
@Override
public final LongStream mapToLong(IntToLongFunction mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedInt<Long>(sink) {
                @Override
                public void accept(int t) {
                    downstream.accept(mapper.applyAsLong(t));
                }
            };
        }
    };
}
 
Example #6
Source Project: desugar_jdk_libs   Author: google   File: IntPipeline.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public final LongStream mapToLong(IntToLongFunction mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedInt<Long>(sink) {
                @Override
                public void accept(int t) {
                    downstream.accept(mapper.applyAsLong(t));
                }
            };
        }
    };
}
 
Example #7
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: IntPipeline.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public final LongStream mapToLong(IntToLongFunction mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedInt<Long>(sink) {
                @Override
                public void accept(int t) {
                    downstream.accept(mapper.applyAsLong(t));
                }
            };
        }
    };
}
 
Example #8
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: IntPipeline.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public final LongStream mapToLong(IntToLongFunction mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedInt<Long>(sink) {
                @Override
                public void accept(int t) {
                    downstream.accept(mapper.applyAsLong(t));
                }
            };
        }
    };
}
 
Example #9
Source Project: Bytecoder   Author: mirkosertic   File: IntPipeline.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public final LongStream mapToLong(IntToLongFunction mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedInt<Long>(sink) {
                @Override
                public void accept(int t) {
                    downstream.accept(mapper.applyAsLong(t));
                }
            };
        }
    };
}
 
Example #10
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: IntPipeline.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public final LongStream mapToLong(IntToLongFunction mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedInt<Long>(sink) {
                @Override
                public void accept(int t) {
                    downstream.accept(mapper.applyAsLong(t));
                }
            };
        }
    };
}
 
Example #11
Source Project: jdk8u-jdk   Author: lambdalab-mirror   File: IntPipeline.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public final LongStream mapToLong(IntToLongFunction mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedInt<Long>(sink) {
                @Override
                public void accept(int t) {
                    downstream.accept(mapper.applyAsLong(t));
                }
            };
        }
    };
}
 
Example #12
Source Project: Java8CN   Author: Java8-CNAPI-Team   File: IntPipeline.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public final LongStream mapToLong(IntToLongFunction mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedInt<Long>(sink) {
                @Override
                public void accept(int t) {
                    downstream.accept(mapper.applyAsLong(t));
                }
            };
        }
    };
}
 
Example #13
Source Project: hottub   Author: dsrg-uoft   File: IntPipeline.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public final LongStream mapToLong(IntToLongFunction mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedInt<Long>(sink) {
                @Override
                public void accept(int t) {
                    downstream.accept(mapper.applyAsLong(t));
                }
            };
        }
    };
}
 
Example #14
Source Project: openjdk-8-source   Author: keerath   File: IntPipeline.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public final LongStream mapToLong(IntToLongFunction mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedInt<Long>(sink) {
                @Override
                public void accept(int t) {
                    downstream.accept(mapper.applyAsLong(t));
                }
            };
        }
    };
}
 
Example #15
Source Project: ViaVersion   Author: ViaVersion   File: CompactArrayUtil.java    License: MIT License 6 votes vote down vote up
public static long[] createCompactArrayWithPadding(int bitsPerEntry, int entries, IntToLongFunction valueGetter) {
    long maxEntryValue = (1L << bitsPerEntry) - 1;
    char valuesPerLong = (char) (64 / bitsPerEntry);
    int magicIndex = 3 * (valuesPerLong - 1);
    long divideMul = Integer.toUnsignedLong(MAGIC[magicIndex]);
    long divideAdd = Integer.toUnsignedLong(MAGIC[magicIndex + 1]);
    int divideShift = MAGIC[magicIndex + 2];
    int size = (entries + valuesPerLong - 1) / valuesPerLong;

    long[] data = new long[size];

    for (int i = 0; i < entries; i++) {
        long value = valueGetter.applyAsLong(i);
        int cellIndex = (int) (i * divideMul + divideAdd >> 32L >> divideShift);
        int bitIndex = (i - cellIndex * valuesPerLong) * bitsPerEntry;
        data[cellIndex] = data[cellIndex] & ~(maxEntryValue << bitIndex) | (value & maxEntryValue) << bitIndex;
    }

    return data;
}
 
Example #16
Source Project: ViaVersion   Author: ViaVersion   File: CompactArrayUtil.java    License: MIT License 6 votes vote down vote up
public static long[] createCompactArray(int bitsPerEntry, int entries, IntToLongFunction valueGetter) {
    long maxEntryValue = (1L << bitsPerEntry) - 1;
    long[] data = new long[(int) Math.ceil(entries * bitsPerEntry / 64.0)];
    for (int i = 0; i < entries; i++) {
        long value = valueGetter.applyAsLong(i);
        int bitIndex = i * bitsPerEntry;
        int startIndex = bitIndex / 64;
        int endIndex = ((i + 1) * bitsPerEntry - 1) / 64;
        int startBitSubIndex = bitIndex % 64;
        data[startIndex] = data[startIndex] & ~(maxEntryValue << startBitSubIndex) | (value & maxEntryValue) << startBitSubIndex;
        if (startIndex != endIndex) {
            int endBitSubIndex = 64 - startBitSubIndex;
            data[endIndex] = data[endIndex] >>> endBitSubIndex << endBitSubIndex | (value & maxEntryValue) >> endBitSubIndex;
        }
    }
    return data;
}
 
Example #17
Source Project: openjdk-8   Author: bpupadhyaya   File: IntPipeline.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public final LongStream mapToLong(IntToLongFunction mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedInt<Long>(sink) {
                @Override
                public void accept(int t) {
                    downstream.accept(mapper.applyAsLong(t));
                }
            };
        }
    };
}
 
Example #18
Source Project: jdk8u_jdk   Author: JetBrains   File: IntPipeline.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public final LongStream mapToLong(IntToLongFunction mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedInt<Long>(sink) {
                @Override
                public void accept(int t) {
                    downstream.accept(mapper.applyAsLong(t));
                }
            };
        }
    };
}
 
Example #19
Source Project: jdk8u-jdk   Author: frohoff   File: IntPipeline.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public final LongStream mapToLong(IntToLongFunction mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedInt<Long>(sink) {
                @Override
                public void accept(int t) {
                    downstream.accept(mapper.applyAsLong(t));
                }
            };
        }
    };
}
 
Example #20
Source Project: jdk8u-dev-jdk   Author: frohoff   File: IntPipeline.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public final LongStream mapToLong(IntToLongFunction mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedInt<Long>(sink) {
                @Override
                public void accept(int t) {
                    downstream.accept(mapper.applyAsLong(t));
                }
            };
        }
    };
}
 
Example #21
Source Project: j2objc   Author: google   File: IntPipeline.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public final LongStream mapToLong(IntToLongFunction mapper) {
    Objects.requireNonNull(mapper);
    return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                 StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
        @Override
        public Sink<Integer> opWrapSink(int flags, Sink<Long> sink) {
            return new Sink.ChainedInt<Long>(sink) {
                @Override
                public void accept(int t) {
                    downstream.accept(mapper.applyAsLong(t));
                }
            };
        }
    };
}
 
Example #22
Source Project: dragonwell8_jdk   Author: alibaba   File: SetAllTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "long")
public void testSetAllLong(String name, int size, IntToLongFunction generator, long[] expected) {
    long[] result = new long[size];
    Arrays.setAll(result, generator);
    assertEquals(result, expected, "setAll(long[], IntToLongFunction) case " + name + " failed.");

    // ensure fresh array
    result = new long[size];
    Arrays.parallelSetAll(result, generator);
    assertEquals(result, expected, "parallelSetAll(long[], IntToLongFunction) case " + name + " failed.");
}
 
Example #23
Source Project: TencentKona-8   Author: Tencent   File: SetAllTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "long")
public void testSetAllLong(String name, int size, IntToLongFunction generator, long[] expected) {
    long[] result = new long[size];
    Arrays.setAll(result, generator);
    assertEquals(result, expected, "setAll(long[], IntToLongFunction) case " + name + " failed.");

    // ensure fresh array
    result = new long[size];
    Arrays.parallelSetAll(result, generator);
    assertEquals(result, expected, "parallelSetAll(long[], IntToLongFunction) case " + name + " failed.");
}
 
Example #24
Source Project: jdk8u60   Author: chenghanpeng   File: SetAllTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "long")
public void testSetAllLong(String name, int size, IntToLongFunction generator, long[] expected) {
    long[] result = new long[size];
    Arrays.setAll(result, generator);
    assertEquals(result, expected, "setAll(long[], IntToLongFunction) case " + name + " failed.");

    // ensure fresh array
    result = new long[size];
    Arrays.parallelSetAll(result, generator);
    assertEquals(result, expected, "parallelSetAll(long[], IntToLongFunction) case " + name + " failed.");
}
 
Example #25
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: SetAllTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "long")
public void testSetAllLong(String name, int size, IntToLongFunction generator, long[] expected) {
    long[] result = new long[size];
    Arrays.setAll(result, generator);
    assertEquals(result, expected, "setAll(long[], IntToLongFunction) case " + name + " failed.");

    // ensure fresh array
    result = new long[size];
    Arrays.parallelSetAll(result, generator);
    assertEquals(result, expected, "parallelSetAll(long[], IntToLongFunction) case " + name + " failed.");
}
 
Example #26
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: SetAllTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "long")
public void testSetAllLong(String name, int size, IntToLongFunction generator, long[] expected) {
    long[] result = new long[size];
    Arrays.setAll(result, generator);
    assertEquals(result, expected, "setAll(long[], IntToLongFunction) case " + name + " failed.");

    // ensure fresh array
    result = new long[size];
    Arrays.parallelSetAll(result, generator);
    assertEquals(result, expected, "parallelSetAll(long[], IntToLongFunction) case " + name + " failed.");
}
 
Example #27
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: SetAllTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "long")
public void testSetAllLong(String name, int size, IntToLongFunction generator, long[] expected) {
    long[] result = new long[size];
    Arrays.setAll(result, generator);
    assertEquals(result, expected, "setAll(long[], IntToLongFunction) case " + name + " failed.");

    // ensure fresh array
    result = new long[size];
    Arrays.parallelSetAll(result, generator);
    assertEquals(result, expected, "parallelSetAll(long[], IntToLongFunction) case " + name + " failed.");
}
 
Example #28
Source Project: jdk8u-jdk   Author: lambdalab-mirror   File: SetAllTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "long")
public void testSetAllLong(String name, int size, IntToLongFunction generator, long[] expected) {
    long[] result = new long[size];
    Arrays.setAll(result, generator);
    assertEquals(result, expected, "setAll(long[], IntToLongFunction) case " + name + " failed.");

    // ensure fresh array
    result = new long[size];
    Arrays.parallelSetAll(result, generator);
    assertEquals(result, expected, "parallelSetAll(long[], IntToLongFunction) case " + name + " failed.");
}
 
Example #29
Source Project: hottub   Author: dsrg-uoft   File: SetAllTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "long")
public void testSetAllLong(String name, int size, IntToLongFunction generator, long[] expected) {
    long[] result = new long[size];
    Arrays.setAll(result, generator);
    assertEquals(result, expected, "setAll(long[], IntToLongFunction) case " + name + " failed.");

    // ensure fresh array
    result = new long[size];
    Arrays.parallelSetAll(result, generator);
    assertEquals(result, expected, "parallelSetAll(long[], IntToLongFunction) case " + name + " failed.");
}
 
Example #30
Source Project: openjdk-8-source   Author: keerath   File: SetAllTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "long")
public void testSetAllLong(String name, int size, IntToLongFunction generator, long[] expected) {
    long[] result = new long[size];
    Arrays.setAll(result, generator);
    assertEquals(result, expected, "setAll(long[], IntToLongFunction) case " + name + " failed.");

    // ensure fresh array
    result = new long[size];
    Arrays.parallelSetAll(result, generator);
    assertEquals(result, expected, "parallelSetAll(long[], IntToLongFunction) case " + name + " failed.");
}