repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.streamToOptional
public final static <T> Optional<Seq<T>> streamToOptional(final Stream<T> stream) { final List<T> collected = stream.collect(java.util.stream.Collectors.toList()); if (collected.size() == 0) return Optional.empty(); return Optional.of(Seq.fromIterable(collected)); }
java
public final static <T> Optional<Seq<T>> streamToOptional(final Stream<T> stream) { final List<T> collected = stream.collect(java.util.stream.Collectors.toList()); if (collected.size() == 0) return Optional.empty(); return Optional.of(Seq.fromIterable(collected)); }
[ "public", "final", "static", "<", "T", ">", "Optional", "<", "Seq", "<", "T", ">", ">", "streamToOptional", "(", "final", "Stream", "<", "T", ">", "stream", ")", "{", "final", "List", "<", "T", ">", "collected", "=", "stream", ".", "collect", "(", ...
Create an Optional containing a List materialized from a Stream <pre> {@code Optional<Seq<Integer>> opt = Streams.streamToOptional(Stream.of(1,2,3)); //Optional[[1,2,3]] } </pre> @param stream To convert into an Optional @return Optional with a List of values
[ "Create", "an", "Optional", "containing", "a", "List", "materialized", "from", "a", "Stream" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L473-L479
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.optionalToStream
public final static <T> Stream<T> optionalToStream(final Optional<T> optional) { if (optional.isPresent()) return Stream.of(optional.get()); return Stream.of(); }
java
public final static <T> Stream<T> optionalToStream(final Optional<T> optional) { if (optional.isPresent()) return Stream.of(optional.get()); return Stream.of(); }
[ "public", "final", "static", "<", "T", ">", "Stream", "<", "T", ">", "optionalToStream", "(", "final", "Optional", "<", "T", ">", "optional", ")", "{", "if", "(", "optional", ".", "isPresent", "(", ")", ")", "return", "Stream", ".", "of", "(", "optio...
Convert an Optional to a Stream <pre> {@code Stream<Integer> stream = Streams.optionalToStream(Optional.of(1)); //Stream[1] Stream<Integer> zero = Streams.optionalToStream(Optional.zero()); //Stream[] } </pre> @param optional Optional to convert to a Stream @return Stream with a single value (if present) created from an Optional
[ "Convert", "an", "Optional", "to", "a", "Stream" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L497-L501
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.streamToCompletableFuture
public final static <T> CompletableFuture<List<T>> streamToCompletableFuture(final Stream<T> stream) { return CompletableFuture.completedFuture(stream.collect(Collectors.toList())); }
java
public final static <T> CompletableFuture<List<T>> streamToCompletableFuture(final Stream<T> stream) { return CompletableFuture.completedFuture(stream.collect(Collectors.toList())); }
[ "public", "final", "static", "<", "T", ">", "CompletableFuture", "<", "List", "<", "T", ">", ">", "streamToCompletableFuture", "(", "final", "Stream", "<", "T", ">", "stream", ")", "{", "return", "CompletableFuture", ".", "completedFuture", "(", "stream", "....
Create a CompletableFuture containing a List materialized from a Stream @param stream To convert into an Optional @return CompletableFuture with a List of values
[ "Create", "a", "CompletableFuture", "containing", "a", "List", "materialized", "from", "a", "Stream" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L509-L512
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.completableFutureToStream
public final static <T> Stream<T> completableFutureToStream(final CompletableFuture<T> future) { return Stream.of(future.join()); }
java
public final static <T> Stream<T> completableFutureToStream(final CompletableFuture<T> future) { return Stream.of(future.join()); }
[ "public", "final", "static", "<", "T", ">", "Stream", "<", "T", ">", "completableFutureToStream", "(", "final", "CompletableFuture", "<", "T", ">", "future", ")", "{", "return", "Stream", ".", "of", "(", "future", ".", "join", "(", ")", ")", ";", "}" ]
Convert a CompletableFuture to a Stream @param future CompletableFuture to convert @return Stream with a single value created from a CompletableFuture
[ "Convert", "a", "CompletableFuture", "to", "a", "Stream" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L520-L523
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.quadruplicate
@SuppressWarnings("unchecked") public final static <T> Tuple4<Stream<T>, Stream<T>, Stream<T>, Stream<T>> quadruplicate(final Stream<T> stream) { final Stream<Stream<T>> its = Streams.toBufferingCopier(stream.iterator(), 4) .stream() .map(it -> Streams.stream(it)); final Iterator<Stream<T>> it = its.iterator(); return new Tuple4( it.next(), it.next(), it.next(), it.next()); }
java
@SuppressWarnings("unchecked") public final static <T> Tuple4<Stream<T>, Stream<T>, Stream<T>, Stream<T>> quadruplicate(final Stream<T> stream) { final Stream<Stream<T>> its = Streams.toBufferingCopier(stream.iterator(), 4) .stream() .map(it -> Streams.stream(it)); final Iterator<Stream<T>> it = its.iterator(); return new Tuple4( it.next(), it.next(), it.next(), it.next()); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "final", "static", "<", "T", ">", "Tuple4", "<", "Stream", "<", "T", ">", ",", "Stream", "<", "T", ">", ",", "Stream", "<", "T", ">", ",", "Stream", "<", "T", ">", ">", "quadruplicate", ...
Makes four copies of a Stream Buffers intermediate values, leaders may change positions so a limit can be safely applied to the leading stream. Not thread-safe. <pre> {@code Tuple4<ReactiveSeq<Tuple4<T1,T2,T3,T4>>,ReactiveSeq<Tuple4<T1,T2,T3,T4>>,ReactiveSeq<Tuple4<T1,T2,T3,T4>>,ReactiveSeq<Tuple4<T1,T2,T3,T4>>> quad = sequence.quadruplicate(); } </pre> @return
[ "Makes", "four", "copies", "of", "a", "Stream", "Buffers", "intermediate", "values", "leaders", "may", "change", "positions", "so", "a", "limit", "can", "be", "safely", "applied", "to", "the", "leading", "stream", ".", "Not", "thread", "-", "safe", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L973-L981
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.appendStream
public static final <T> Stream<T> appendStream(final Stream<T> stream1, final Stream<T> append) { return Stream.concat(stream1, append); }
java
public static final <T> Stream<T> appendStream(final Stream<T> stream1, final Stream<T> append) { return Stream.concat(stream1, append); }
[ "public", "static", "final", "<", "T", ">", "Stream", "<", "T", ">", "appendStream", "(", "final", "Stream", "<", "T", ">", "stream1", ",", "final", "Stream", "<", "T", ">", "append", ")", "{", "return", "Stream", ".", "concat", "(", "stream1", ",", ...
Append Stream to this Stream <pre> {@code List<String> result = of(1,2,3).appendStream(of(100,200,300)) .map(it ->it+"!!") .collect(CyclopsCollectors.toList()); assertThat(result,equalTo(Arrays.asList("1!!","2!!","3!!","100!!","200!!","300!!"))); } </pre> @param stream1 to append to @param append to append with @return Stream with Stream appended
[ "Append", "Stream", "to", "this", "Stream" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L1023-L1025
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.prependStream
public static final <T> Stream<T> prependStream(final Stream<T> stream1, final Stream<T> prepend) { return Stream.concat(prepend, stream1); }
java
public static final <T> Stream<T> prependStream(final Stream<T> stream1, final Stream<T> prepend) { return Stream.concat(prepend, stream1); }
[ "public", "static", "final", "<", "T", ">", "Stream", "<", "T", ">", "prependStream", "(", "final", "Stream", "<", "T", ">", "stream1", ",", "final", "Stream", "<", "T", ">", "prepend", ")", "{", "return", "Stream", ".", "concat", "(", "prepend", ","...
Prepend Stream to this Stream <pre> {@code List<String> result = of(1,2,3).prependStream(of(100,200,300)) .map(it ->it+"!!").collect(CyclopsCollectors.toList()); assertThat(result,equalTo(Arrays.asList("100!!","200!!","300!!","1!!","2!!","3!!"))); } </pre> @param stream1 to Prepend to @param prepend to Prepend with @return Stream with Stream prepended
[ "Prepend", "Stream", "to", "this", "Stream" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L1044-L1047
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.dropWhile
public static <U> Stream<U> dropWhile(final Stream<U> stream, final Predicate<? super U> predicate) { return StreamSupport.stream(new SkipWhileSpliterator<U>(stream.spliterator(),predicate), stream.isParallel()); }
java
public static <U> Stream<U> dropWhile(final Stream<U> stream, final Predicate<? super U> predicate) { return StreamSupport.stream(new SkipWhileSpliterator<U>(stream.spliterator(),predicate), stream.isParallel()); }
[ "public", "static", "<", "U", ">", "Stream", "<", "U", ">", "dropWhile", "(", "final", "Stream", "<", "U", ">", "stream", ",", "final", "Predicate", "<", "?", "super", "U", ">", "predicate", ")", "{", "return", "StreamSupport", ".", "stream", "(", "n...
skip elements in a Stream while Predicate holds true <pre> {@code Streams.dropWhile(Stream.of(4,3,6,7).sorted(),i->i<6).collect(CyclopsCollectors.toList()) // [6,7] }</pre> @param stream @param predicate @return
[ "skip", "elements", "in", "a", "Stream", "while", "Predicate", "holds", "true" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L1192-L1194
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.cycle
public static <U> Stream<U> cycle(final Stream<U> s) { return cycle(Streamable.fromStream(s)); }
java
public static <U> Stream<U> cycle(final Stream<U> s) { return cycle(Streamable.fromStream(s)); }
[ "public", "static", "<", "U", ">", "Stream", "<", "U", ">", "cycle", "(", "final", "Stream", "<", "U", ">", "s", ")", "{", "return", "cycle", "(", "Streamable", ".", "fromStream", "(", "s", ")", ")", ";", "}" ]
Create a new Stream that infiniteable cycles the provided Stream <pre> {@code assertThat(Streams.cycle(Stream.of(1,2,3)) .limit(6) .collect(CyclopsCollectors.toList()), equalTo(Arrays.asList(1,2,3,1,2,3))); } </pre> @param s Stream to cycle @return New cycling stream
[ "Create", "a", "new", "Stream", "that", "infiniteable", "cycles", "the", "provided", "Stream" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L1367-L1369
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.reduce
@SuppressWarnings({ "rawtypes", "unchecked" }) public static <R> Seq<R> reduce(final Stream<R> stream, final Iterable<? extends Monoid<R>> reducers) { return Seq.fromIterable(new MultiReduceOperator<R>( stream).reduce(reducers)); }
java
@SuppressWarnings({ "rawtypes", "unchecked" }) public static <R> Seq<R> reduce(final Stream<R> stream, final Iterable<? extends Monoid<R>> reducers) { return Seq.fromIterable(new MultiReduceOperator<R>( stream).reduce(reducers)); }
[ "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "public", "static", "<", "R", ">", "Seq", "<", "R", ">", "reduce", "(", "final", "Stream", "<", "R", ">", "stream", ",", "final", "Iterable", "<", "?", "extends", "Monoi...
Simultaneously reduce a stream with multiple reducers <pre>{@code Monoid<Integer> sum = Monoid.of(0,(a,b)->a+b); Monoid<Integer> mult = Monoid.of(1,(a,b)->a*b); val result = Streams.reduce(Stream.of(1,2,3,4),Arrays.asList(sum,mult)); assertThat(result,equalTo(Arrays.asList(10,24))); }</pre> @param stream Stream to reduce @param reducers Reducers to reduce Stream @return Reduced Stream values as List entries
[ "Simultaneously", "reduce", "a", "stream", "with", "multiple", "reducers" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L1507-L1512
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.reduce
@SuppressWarnings({ "rawtypes", "unchecked" }) public static <R> Seq<R> reduce(final Stream<R> stream, final Stream<? extends Monoid<R>> reducers) { return reduce(stream, Seq.fromIterable((List) reducers.collect(java.util.stream.Collectors.toList()))); }
java
@SuppressWarnings({ "rawtypes", "unchecked" }) public static <R> Seq<R> reduce(final Stream<R> stream, final Stream<? extends Monoid<R>> reducers) { return reduce(stream, Seq.fromIterable((List) reducers.collect(java.util.stream.Collectors.toList()))); }
[ "@", "SuppressWarnings", "(", "{", "\"rawtypes\"", ",", "\"unchecked\"", "}", ")", "public", "static", "<", "R", ">", "Seq", "<", "R", ">", "reduce", "(", "final", "Stream", "<", "R", ">", "stream", ",", "final", "Stream", "<", "?", "extends", "Monoid"...
Simultanously reduce a stream with multiple reducers <pre> {@code Monoid<String> concat = Monoid.of("",(a,b)->a+b); Monoid<String> join = Monoid.of("",(a,b)->a+","+b); assertThat(Streams.reduce(Stream.of("hello", "world", "woo!"),Stream.of(concat,join)) ,equalTo(Arrays.asList("helloworldwoo!",",hello,world,woo!"))); } </pre> @param stream Stream to reduce @param reducers Reducers to reduce Stream @return Reduced Stream values as List entries
[ "Simultanously", "reduce", "a", "stream", "with", "multiple", "reducers" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L1530-L1534
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.cycleUntil
public final static <T> Stream<T> cycleUntil(final Stream<T> stream, final Predicate<? super T> predicate) { return Streams.takeUntil(Streams.cycle(stream), predicate); }
java
public final static <T> Stream<T> cycleUntil(final Stream<T> stream, final Predicate<? super T> predicate) { return Streams.takeUntil(Streams.cycle(stream), predicate); }
[ "public", "final", "static", "<", "T", ">", "Stream", "<", "T", ">", "cycleUntil", "(", "final", "Stream", "<", "T", ">", "stream", ",", "final", "Predicate", "<", "?", "super", "T", ">", "predicate", ")", "{", "return", "Streams", ".", "takeUntil", ...
Repeat in a Stream until specified predicate holds <pre> {@code count =0; assertThat(Streams.cycleUntil(Stream.of(1,2,2,3) ,next -> count++>10 ) .collect(CyclopsCollectors.toList()),equalTo(Arrays.asList(1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2))); } </pre> @param predicate repeat while true @return Repeating Stream
[ "Repeat", "in", "a", "Stream", "until", "specified", "predicate", "holds" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L1571-L1573
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.zipSequence
public final static <T, S, R> Stream<R> zipSequence(final Stream<T> stream, final Stream<? extends S> second, final BiFunction<? super T, ? super S, ? extends R> zipper) { final Iterator<T> left = stream.iterator(); final Iterator<? extends S> right = second.iterator(); return Streams.stream(new Iterator<R>() { @Override public boolean hasNext() { return left.hasNext() && right.hasNext(); } @Override public R next() { return zipper.apply(left.next(), right.next()); } }); }
java
public final static <T, S, R> Stream<R> zipSequence(final Stream<T> stream, final Stream<? extends S> second, final BiFunction<? super T, ? super S, ? extends R> zipper) { final Iterator<T> left = stream.iterator(); final Iterator<? extends S> right = second.iterator(); return Streams.stream(new Iterator<R>() { @Override public boolean hasNext() { return left.hasNext() && right.hasNext(); } @Override public R next() { return zipper.apply(left.next(), right.next()); } }); }
[ "public", "final", "static", "<", "T", ",", "S", ",", "R", ">", "Stream", "<", "R", ">", "zipSequence", "(", "final", "Stream", "<", "T", ">", "stream", ",", "final", "Stream", "<", "?", "extends", "S", ">", "second", ",", "final", "BiFunction", "<...
Generic zip function. E.g. Zipping a Stream and a Sequence <pre> {@code Stream<List<Integer>> zipped = Streams.zip(Stream.of(1,2,3) ,ReactiveSeq.of(2,3,4), (a,b) -> Arrays.asList(a,b)); List<Integer> zip = zipped.collect(CyclopsCollectors.toList()).getValue(1); assertThat(zip.getValue(0),equalTo(2)); assertThat(zip.getValue(1),equalTo(3)); } </pre> @param second Monad to zip with @param zipper Zipping function @return Stream zipping two Monads
[ "Generic", "zip", "function", ".", "E", ".", "g", ".", "Zipping", "a", "Stream", "and", "a", "Sequence" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L1596-L1614
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.grouped
public final static <T> Stream<Vector<T>> grouped(final Stream<T> stream, final int groupSize) { return StreamSupport.stream(new GroupingSpliterator<>(stream.spliterator(),()->Vector.empty(), c->Vector.fromIterable(c),groupSize),stream.isParallel()); }
java
public final static <T> Stream<Vector<T>> grouped(final Stream<T> stream, final int groupSize) { return StreamSupport.stream(new GroupingSpliterator<>(stream.spliterator(),()->Vector.empty(), c->Vector.fromIterable(c),groupSize),stream.isParallel()); }
[ "public", "final", "static", "<", "T", ">", "Stream", "<", "Vector", "<", "T", ">", ">", "grouped", "(", "final", "Stream", "<", "T", ">", "stream", ",", "final", "int", "groupSize", ")", "{", "return", "StreamSupport", ".", "stream", "(", "new", "Gr...
Group elements in a Stream by size <pre> {@code List<List<Integer>> list = Streams.grouped(Stream.of(1,2,3,4,5,6) ,3) .collect(CyclopsCollectors.toList()); assertThat(list.getValue(0),hasItems(1,2,3)); assertThat(list.getValue(1),hasItems(4,5,6)); } </pre> @param stream Stream to group @param groupSize Size of each Group @return Stream with elements grouped by size
[ "Group", "elements", "in", "a", "Stream", "by", "size" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L1770-L1775
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.scanLeft
public final static <T> Stream<T> scanLeft(final Stream<T> stream, final Monoid<T> monoid) { final Iterator<T> it = stream.iterator(); return Streams.stream(new Iterator<T>() { boolean init = false; T next = monoid.zero(); @Override public boolean hasNext() { if (!init) return true; return it.hasNext(); } @Override public T next() { if (!init) { init = true; return monoid.zero(); } return next = monoid .apply(next, it.next()); } }); }
java
public final static <T> Stream<T> scanLeft(final Stream<T> stream, final Monoid<T> monoid) { final Iterator<T> it = stream.iterator(); return Streams.stream(new Iterator<T>() { boolean init = false; T next = monoid.zero(); @Override public boolean hasNext() { if (!init) return true; return it.hasNext(); } @Override public T next() { if (!init) { init = true; return monoid.zero(); } return next = monoid .apply(next, it.next()); } }); }
[ "public", "final", "static", "<", "T", ">", "Stream", "<", "T", ">", "scanLeft", "(", "final", "Stream", "<", "T", ">", "stream", ",", "final", "Monoid", "<", "T", ">", "monoid", ")", "{", "final", "Iterator", "<", "T", ">", "it", "=", "stream", ...
Scan left using supplied Monoid <pre> {@code assertEquals(asList("", "a", "ab", "abc"), Streams.scanLeft(Stream.of("a", "b", "c"),Reducers.toString("")) .collect(CyclopsCollectors.toList()); } </pre> @param monoid @return
[ "Scan", "left", "using", "supplied", "Monoid" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L1839-L1866
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.xMatch
public static <T> boolean xMatch(final Stream<T> stream, final int num, final Predicate<? super T> c) { return stream.filter(t -> c.test(t)) .collect(java.util.stream.Collectors.counting()) == num; }
java
public static <T> boolean xMatch(final Stream<T> stream, final int num, final Predicate<? super T> c) { return stream.filter(t -> c.test(t)) .collect(java.util.stream.Collectors.counting()) == num; }
[ "public", "static", "<", "T", ">", "boolean", "xMatch", "(", "final", "Stream", "<", "T", ">", "stream", ",", "final", "int", "num", ",", "final", "Predicate", "<", "?", "super", "T", ">", "c", ")", "{", "return", "stream", ".", "filter", "(", "t",...
Check that there are specified number of matches of predicate in the Stream <pre> {@code assertTrue(Streams.xMatch(Stream.of(1,2,3,5,6,7),3, i->i>4)); } </pre>
[ "Check", "that", "there", "are", "specified", "number", "of", "matches", "of", "predicate", "in", "the", "Stream" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L1878-L1882
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.foldMap
public final static <T, R> R foldMap(final Stream<T> stream, final Function<? super T, ? extends R> mapper, final Monoid<R> reducer) { return reducer.foldLeft(stream.map(mapper)); }
java
public final static <T, R> R foldMap(final Stream<T> stream, final Function<? super T, ? extends R> mapper, final Monoid<R> reducer) { return reducer.foldLeft(stream.map(mapper)); }
[ "public", "final", "static", "<", "T", ",", "R", ">", "R", "foldMap", "(", "final", "Stream", "<", "T", ">", "stream", ",", "final", "Function", "<", "?", "super", "T", ",", "?", "extends", "R", ">", "mapper", ",", "final", "Monoid", "<", "R", ">...
Attempt to transform this Stream to the same type as the supplied Monoid, using supplied function Then use Monoid to reduce values @param mapper Function to transform Monad type @param reducer Monoid to reduce values @return Reduce result
[ "Attempt", "to", "transform", "this", "Stream", "to", "the", "same", "type", "as", "the", "supplied", "Monoid", "using", "supplied", "function", "Then", "use", "Monoid", "to", "reduce", "values" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L1952-L1954
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.intersperse
public static <T> Stream<T> intersperse(final Stream<T> stream, final T value) { return stream.flatMap(t -> Stream.of(value, t)) .skip(1); }
java
public static <T> Stream<T> intersperse(final Stream<T> stream, final T value) { return stream.flatMap(t -> Stream.of(value, t)) .skip(1); }
[ "public", "static", "<", "T", ">", "Stream", "<", "T", ">", "intersperse", "(", "final", "Stream", "<", "T", ">", "stream", ",", "final", "T", "value", ")", "{", "return", "stream", ".", "flatMap", "(", "t", "->", "Stream", ".", "of", "(", "value",...
Returns a stream with a given value interspersed between any two values of this stream. <pre> {@code assertThat(Arrays.asList(1, 0, 2, 0, 3, 0, 4), equalTo( Streams.intersperse(Stream.of(1, 2, 3, 4),0)); } </pre>
[ "Returns", "a", "stream", "with", "a", "given", "value", "interspersed", "between", "any", "two", "values", "of", "this", "stream", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L2130-L2133
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.ofType
@SuppressWarnings("unchecked") public static <T, U> Stream<U> ofType(final Stream<T> stream, final Class<? extends U> type) { return stream.filter(type::isInstance) .map(t -> (U) t); }
java
@SuppressWarnings("unchecked") public static <T, U> Stream<U> ofType(final Stream<T> stream, final Class<? extends U> type) { return stream.filter(type::isInstance) .map(t -> (U) t); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ",", "U", ">", "Stream", "<", "U", ">", "ofType", "(", "final", "Stream", "<", "T", ">", "stream", ",", "final", "Class", "<", "?", "extends", "U", ">", "type", ")", ...
Keep only those elements in a stream that are of a given type. assertThat(Arrays.asList(1, 2, 3), equalTo( Streams.ofType(Stream.of(1, "a", 2, "b", 3,Integer.class));
[ "Keep", "only", "those", "elements", "in", "a", "stream", "that", "are", "of", "a", "given", "type", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L2143-L2147
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.flatMapCharSequence
public final static <T> Stream<Character> flatMapCharSequence(final Stream<T> stream, final Function<? super T, CharSequence> fn) { return stream.flatMap(fn.andThen(CharSequence::chars) .andThen(s->s.mapToObj(i->Character.toChars(i)[0]))); }
java
public final static <T> Stream<Character> flatMapCharSequence(final Stream<T> stream, final Function<? super T, CharSequence> fn) { return stream.flatMap(fn.andThen(CharSequence::chars) .andThen(s->s.mapToObj(i->Character.toChars(i)[0]))); }
[ "public", "final", "static", "<", "T", ">", "Stream", "<", "Character", ">", "flatMapCharSequence", "(", "final", "Stream", "<", "T", ">", "stream", ",", "final", "Function", "<", "?", "super", "T", ",", "CharSequence", ">", "fn", ")", "{", "return", "...
rename -flatMapCharSequence
[ "rename", "-", "flatMapCharSequence" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L2265-L2268
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.flatMapFile
public final static <T> Stream<String> flatMapFile(final Stream<T> stream, final Function<? super T, File> fn) { return stream.flatMap(fn.andThen(f->ExceptionSoftener.softenSupplier(()->Files.lines(Paths.get(f.getAbsolutePath()) ) ).get())); }
java
public final static <T> Stream<String> flatMapFile(final Stream<T> stream, final Function<? super T, File> fn) { return stream.flatMap(fn.andThen(f->ExceptionSoftener.softenSupplier(()->Files.lines(Paths.get(f.getAbsolutePath()) ) ).get())); }
[ "public", "final", "static", "<", "T", ">", "Stream", "<", "String", ">", "flatMapFile", "(", "final", "Stream", "<", "T", ">", "stream", ",", "final", "Function", "<", "?", "super", "T", ",", "File", ">", "fn", ")", "{", "return", "stream", ".", "...
Perform a flatMap operation where the result will be a flattened stream of Strings from the text loaded from the supplied files. <pre> {@code List<String> result = Streams.liftAndBindFile(Stream.of("input.file") .map(getClass().getClassLoader()::getResource) .peek(System.out::println) .map(URL::getFile) ,File::new) .toList(); assertThat(result,equalTo(Arrays.asList("hello","world"))); } </pre> @param fn @return
[ "Perform", "a", "flatMap", "operation", "where", "the", "result", "will", "be", "a", "flattened", "stream", "of", "Strings", "from", "the", "text", "loaded", "from", "the", "supplied", "files", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L2293-L2295
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.flatMapURL
public final static <T> Stream<String> flatMapURL(final Stream<T> stream, final Function<? super T, URL> fn) { return stream.flatMap(fn.andThen(url -> ExceptionSoftener.softenSupplier(() -> { final BufferedReader in = new BufferedReader( new InputStreamReader( url.openStream())); return in.lines(); }) .get())); }
java
public final static <T> Stream<String> flatMapURL(final Stream<T> stream, final Function<? super T, URL> fn) { return stream.flatMap(fn.andThen(url -> ExceptionSoftener.softenSupplier(() -> { final BufferedReader in = new BufferedReader( new InputStreamReader( url.openStream())); return in.lines(); }) .get())); }
[ "public", "final", "static", "<", "T", ">", "Stream", "<", "String", ">", "flatMapURL", "(", "final", "Stream", "<", "T", ">", "stream", ",", "final", "Function", "<", "?", "super", "T", ",", "URL", ">", "fn", ")", "{", "return", "stream", ".", "fl...
Perform a flatMap operation where the result will be a flattened stream of Strings from the text loaded from the supplied URLs <pre> {@code List<String> result = Streams.liftAndBindURL(Stream.of("input.file") ,getClass().getClassLoader()::getResource) .collect(CyclopsCollectors.toList(); assertThat(result,equalTo(Arrays.asList("hello","world"))); } </pre> @param fn @return
[ "Perform", "a", "flatMap", "operation", "where", "the", "result", "will", "be", "a", "flattened", "stream", "of", "Strings", "from", "the", "text", "loaded", "from", "the", "supplied", "URLs" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L2315-L2325
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.flatMapBufferedReader
public final static <T> Stream<String> flatMapBufferedReader(final Stream<T> stream, final Function<? super T, BufferedReader> fn) { return stream.flatMap(fn.andThen(in -> ExceptionSoftener.softenSupplier(() -> { return in.lines(); }) .get())); }
java
public final static <T> Stream<String> flatMapBufferedReader(final Stream<T> stream, final Function<? super T, BufferedReader> fn) { return stream.flatMap(fn.andThen(in -> ExceptionSoftener.softenSupplier(() -> { return in.lines(); }) .get())); }
[ "public", "final", "static", "<", "T", ">", "Stream", "<", "String", ">", "flatMapBufferedReader", "(", "final", "Stream", "<", "T", ">", "stream", ",", "final", "Function", "<", "?", "super", "T", ",", "BufferedReader", ">", "fn", ")", "{", "return", ...
Perform a flatMap operation where the result will be a flattened stream of Strings from the text loaded from the supplied BufferedReaders <pre> List<String> result = Streams.liftAndBindBufferedReader(Stream.of("input.file") .map(getClass().getClassLoader()::getResourceAsStream) .map(InputStreamReader::new) ,BufferedReader::new) .collect(CyclopsCollectors.toList(); assertThat(result,equalTo(Arrays.asList("hello","world"))); </pre> @param fn @return
[ "Perform", "a", "flatMap", "operation", "where", "the", "result", "will", "be", "a", "flattened", "stream", "of", "Strings", "from", "the", "text", "loaded", "from", "the", "supplied", "BufferedReaders" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L2346-L2353
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.groupedStatefullyUntil
public final static <T> Stream<Seq<T>> groupedStatefullyUntil(final Stream<T> stream, final BiPredicate<Seq<? super T>, ? super T> predicate) { return StreamSupport.stream(new GroupedStatefullySpliterator<>(stream.spliterator(),()->Seq.of(),Function.identity(),predicate.negate()),stream.isParallel()); }
java
public final static <T> Stream<Seq<T>> groupedStatefullyUntil(final Stream<T> stream, final BiPredicate<Seq<? super T>, ? super T> predicate) { return StreamSupport.stream(new GroupedStatefullySpliterator<>(stream.spliterator(),()->Seq.of(),Function.identity(),predicate.negate()),stream.isParallel()); }
[ "public", "final", "static", "<", "T", ">", "Stream", "<", "Seq", "<", "T", ">", ">", "groupedStatefullyUntil", "(", "final", "Stream", "<", "T", ">", "stream", ",", "final", "BiPredicate", "<", "Seq", "<", "?", "super", "T", ">", ",", "?", "super", ...
Group data in a Stream using knowledge of the current batch and the next entry to determing grouping limits @see Traversable#groupedUntil(BiPredicate) @param stream Stream to group @param predicate Predicate to determine grouping @return Stream grouped into Lists determined by predicate
[ "Group", "data", "in", "a", "Stream", "using", "knowledge", "of", "the", "current", "batch", "and", "the", "next", "entry", "to", "determing", "grouping", "limits" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L2600-L2603
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.groupedUntil
public final static <T> Stream<Seq<T>> groupedUntil(final Stream<T> stream, final Predicate<? super T> predicate) { return groupedWhile(stream, predicate.negate()); }
java
public final static <T> Stream<Seq<T>> groupedUntil(final Stream<T> stream, final Predicate<? super T> predicate) { return groupedWhile(stream, predicate.negate()); }
[ "public", "final", "static", "<", "T", ">", "Stream", "<", "Seq", "<", "T", ">", ">", "groupedUntil", "(", "final", "Stream", "<", "T", ">", "stream", ",", "final", "Predicate", "<", "?", "super", "T", ">", "predicate", ")", "{", "return", "groupedWh...
Group a Stream until the supplied predicate holds @see ReactiveSeq#groupedUntil(Predicate) @param stream Stream to group @param predicate Predicate to determine grouping @return Stream grouped into Lists determined by predicate
[ "Group", "a", "Stream", "until", "the", "supplied", "predicate", "holds" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L2651-L2653
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.debounce
public final static <T> Stream<T> debounce(final Stream<T> stream, final long time, final TimeUnit t) { return new DebounceOperator<>( stream).debounce(time, t); }
java
public final static <T> Stream<T> debounce(final Stream<T> stream, final long time, final TimeUnit t) { return new DebounceOperator<>( stream).debounce(time, t); }
[ "public", "final", "static", "<", "T", ">", "Stream", "<", "T", ">", "debounce", "(", "final", "Stream", "<", "T", ">", "stream", ",", "final", "long", "time", ",", "final", "TimeUnit", "t", ")", "{", "return", "new", "DebounceOperator", "<>", "(", "...
Allow one element through per time period, drop all other elements in that time period @see ReactiveSeq#debounce(long, TimeUnit) @param stream Stream to debounce @param time Time to applyHKT debouncing over @param t Time unit for debounce period @return Stream with debouncing applied
[ "Allow", "one", "element", "through", "per", "time", "period", "drop", "all", "other", "elements", "in", "that", "time", "period" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L2706-L2709
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/Streams.java
Streams.onePer
public final static <T> Stream<T> onePer(final Stream<T> stream, final long time, final TimeUnit t) { return new OnePerOperator<>( stream).onePer(time, t); }
java
public final static <T> Stream<T> onePer(final Stream<T> stream, final long time, final TimeUnit t) { return new OnePerOperator<>( stream).onePer(time, t); }
[ "public", "final", "static", "<", "T", ">", "Stream", "<", "T", ">", "onePer", "(", "final", "Stream", "<", "T", ">", "stream", ",", "final", "long", "time", ",", "final", "TimeUnit", "t", ")", "{", "return", "new", "OnePerOperator", "<>", "(", "stre...
emit one element per time period @see ReactiveSeq#onePer(long, TimeUnit) @param stream Stream to emit one element per time period from @param time Time period @param t Time Pure @return Stream with slowed emission
[ "emit", "one", "element", "per", "time", "period" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/Streams.java#L2721-L2724
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/util/box/MutableLong.java
MutableLong.fromExternal
public static MutableLong fromExternal(final LongSupplier s, final LongConsumer c) { return new MutableLong() { @Override public long getAsLong() { return s.getAsLong(); } @Override public Long get() { return getAsLong(); } @Override public MutableLong set(final long value) { c.accept(value); return this; } }; }
java
public static MutableLong fromExternal(final LongSupplier s, final LongConsumer c) { return new MutableLong() { @Override public long getAsLong() { return s.getAsLong(); } @Override public Long get() { return getAsLong(); } @Override public MutableLong set(final long value) { c.accept(value); return this; } }; }
[ "public", "static", "MutableLong", "fromExternal", "(", "final", "LongSupplier", "s", ",", "final", "LongConsumer", "c", ")", "{", "return", "new", "MutableLong", "(", ")", "{", "@", "Override", "public", "long", "getAsLong", "(", ")", "{", "return", "s", ...
Construct a MutableLong that gets and sets an external value using the provided Supplier and Consumer e.g. <pre> {@code MutableLong mutable = MutableLong.fromExternal(()->!this.value,val->!this.value); } </pre> @param s Supplier of an external value @param c Consumer that sets an external value @return MutableLong that gets / sets an external (mutable) value
[ "Construct", "a", "MutableLong", "that", "gets", "and", "sets", "an", "external", "value", "using", "the", "provided", "Supplier", "and", "Consumer" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/util/box/MutableLong.java#L81-L99
train
aol/cyclops
cyclops-futurestream/src/main/java/com/oath/cyclops/react/StageWithResults.java
StageWithResults.submit
public <R> R submit(final Function<RS, R> fn) { return submit(() -> fn.apply(this.results)); }
java
public <R> R submit(final Function<RS, R> fn) { return submit(() -> fn.apply(this.results)); }
[ "public", "<", "R", ">", "R", "submit", "(", "final", "Function", "<", "RS", ",", "R", ">", "fn", ")", "{", "return", "submit", "(", "(", ")", "->", "fn", ".", "apply", "(", "this", ".", "results", ")", ")", ";", "}" ]
This method allows the SimpleReact Executor to be reused by JDK parallel streams. It is best used when collectResults and block are called explicitly for finer grained control over the blocking conditions. @param fn Function that contains parallelStream code to be executed by the SimpleReact ForkJoinPool (if configured)
[ "This", "method", "allows", "the", "SimpleReact", "Executor", "to", "be", "reused", "by", "JDK", "parallel", "streams", ".", "It", "is", "best", "used", "when", "collectResults", "and", "block", "are", "called", "explicitly", "for", "finer", "grained", "contro...
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/com/oath/cyclops/react/StageWithResults.java#L38-L40
train
aol/cyclops
cyclops-futurestream/src/main/java/com/oath/cyclops/react/StageWithResults.java
StageWithResults.submit
public <T> T submit(final Callable<T> callable) { if (taskExecutor instanceof ForkJoinPool) { try { return ((ForkJoinPool) taskExecutor).submit(callable) .get(); } catch (final ExecutionException e) { throw ExceptionSoftener.throwSoftenedException(e); } catch (final InterruptedException e) { Thread.currentThread() .interrupt(); throw ExceptionSoftener.throwSoftenedException(e); } } try { return callable.call(); } catch (final Exception e) { throw new RuntimeException( e); } }
java
public <T> T submit(final Callable<T> callable) { if (taskExecutor instanceof ForkJoinPool) { try { return ((ForkJoinPool) taskExecutor).submit(callable) .get(); } catch (final ExecutionException e) { throw ExceptionSoftener.throwSoftenedException(e); } catch (final InterruptedException e) { Thread.currentThread() .interrupt(); throw ExceptionSoftener.throwSoftenedException(e); } } try { return callable.call(); } catch (final Exception e) { throw new RuntimeException( e); } }
[ "public", "<", "T", ">", "T", "submit", "(", "final", "Callable", "<", "T", ">", "callable", ")", "{", "if", "(", "taskExecutor", "instanceof", "ForkJoinPool", ")", "{", "try", "{", "return", "(", "(", "ForkJoinPool", ")", "taskExecutor", ")", ".", "su...
This method allows the SimpleReact Executor to be reused by JDK parallel streams @param callable that contains code
[ "This", "method", "allows", "the", "SimpleReact", "Executor", "to", "be", "reused", "by", "JDK", "parallel", "streams" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/com/oath/cyclops/react/StageWithResults.java#L47-L69
train
aol/cyclops
cyclops/src/main/java/cyclops/function/Memoize.java
Memoize.memoizeSupplierAsync
public static <R> Function0<R> memoizeSupplierAsync(final Supplier<R> fn, ScheduledExecutorService ex, long updateRateInMillis){ return ()-> Memoize.memoizeFunctionAsync(a-> fn.get(),ex,updateRateInMillis) .apply("k"); }
java
public static <R> Function0<R> memoizeSupplierAsync(final Supplier<R> fn, ScheduledExecutorService ex, long updateRateInMillis){ return ()-> Memoize.memoizeFunctionAsync(a-> fn.get(),ex,updateRateInMillis) .apply("k"); }
[ "public", "static", "<", "R", ">", "Function0", "<", "R", ">", "memoizeSupplierAsync", "(", "final", "Supplier", "<", "R", ">", "fn", ",", "ScheduledExecutorService", "ex", ",", "long", "updateRateInMillis", ")", "{", "return", "(", ")", "->", "Memoize", "...
Memoize a Supplier and update the cached values asynchronously using the provided Scheduled Executor Service Does not support null keys @param fn Supplier to Memoize @param ex Scheduled Executor Service @param updateRateInMillis Time in millis between async updates @param <R> Return type of Function @return Memoized asynchronously updating function
[ "Memoize", "a", "Supplier", "and", "update", "the", "cached", "values", "asynchronously", "using", "the", "provided", "Scheduled", "Executor", "Service", "Does", "not", "support", "null", "keys" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/function/Memoize.java#L74-L77
train
aol/cyclops
cyclops/src/main/java/cyclops/function/Memoize.java
Memoize.memoizeBiFunction
public static <T1, T2, R> Function2<T1, T2, R> memoizeBiFunction(final BiFunction<T1, T2, R> fn) { Function1<Tuple2<T1, T2>, R> memoise2 = memoizeFunction((final Tuple2<T1, T2> pair) -> fn.apply(pair._1(), pair._2())); return (t1, t2) -> memoise2.apply(tuple(t1, t2)); }
java
public static <T1, T2, R> Function2<T1, T2, R> memoizeBiFunction(final BiFunction<T1, T2, R> fn) { Function1<Tuple2<T1, T2>, R> memoise2 = memoizeFunction((final Tuple2<T1, T2> pair) -> fn.apply(pair._1(), pair._2())); return (t1, t2) -> memoise2.apply(tuple(t1, t2)); }
[ "public", "static", "<", "T1", ",", "T2", ",", "R", ">", "Function2", "<", "T1", ",", "T2", ",", "R", ">", "memoizeBiFunction", "(", "final", "BiFunction", "<", "T1", ",", "T2", ",", "R", ">", "fn", ")", "{", "Function1", "<", "Tuple2", "<", "T1"...
Convert a BiFunction into one that caches it's result @param fn BiFunction to memoise @return Memoised BiFunction
[ "Convert", "a", "BiFunction", "into", "one", "that", "caches", "it", "s", "result" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/function/Memoize.java#L253-L256
train
aol/cyclops
cyclops/src/main/java/cyclops/function/Memoize.java
Memoize.memoizeTriFunction
public static <T1, T2, T3, R> Function3<T1, T2, T3, R> memoizeTriFunction(final Function3<T1, T2, T3, R> fn, final Cacheable<R> cache) { Function1<Tuple3<T1, T2, T3>, R> memoise2 = memoizeFunction((final Tuple3<T1, T2, T3> triple) -> fn.apply(triple._1(), triple._2(), triple._3()), cache); return (t1, t2, t3) -> memoise2.apply(tuple(t1, t2, t3)); }
java
public static <T1, T2, T3, R> Function3<T1, T2, T3, R> memoizeTriFunction(final Function3<T1, T2, T3, R> fn, final Cacheable<R> cache) { Function1<Tuple3<T1, T2, T3>, R> memoise2 = memoizeFunction((final Tuple3<T1, T2, T3> triple) -> fn.apply(triple._1(), triple._2(), triple._3()), cache); return (t1, t2, t3) -> memoise2.apply(tuple(t1, t2, t3)); }
[ "public", "static", "<", "T1", ",", "T2", ",", "T3", ",", "R", ">", "Function3", "<", "T1", ",", "T2", ",", "T3", ",", "R", ">", "memoizeTriFunction", "(", "final", "Function3", "<", "T1", ",", "T2", ",", "T3", ",", "R", ">", "fn", ",", "final"...
Convert a TriFunction into one that caches it's result @param fn TriFunction to memoise @param cache Cachable to store the results @return Memoised TriFunction
[ "Convert", "a", "TriFunction", "into", "one", "that", "caches", "it", "s", "result" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/function/Memoize.java#L301-L304
train
aol/cyclops
cyclops/src/main/java/cyclops/function/Memoize.java
Memoize.memoizeQuadFunction
public static <T1, T2, T3, T4, R> Function4<T1, T2, T3, T4, R> memoizeQuadFunction(final Function4<T1, T2, T3, T4, R> fn) { Function1<Tuple4<T1, T2, T3, T4>, R> memoise2 = memoizeFunction((final Tuple4<T1, T2, T3, T4> quad) -> fn.apply(quad._1(), quad._2(), quad._3(), quad._4())); return (t1, t2, t3, t4) -> memoise2.apply(tuple(t1, t2, t3, t4)); }
java
public static <T1, T2, T3, T4, R> Function4<T1, T2, T3, T4, R> memoizeQuadFunction(final Function4<T1, T2, T3, T4, R> fn) { Function1<Tuple4<T1, T2, T3, T4>, R> memoise2 = memoizeFunction((final Tuple4<T1, T2, T3, T4> quad) -> fn.apply(quad._1(), quad._2(), quad._3(), quad._4())); return (t1, t2, t3, t4) -> memoise2.apply(tuple(t1, t2, t3, t4)); }
[ "public", "static", "<", "T1", ",", "T2", ",", "T3", ",", "T4", ",", "R", ">", "Function4", "<", "T1", ",", "T2", ",", "T3", ",", "T4", ",", "R", ">", "memoizeQuadFunction", "(", "final", "Function4", "<", "T1", ",", "T2", ",", "T3", ",", "T4",...
Convert a QuadFunction into one that caches it's result @param fn QuadFunction to memoise @return Memoised TriFunction
[ "Convert", "a", "QuadFunction", "into", "one", "that", "caches", "it", "s", "result" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/function/Memoize.java#L324-L327
train
aol/cyclops
cyclops/src/main/java/cyclops/function/Memoize.java
Memoize.memoizePredicate
public static <T> Predicate<T> memoizePredicate(final Predicate<T> p, final Cacheable<Boolean> cache) { final Function<T, Boolean> memoised = memoizeFunction((Function<T, Boolean>) t -> p.test(t), cache); LazyImmutable<Boolean> nullR = LazyImmutable.def(); return (t) -> t==null? nullR.computeIfAbsent(()->p.test(null)) : memoised.apply(t); }
java
public static <T> Predicate<T> memoizePredicate(final Predicate<T> p, final Cacheable<Boolean> cache) { final Function<T, Boolean> memoised = memoizeFunction((Function<T, Boolean>) t -> p.test(t), cache); LazyImmutable<Boolean> nullR = LazyImmutable.def(); return (t) -> t==null? nullR.computeIfAbsent(()->p.test(null)) : memoised.apply(t); }
[ "public", "static", "<", "T", ">", "Predicate", "<", "T", ">", "memoizePredicate", "(", "final", "Predicate", "<", "T", ">", "p", ",", "final", "Cacheable", "<", "Boolean", ">", "cache", ")", "{", "final", "Function", "<", "T", ",", "Boolean", ">", "...
Convert a Predicate into one that caches it's result @param p Predicate to memoise @param cache Cachable to store the results @return Memoised Predicate
[ "Convert", "a", "Predicate", "into", "one", "that", "caches", "it", "s", "result" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/function/Memoize.java#L388-L392
train
aol/cyclops
cyclops-reactor-integration/src/main/java/cyclops/companion/reactor/Monos.java
Monos.anyOf
public static <T> Mono<T> anyOf(Mono<T>... fts) { return Mono.from(Future.anyOf(futures(fts))); }
java
public static <T> Mono<T> anyOf(Mono<T>... fts) { return Mono.from(Future.anyOf(futures(fts))); }
[ "public", "static", "<", "T", ">", "Mono", "<", "T", ">", "anyOf", "(", "Mono", "<", "T", ">", "...", "fts", ")", "{", "return", "Mono", ".", "from", "(", "Future", ".", "anyOf", "(", "futures", "(", "fts", ")", ")", ")", ";", "}" ]
Select the first Mono to complete @see CompletableFuture#anyOf(CompletableFuture...) @param fts Monos to race @return First Mono to complete
[ "Select", "the", "first", "Mono", "to", "complete" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-reactor-integration/src/main/java/cyclops/companion/reactor/Monos.java#L102-L105
train
aol/cyclops
cyclops-reactor-integration/src/main/java/cyclops/companion/reactor/Monos.java
Monos.forEach3
public static <T1, T2, R1, R2, R> Mono<R> forEach3(Mono<? extends T1> value1, Function<? super T1, ? extends Mono<R1>> value2, BiFunction<? super T1, ? super R1, ? extends Mono<R2>> value3, Function3<? super T1, ? super R1, ? super R2, ? extends R> yieldingFunction) { Future<? extends R> res = Future.fromPublisher(value1).flatMap(in -> { Future<R1> a = Future.fromPublisher(value2.apply(in)); return a.flatMap(ina -> { Future<R2> b = Future.fromPublisher(value3.apply(in, ina)); return b.map(in2 -> yieldingFunction.apply(in, ina, in2)); }); }); return Mono.from(res); }
java
public static <T1, T2, R1, R2, R> Mono<R> forEach3(Mono<? extends T1> value1, Function<? super T1, ? extends Mono<R1>> value2, BiFunction<? super T1, ? super R1, ? extends Mono<R2>> value3, Function3<? super T1, ? super R1, ? super R2, ? extends R> yieldingFunction) { Future<? extends R> res = Future.fromPublisher(value1).flatMap(in -> { Future<R1> a = Future.fromPublisher(value2.apply(in)); return a.flatMap(ina -> { Future<R2> b = Future.fromPublisher(value3.apply(in, ina)); return b.map(in2 -> yieldingFunction.apply(in, ina, in2)); }); }); return Mono.from(res); }
[ "public", "static", "<", "T1", ",", "T2", ",", "R1", ",", "R2", ",", "R", ">", "Mono", "<", "R", ">", "forEach3", "(", "Mono", "<", "?", "extends", "T1", ">", "value1", ",", "Function", "<", "?", "super", "T1", ",", "?", "extends", "Mono", "<",...
Perform a For Comprehension over a Mono, accepting 2 generating functions. This results in a three level nested internal iteration over the provided Monos. <pre> {@code import static cyclops.companion.reactor.Monos.forEach3; forEach3(Mono.just(1), a-> Mono.just(a+1), (a,b) -> Mono.<Integer>just(a+b), Tuple::tuple) } </pre> @param value1 top level Mono @param value2 Nested Mono @param value3 Nested Mono @param yieldingFunction Generates a result per combination @return Mono with a combined value generated by the yielding function
[ "Perform", "a", "For", "Comprehension", "over", "a", "Mono", "accepting", "2", "generating", "functions", ".", "This", "results", "in", "a", "three", "level", "nested", "internal", "iteration", "over", "the", "provided", "Monos", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-reactor-integration/src/main/java/cyclops/companion/reactor/Monos.java#L270-L290
train
aol/cyclops
cyclops-reactor-integration/src/main/java/cyclops/companion/reactor/Monos.java
Monos.forEach
public static <T, R1, R> Mono<R> forEach(Mono<? extends T> value1, Function<? super T, Mono<R1>> value2, BiFunction<? super T, ? super R1, ? extends R> yieldingFunction) { Future<R> res = Future.fromPublisher(value1).flatMap(in -> { Future<R1> a = Future.fromPublisher(value2.apply(in)); return a.map(ina -> yieldingFunction.apply(in, ina)); }); return Mono.from(res); }
java
public static <T, R1, R> Mono<R> forEach(Mono<? extends T> value1, Function<? super T, Mono<R1>> value2, BiFunction<? super T, ? super R1, ? extends R> yieldingFunction) { Future<R> res = Future.fromPublisher(value1).flatMap(in -> { Future<R1> a = Future.fromPublisher(value2.apply(in)); return a.map(ina -> yieldingFunction.apply(in, ina)); }); return Mono.from(res); }
[ "public", "static", "<", "T", ",", "R1", ",", "R", ">", "Mono", "<", "R", ">", "forEach", "(", "Mono", "<", "?", "extends", "T", ">", "value1", ",", "Function", "<", "?", "super", "T", ",", "Mono", "<", "R1", ">", ">", "value2", ",", "BiFunctio...
Perform a For Comprehension over a Mono, accepting a generating function. This results in a two level nested internal iteration over the provided Monos. <pre> {@code import static cyclops.companion.reactor.Monos.forEach; forEach(Mono.just(1), a-> Mono.just(a+1), Tuple::tuple) } </pre> @param value1 top level Mono @param value2 Nested Mono @param yieldingFunction Generates a result per combination @return Mono with a combined value generated by the yielding function
[ "Perform", "a", "For", "Comprehension", "over", "a", "Mono", "accepting", "a", "generating", "function", ".", "This", "results", "in", "a", "two", "level", "nested", "internal", "iteration", "over", "the", "provided", "Monos", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-reactor-integration/src/main/java/cyclops/companion/reactor/Monos.java#L315-L330
train
aol/cyclops
cyclops-reactor-integration/src/main/java/cyclops/companion/reactor/Monos.java
Monos.fromIterable
public static <T> Mono<T> fromIterable(Iterable<T> t) { return Mono.from(Flux.fromIterable(t)); }
java
public static <T> Mono<T> fromIterable(Iterable<T> t) { return Mono.from(Flux.fromIterable(t)); }
[ "public", "static", "<", "T", ">", "Mono", "<", "T", ">", "fromIterable", "(", "Iterable", "<", "T", ">", "t", ")", "{", "return", "Mono", ".", "from", "(", "Flux", ".", "fromIterable", "(", "t", ")", ")", ";", "}" ]
Construct a Mono from Iterable by taking the first value from Iterable @param t Iterable to populate Mono from @return Mono containing first element from Iterable (or empty Mono)
[ "Construct", "a", "Mono", "from", "Iterable", "by", "taking", "the", "first", "value", "from", "Iterable" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-reactor-integration/src/main/java/cyclops/companion/reactor/Monos.java#L398-L400
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/util/box/MutableShort.java
MutableShort.fromExternal
public static MutableShort fromExternal(final Supplier<Short> s, final Consumer<Short> c) { return new MutableShort() { @Override public short getAsShort() { return s.get(); } @Override public Short get() { return getAsShort(); } @Override public MutableShort set(final short value) { c.accept(value); return this; } }; }
java
public static MutableShort fromExternal(final Supplier<Short> s, final Consumer<Short> c) { return new MutableShort() { @Override public short getAsShort() { return s.get(); } @Override public Short get() { return getAsShort(); } @Override public MutableShort set(final short value) { c.accept(value); return this; } }; }
[ "public", "static", "MutableShort", "fromExternal", "(", "final", "Supplier", "<", "Short", ">", "s", ",", "final", "Consumer", "<", "Short", ">", "c", ")", "{", "return", "new", "MutableShort", "(", ")", "{", "@", "Override", "public", "short", "getAsShor...
Construct a MutableShort that gets and sets an external value using the provided Supplier and Consumer e.g. <pre> {@code MutableShort mutable = MutableShort.fromExternal(()->!this.value,val->!this.value); } </pre> @param s Supplier of an external value @param c Consumer that sets an external value @return MutableShort that gets / sets an external (mutable) value
[ "Construct", "a", "MutableShort", "that", "gets", "and", "sets", "an", "external", "value", "using", "the", "provided", "Supplier", "and", "Consumer" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/util/box/MutableShort.java#L81-L99
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/internal/stream/SeqUtils.java
SeqUtils.cycle
public static <U> Stream<U> cycle(final int times, final Streamable<U> s) { return Stream.iterate(s.stream(), s1 -> s.stream()) .limit(times) .flatMap(Function.identity()); }
java
public static <U> Stream<U> cycle(final int times, final Streamable<U> s) { return Stream.iterate(s.stream(), s1 -> s.stream()) .limit(times) .flatMap(Function.identity()); }
[ "public", "static", "<", "U", ">", "Stream", "<", "U", ">", "cycle", "(", "final", "int", "times", ",", "final", "Streamable", "<", "U", ">", "s", ")", "{", "return", "Stream", ".", "iterate", "(", "s", ".", "stream", "(", ")", ",", "s1", "->", ...
Create a Stream that finitely cycles the provided Streamable, provided number of times <pre> {@code assertThat(StreamUtils.cycle(3,Streamable.of(1,2,2)) .collect(CyclopsCollectors.toList()), equalTo(Arrays.asList(1,2,2,1,2,2,1,2,2))); } </pre> @param s Streamable to cycle @return New cycling stream
[ "Create", "a", "Stream", "that", "finitely", "cycles", "the", "provided", "Streamable", "provided", "number", "of", "times" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/internal/stream/SeqUtils.java#L70-L74
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/internal/stream/SeqUtils.java
SeqUtils.toConcurrentLazyCollection
public static final <A> Collection<A> toConcurrentLazyCollection(final Stream<A> stream) { return toConcurrentLazyCollection(stream.iterator()); }
java
public static final <A> Collection<A> toConcurrentLazyCollection(final Stream<A> stream) { return toConcurrentLazyCollection(stream.iterator()); }
[ "public", "static", "final", "<", "A", ">", "Collection", "<", "A", ">", "toConcurrentLazyCollection", "(", "final", "Stream", "<", "A", ">", "stream", ")", "{", "return", "toConcurrentLazyCollection", "(", "stream", ".", "iterator", "(", ")", ")", ";", "}...
Lazily constructs a Collection from specified Stream. Collections iterator may be safely used concurrently by multiple threads.
[ "Lazily", "constructs", "a", "Collection", "from", "specified", "Stream", ".", "Collections", "iterator", "may", "be", "safely", "used", "concurrently", "by", "multiple", "threads", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/internal/stream/SeqUtils.java#L94-L96
train
aol/cyclops
cyclops-anym/src/main/java/cyclops/monads/transformers/jdk/OptionalT.java
OptionalT.map
@Override public <B> OptionalT<W,B> map(final Function<? super T, ? extends B> f) { return new OptionalT<W,B>( run.map(o -> o.map(f))); }
java
@Override public <B> OptionalT<W,B> map(final Function<? super T, ? extends B> f) { return new OptionalT<W,B>( run.map(o -> o.map(f))); }
[ "@", "Override", "public", "<", "B", ">", "OptionalT", "<", "W", ",", "B", ">", "map", "(", "final", "Function", "<", "?", "super", "T", ",", "?", "extends", "B", ">", "f", ")", "{", "return", "new", "OptionalT", "<", "W", ",", "B", ">", "(", ...
Map the wrapped Optional <pre> {@code OptionalWT.of(AnyM.fromStream(Arrays.asOptionalW(10)) .map(t->t=t+1); //OptionalWT<AnyMSeq<Stream<Optional[11]>>> } </pre> @param f Mapping function for the wrapped Optional @return OptionalWT that applies the transform function to the wrapped Optional
[ "Map", "the", "wrapped", "Optional" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-anym/src/main/java/cyclops/monads/transformers/jdk/OptionalT.java#L129-L133
train
aol/cyclops
cyclops-anym/src/main/java/cyclops/monads/transformers/jdk/OptionalT.java
OptionalT.of
public static <W extends WitnessType<W>,A> OptionalT<W,A> of(final AnyM<W,Optional<A>> monads) { return new OptionalT<>( monads); }
java
public static <W extends WitnessType<W>,A> OptionalT<W,A> of(final AnyM<W,Optional<A>> monads) { return new OptionalT<>( monads); }
[ "public", "static", "<", "W", "extends", "WitnessType", "<", "W", ">", ",", "A", ">", "OptionalT", "<", "W", ",", "A", ">", "of", "(", "final", "AnyM", "<", "W", ",", "Optional", "<", "A", ">", ">", "monads", ")", "{", "return", "new", "OptionalT...
Construct an OptionalWT from an AnyM that wraps a monad containing OptionalWs @param monads AnyM that contains a monad wrapping an Optional @return OptionalWT
[ "Construct", "an", "OptionalWT", "from", "an", "AnyM", "that", "wraps", "a", "monad", "containing", "OptionalWs" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-anym/src/main/java/cyclops/monads/transformers/jdk/OptionalT.java#L252-L255
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/types/reactive/QueueBasedSubscriber.java
QueueBasedSubscriber.subscriber
public static <T> QueueBasedSubscriber<T> subscriber(final Counter counter, final int maxConcurrency) { return new QueueBasedSubscriber<>( counter, maxConcurrency); }
java
public static <T> QueueBasedSubscriber<T> subscriber(final Counter counter, final int maxConcurrency) { return new QueueBasedSubscriber<>( counter, maxConcurrency); }
[ "public", "static", "<", "T", ">", "QueueBasedSubscriber", "<", "T", ">", "subscriber", "(", "final", "Counter", "counter", ",", "final", "int", "maxConcurrency", ")", "{", "return", "new", "QueueBasedSubscriber", "<>", "(", "counter", ",", "maxConcurrency", "...
Create a QueueBasedSubscriber, backed by a JDK LinkedBlockingQueue @param counter Counter for tracking connections to the queue and data volumes @param maxConcurrency Maximum number of subscriptions @return QueueBasedSubscriber
[ "Create", "a", "QueueBasedSubscriber", "backed", "by", "a", "JDK", "LinkedBlockingQueue" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/types/reactive/QueueBasedSubscriber.java#L45-L48
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/types/reactive/QueueBasedSubscriber.java
QueueBasedSubscriber.subscriber
public static <T> QueueBasedSubscriber<T> subscriber(final Queue<T> q, final Counter counter, final int maxConcurrency) { return new QueueBasedSubscriber<>( q, counter, maxConcurrency); }
java
public static <T> QueueBasedSubscriber<T> subscriber(final Queue<T> q, final Counter counter, final int maxConcurrency) { return new QueueBasedSubscriber<>( q, counter, maxConcurrency); }
[ "public", "static", "<", "T", ">", "QueueBasedSubscriber", "<", "T", ">", "subscriber", "(", "final", "Queue", "<", "T", ">", "q", ",", "final", "Counter", "counter", ",", "final", "int", "maxConcurrency", ")", "{", "return", "new", "QueueBasedSubscriber", ...
Create a QueueBasedSubscriber, backed by the provided Queue @param q Queue backing the reactiveSubscriber @param counter Counter for tracking connections to the queue and data volumes @param maxConcurrency Maximum number of subscriptions @return QueueBasedSubscriber
[ "Create", "a", "QueueBasedSubscriber", "backed", "by", "the", "provided", "Queue" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/types/reactive/QueueBasedSubscriber.java#L58-L61
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/types/reactive/QueueBasedSubscriber.java
QueueBasedSubscriber.subscriber
public static <T> QueueBasedSubscriber<T> subscriber(final QueueFactory<T> factory, final Counter counter, final int maxConcurrency) { return new QueueBasedSubscriber<>( factory, counter, maxConcurrency); }
java
public static <T> QueueBasedSubscriber<T> subscriber(final QueueFactory<T> factory, final Counter counter, final int maxConcurrency) { return new QueueBasedSubscriber<>( factory, counter, maxConcurrency); }
[ "public", "static", "<", "T", ">", "QueueBasedSubscriber", "<", "T", ">", "subscriber", "(", "final", "QueueFactory", "<", "T", ">", "factory", ",", "final", "Counter", "counter", ",", "final", "int", "maxConcurrency", ")", "{", "return", "new", "QueueBasedS...
Create a QueueBasedSubscriber, backed by a Queue that will be created with the provided QueueFactory @param factory QueueFactory @param counter Counter for tracking connections to the queue and data volumes @param maxConcurrency Maximum number of subscriptions @return QueueBasedSubscriber
[ "Create", "a", "QueueBasedSubscriber", "backed", "by", "a", "Queue", "that", "will", "be", "created", "with", "the", "provided", "QueueFactory" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/types/reactive/QueueBasedSubscriber.java#L71-L75
train
aol/cyclops
cyclops-pure/src/main/java/cyclops/hkt/Active.java
Active.custom
public <S,R> Active<W,R> custom(Function<? super Higher<W, T>,? extends S> narrow,Function<? super S,? extends Higher<W,R>> fn){ return Active.of(fn.apply(narrow.apply(single)),def1); }
java
public <S,R> Active<W,R> custom(Function<? super Higher<W, T>,? extends S> narrow,Function<? super S,? extends Higher<W,R>> fn){ return Active.of(fn.apply(narrow.apply(single)),def1); }
[ "public", "<", "S", ",", "R", ">", "Active", "<", "W", ",", "R", ">", "custom", "(", "Function", "<", "?", "super", "Higher", "<", "W", ",", "T", ">", ",", "?", "extends", "S", ">", "narrow", ",", "Function", "<", "?", "super", "S", ",", "?",...
Perform a custom operation <pre> {@code Active<list,Integer> active = Active.of(ListX.of(1,2,3), ListX.Instances.definitions()); Active<list, ListX<Integer>> grouped = active.custom(ListX::narrowK, l -> l.grouped(10)); } </pre> @param narrow Function that narrows Higher Kinded encoding to it's concrete type @param fn Transformation function @param <S> Concrete type @param <R> Return type @return Transformed Active after custom operation
[ "Perform", "a", "custom", "operation" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-pure/src/main/java/cyclops/hkt/Active.java#L89-L92
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/util/box/Mutable.java
Mutable.fromExternal
public static <T> Mutable<T> fromExternal(final Supplier<T> s, final Consumer<T> c) { return new Mutable<T>() { @Override public T get() { return s.get(); } @Override public Mutable<T> set(final T value) { c.accept(value); return this; } }; }
java
public static <T> Mutable<T> fromExternal(final Supplier<T> s, final Consumer<T> c) { return new Mutable<T>() { @Override public T get() { return s.get(); } @Override public Mutable<T> set(final T value) { c.accept(value); return this; } }; }
[ "public", "static", "<", "T", ">", "Mutable", "<", "T", ">", "fromExternal", "(", "final", "Supplier", "<", "T", ">", "s", ",", "final", "Consumer", "<", "T", ">", "c", ")", "{", "return", "new", "Mutable", "<", "T", ">", "(", ")", "{", "@", "O...
Construct a Mutable that gets and sets an external value using the provided Supplier and Consumer e.g. <pre> {@code Mutable<Integer> mutable = Mutable.from(()->this.value*2,val->this.value=val); } </pre> @param s Supplier of an external value @param c Consumer that sets an external value @return Mutable that gets / sets an external (mutable) value
[ "Construct", "a", "Mutable", "that", "gets", "and", "sets", "an", "external", "value", "using", "the", "provided", "Supplier", "and", "Consumer" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/util/box/Mutable.java#L88-L101
train
aol/cyclops
cyclops/src/main/java/cyclops/function/PartialApplicator.java
PartialApplicator.partial5
public static <T1, T2, T3, T4, T5, R> Supplier<R> partial5(final T1 t1, final T2 t2, final T3 t3, final T4 t4, final T5 t5, final Function5<T1, T2, T3, T4, T5, R> quintFunc) { return () -> quintFunc.apply(t1, t2, t3, t4, t5); }
java
public static <T1, T2, T3, T4, T5, R> Supplier<R> partial5(final T1 t1, final T2 t2, final T3 t3, final T4 t4, final T5 t5, final Function5<T1, T2, T3, T4, T5, R> quintFunc) { return () -> quintFunc.apply(t1, t2, t3, t4, t5); }
[ "public", "static", "<", "T1", ",", "T2", ",", "T3", ",", "T4", ",", "T5", ",", "R", ">", "Supplier", "<", "R", ">", "partial5", "(", "final", "T1", "t1", ",", "final", "T2", "t2", ",", "final", "T3", "t3", ",", "final", "T4", "t4", ",", "fin...
Returns a Function with 4 arguments applied to the supplied QuintFunction @param t1 Generic argument @param t2 Generic argument @param t3 Generic argument @param t4 Generic argument @param quintFunc Function that accepts 5 parameters @param <T1> Generic argument type @param <T2> Generic argument type @param <T3> Generic argument type @param <T4> Generic argument type @param <T5> Generic argument type @param <R> Function generic return type @return Function as a result of 4 arguments being applied to the incoming QuintFunction
[ "Returns", "a", "Function", "with", "4", "arguments", "applied", "to", "the", "supplied", "QuintFunction" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/function/PartialApplicator.java#L209-L212
train
aol/cyclops
cyclops/src/main/java/cyclops/function/PartialApplicator.java
PartialApplicator.partial6
public static <T1, T2, T3, T4, T5, T6, R> Supplier<R> partial6(final T1 t1, final T2 t2, final T3 t3, final T4 t4, final T5 t5, final T6 t6, final Function6<T1, T2, T3, T4, T5, T6, R> hexFunc) { return () -> hexFunc.apply(t1, t2, t3, t4, t5, t6); }
java
public static <T1, T2, T3, T4, T5, T6, R> Supplier<R> partial6(final T1 t1, final T2 t2, final T3 t3, final T4 t4, final T5 t5, final T6 t6, final Function6<T1, T2, T3, T4, T5, T6, R> hexFunc) { return () -> hexFunc.apply(t1, t2, t3, t4, t5, t6); }
[ "public", "static", "<", "T1", ",", "T2", ",", "T3", ",", "T4", ",", "T5", ",", "T6", ",", "R", ">", "Supplier", "<", "R", ">", "partial6", "(", "final", "T1", "t1", ",", "final", "T2", "t2", ",", "final", "T3", "t3", ",", "final", "T4", "t4"...
Returns a Function with 5 arguments applied to the supplied HexFunction @param t1 Generic argument @param t2 Generic argument @param t3 Generic argument @param t4 Generic argument @param t5 Generic argument @param hexFunc Function that accepts 6 parameters @param <T1> Generic argument type @param <T2> Generic argument type @param <T3> Generic argument type @param <T4> Generic argument type @param <T5> Generic argument type @param <T6> Generic argument type @param <R> Function generic return type @return Function as a result of 5 arguments being applied to the incoming HexFunction
[ "Returns", "a", "Function", "with", "5", "arguments", "applied", "to", "the", "supplied", "HexFunction" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/function/PartialApplicator.java#L310-L313
train
aol/cyclops
cyclops-pure/src/main/java/cyclops/kinds/OptionalKind.java
OptionalKind.narrow
public static <T> OptionalKind<T> narrow(final Higher<optional, T> future) { return (OptionalKind<T>)future; }
java
public static <T> OptionalKind<T> narrow(final Higher<optional, T> future) { return (OptionalKind<T>)future; }
[ "public", "static", "<", "T", ">", "OptionalKind", "<", "T", ">", "narrow", "(", "final", "Higher", "<", "optional", ",", "T", ">", "future", ")", "{", "return", "(", "OptionalKind", "<", "T", ">", ")", "future", ";", "}" ]
Convert the raw Higher Kinded Type for OptionalKind types into the OptionalKind type definition class @param future HKT encoded list into a OptionalKind @return OptionalKind
[ "Convert", "the", "raw", "Higher", "Kinded", "Type", "for", "OptionalKind", "types", "into", "the", "OptionalKind", "type", "definition", "class" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-pure/src/main/java/cyclops/kinds/OptionalKind.java#L99-L101
train
aol/cyclops
cyclops-pure/src/main/java/cyclops/kinds/OptionalKind.java
OptionalKind.narrowK
public static <T> Optional<T> narrowK(final Higher<optional, T> Optional) { //has to be an OptionalKind as only OptionalKind can implement Higher<optional, T> return ((OptionalKind<T>)Optional).boxed; }
java
public static <T> Optional<T> narrowK(final Higher<optional, T> Optional) { //has to be an OptionalKind as only OptionalKind can implement Higher<optional, T> return ((OptionalKind<T>)Optional).boxed; }
[ "public", "static", "<", "T", ">", "Optional", "<", "T", ">", "narrowK", "(", "final", "Higher", "<", "optional", ",", "T", ">", "Optional", ")", "{", "//has to be an OptionalKind as only OptionalKind can implement Higher<optional, T>", "return", "(", "(", "Optional...
Convert the HigherKindedType definition for a Optional into @param Optional Type Constructor to convert back into narrowed type @return Optional from Higher Kinded Type
[ "Convert", "the", "HigherKindedType", "definition", "for", "a", "Optional", "into" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-pure/src/main/java/cyclops/kinds/OptionalKind.java#L108-L112
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/CompletableFutures.java
CompletableFutures.forEach3
public static <T1, T2, R1, R2, R> CompletableFuture<R> forEach3(CompletableFuture<? extends T1> value1, Function<? super T1, ? extends CompletableFuture<R1>> value2, BiFunction<? super T1, ? super R1, ? extends CompletableFuture<R2>> value3, Function3<? super T1, ? super R1, ? super R2, ? extends R> yieldingFunction) { return value1.thenCompose(in -> { CompletableFuture<R1> a = value2.apply(in); return a.thenCompose(ina -> { CompletableFuture<R2> b = value3.apply(in,ina); return b.thenApply(in2 -> yieldingFunction.apply(in, ina, in2)); }); }); }
java
public static <T1, T2, R1, R2, R> CompletableFuture<R> forEach3(CompletableFuture<? extends T1> value1, Function<? super T1, ? extends CompletableFuture<R1>> value2, BiFunction<? super T1, ? super R1, ? extends CompletableFuture<R2>> value3, Function3<? super T1, ? super R1, ? super R2, ? extends R> yieldingFunction) { return value1.thenCompose(in -> { CompletableFuture<R1> a = value2.apply(in); return a.thenCompose(ina -> { CompletableFuture<R2> b = value3.apply(in,ina); return b.thenApply(in2 -> yieldingFunction.apply(in, ina, in2)); }); }); }
[ "public", "static", "<", "T1", ",", "T2", ",", "R1", ",", "R2", ",", "R", ">", "CompletableFuture", "<", "R", ">", "forEach3", "(", "CompletableFuture", "<", "?", "extends", "T1", ">", "value1", ",", "Function", "<", "?", "super", "T1", ",", "?", "...
Perform a For Comprehension over a CompletableFuture, accepting 2 generating function. This results in a three level nested internal iteration over the provided CompletableFutures. <pre> {@code import static com.oath.cyclops.reactor.CompletableFutures.forEach3; forEach3(CompletableFuture.just(1), a-> CompletableFuture.just(a+1), (a,b) -> CompletableFuture.<Integer>just(a+b), Tuple::tuple) } </pre> @param value1 top level CompletableFuture @param value2 Nested CompletableFuture @param value3 Nested CompletableFuture @param yieldingFunction Generates a result per combination @return CompletableFuture with a combined value generated by the yielding function
[ "Perform", "a", "For", "Comprehension", "over", "a", "CompletableFuture", "accepting", "2", "generating", "function", ".", "This", "results", "in", "a", "three", "level", "nested", "internal", "iteration", "over", "the", "provided", "CompletableFutures", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/CompletableFutures.java#L127-L146
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/CompletableFutures.java
CompletableFutures.forEach2
public static <T, R1, R> CompletableFuture<R> forEach2(CompletableFuture<? extends T> value1, Function<? super T, CompletableFuture<R1>> value2, BiFunction<? super T, ? super R1, ? extends R> yieldingFunction) { return value1.thenCompose(in -> { CompletableFuture<R1> a = value2.apply(in); return a.thenApply(ina -> yieldingFunction.apply(in, ina)); }); }
java
public static <T, R1, R> CompletableFuture<R> forEach2(CompletableFuture<? extends T> value1, Function<? super T, CompletableFuture<R1>> value2, BiFunction<? super T, ? super R1, ? extends R> yieldingFunction) { return value1.thenCompose(in -> { CompletableFuture<R1> a = value2.apply(in); return a.thenApply(ina -> yieldingFunction.apply(in, ina)); }); }
[ "public", "static", "<", "T", ",", "R1", ",", "R", ">", "CompletableFuture", "<", "R", ">", "forEach2", "(", "CompletableFuture", "<", "?", "extends", "T", ">", "value1", ",", "Function", "<", "?", "super", "T", ",", "CompletableFuture", "<", "R1", ">"...
Perform a For Comprehension over a CompletableFuture, accepting a generating function. This results in a two level nested internal iteration over the provided CompletableFutures. <pre> {@code import static com.oath.cyclops.reactor.CompletableFutures.forEach; forEach(CompletableFuture.just(1), a-> CompletableFuture.just(a+1), Tuple::tuple) } </pre> @param value1 top level CompletableFuture @param value2 Nested CompletableFuture @param yieldingFunction Generates a result per combination @return CompletableFuture with a combined value generated by the yielding function
[ "Perform", "a", "For", "Comprehension", "over", "a", "CompletableFuture", "accepting", "a", "generating", "function", ".", "This", "results", "in", "a", "two", "level", "nested", "internal", "iteration", "over", "the", "provided", "CompletableFutures", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/CompletableFutures.java#L170-L182
train
aol/cyclops
cyclops/src/main/java/cyclops/companion/CompletableFutures.java
CompletableFutures.sequence
public static <T> CompletableFuture<ReactiveSeq<T>> sequence(final Stream<? extends CompletableFuture<T>> fts) { return sequence(ReactiveSeq.fromStream((fts))); }
java
public static <T> CompletableFuture<ReactiveSeq<T>> sequence(final Stream<? extends CompletableFuture<T>> fts) { return sequence(ReactiveSeq.fromStream((fts))); }
[ "public", "static", "<", "T", ">", "CompletableFuture", "<", "ReactiveSeq", "<", "T", ">", ">", "sequence", "(", "final", "Stream", "<", "?", "extends", "CompletableFuture", "<", "T", ">", ">", "fts", ")", "{", "return", "sequence", "(", "ReactiveSeq", "...
Asynchronous sequence operation that convert a Stream of Futures to a Future with a Stream <pre> {@code CompletableFuture<Seq<Integer>> futures =CompletableFuture.sequence(Seq.of( CompletableFuture.completedFuture(10), CompletableFuture.completedFuture(1))); Seq.of(10,1) } </pre> @param fts Stream of Futures to Sequence into a Future with a Stream @return Future with a Stream
[ "Asynchronous", "sequence", "operation", "that", "convert", "a", "Stream", "of", "Futures", "to", "a", "Future", "with", "a", "Stream" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/companion/CompletableFutures.java#L222-L225
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/internal/stream/publisher/PublisherIterable.java
PublisherIterable.subscribe
static <T> void subscribe(Subscriber<? super T> s, Iterator<? extends T> it) { if (it == null) { error(s, new NullPointerException("The iterator is null")); return; } boolean b; try { b = it.hasNext(); } catch (Throwable e) { error(s, e); return; } if (!b) { complete(s); return; } s.onSubscribe(new IterableSubscription<T>(s, it)); }
java
static <T> void subscribe(Subscriber<? super T> s, Iterator<? extends T> it) { if (it == null) { error(s, new NullPointerException("The iterator is null")); return; } boolean b; try { b = it.hasNext(); } catch (Throwable e) { error(s, e); return; } if (!b) { complete(s); return; } s.onSubscribe(new IterableSubscription<T>(s, it)); }
[ "static", "<", "T", ">", "void", "subscribe", "(", "Subscriber", "<", "?", "super", "T", ">", "s", ",", "Iterator", "<", "?", "extends", "T", ">", "it", ")", "{", "if", "(", "it", "==", "null", ")", "{", "error", "(", "s", ",", "new", "NullPoin...
Common method to take an Iterator as a source of values. @param s @param it
[ "Common", "method", "to", "take", "an", "Iterator", "as", "a", "source", "of", "values", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/internal/stream/publisher/PublisherIterable.java#L123-L145
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java
Pipes.of
public static <K, V> Pipes<K, V> of(final Map<K, Adapter<V>> registered) { Objects.requireNonNull(registered); final Pipes<K, V> pipes = new Pipes<>(); pipes.registered.putAll(registered); return pipes; }
java
public static <K, V> Pipes<K, V> of(final Map<K, Adapter<V>> registered) { Objects.requireNonNull(registered); final Pipes<K, V> pipes = new Pipes<>(); pipes.registered.putAll(registered); return pipes; }
[ "public", "static", "<", "K", ",", "V", ">", "Pipes", "<", "K", ",", "V", ">", "of", "(", "final", "Map", "<", "K", ",", "Adapter", "<", "V", ">", ">", "registered", ")", "{", "Objects", ".", "requireNonNull", "(", "registered", ")", ";", "final"...
Construct a Pipes instance to manage a predefined Map of Adapaters @param registered Adapters to register @return Pipes instance to manage provided Adapters
[ "Construct", "a", "Pipes", "instance", "to", "manage", "a", "predefined", "Map", "of", "Adapaters" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java#L109-L114
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java
Pipes.push
public void push(final K key, final V value) { Optional.ofNullable(registered.get(key)) .ifPresent(a -> a.offer(value)); }
java
public void push(final K key, final V value) { Optional.ofNullable(registered.get(key)) .ifPresent(a -> a.offer(value)); }
[ "public", "void", "push", "(", "final", "K", "key", ",", "final", "V", "value", ")", "{", "Optional", ".", "ofNullable", "(", "registered", ".", "get", "(", "key", ")", ")", ".", "ifPresent", "(", "a", "->", "a", ".", "offer", "(", "value", ")", ...
Push a single value synchronously into the Adapter identified by the supplied Key, if it exists <pre> {@code Pipes<String,String> pipes = Pipes.of(); pipes.register("hello", new Queue<String>()); pipes.push("hello", "world"); on another thread pipes.reactiveSeq("hello") .getValue() .forEach(System.out::println); } </pre> @param key Adapter key @param value Value to push to Adapter
[ "Push", "a", "single", "value", "synchronously", "into", "the", "Adapter", "identified", "by", "the", "supplied", "Key", "if", "it", "exists" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java#L139-L142
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java
Pipes.get
@SuppressWarnings({ "unchecked", "rawtypes" }) public Option<Adapter<V>> get(final K key) { return Option.ofNullable((Adapter) registered.get(key)); }
java
@SuppressWarnings({ "unchecked", "rawtypes" }) public Option<Adapter<V>> get(final K key) { return Option.ofNullable((Adapter) registered.get(key)); }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"rawtypes\"", "}", ")", "public", "Option", "<", "Adapter", "<", "V", ">", ">", "get", "(", "final", "K", "key", ")", "{", "return", "Option", ".", "ofNullable", "(", "(", "Adapter", ")", "regi...
Get the Adapter identified by the specified key <pre> {@code //close an adapter pipes.getValue("adapter-key") .map(a->a.close()) .orElse(false); //Maybe is lazy - trigger action } </pre> @param key : Adapter identifier @return selected Queue
[ "Get", "the", "Adapter", "identified", "by", "the", "specified", "key" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java#L161-L164
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java
Pipes.futureStream
@SuppressWarnings({ "unchecked", "rawtypes" }) public Option<FutureStream<V>> futureStream(final K key, final LazyReact builder) { return get(key).map(a -> builder.fromStream(a.stream())); }
java
@SuppressWarnings({ "unchecked", "rawtypes" }) public Option<FutureStream<V>> futureStream(final K key, final LazyReact builder) { return get(key).map(a -> builder.fromStream(a.stream())); }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"rawtypes\"", "}", ")", "public", "Option", "<", "FutureStream", "<", "V", ">", ">", "futureStream", "(", "final", "K", "key", ",", "final", "LazyReact", "builder", ")", "{", "return", "get", "(", ...
Create a FutureStream using the provided LazyReact futureStream builder from the Adapter identified by the provided Key <pre> {@code Pipes<String, Integer> bus = Pipes.of(); bus.register("reactor", QueueFactories.<Integer>boundedNonBlockingQueue(1000) .build()); bus.publishTo("reactor",ReactiveSeq.of(10,20,30)); bus.close("reactor"); on another thread List<String> res = bus.futureStream("reactor", new LazyReact(10,10)) .getValue() .map(i->"fan-out to handle blocking I/O:" + Thread.currentThread().getId() + ":"+i) .toList(); System.out.println(res); assertThat(res.size(),equalTo(3)); } </pre> @param key : Adapter identifier @param builder LazyReact futureStream builder @return LazyFutureStream from selected Queue
[ "Create", "a", "FutureStream", "using", "the", "provided", "LazyReact", "futureStream", "builder", "from", "the", "Adapter", "identified", "by", "the", "provided", "Key" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java#L201-L205
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java
Pipes.reactiveSeq
@SuppressWarnings({ "unchecked", "rawtypes" }) public Option<ReactiveSeq<V>> reactiveSeq(final K key) { return get(key).map(a -> a.stream()); }
java
@SuppressWarnings({ "unchecked", "rawtypes" }) public Option<ReactiveSeq<V>> reactiveSeq(final K key) { return get(key).map(a -> a.stream()); }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"rawtypes\"", "}", ")", "public", "Option", "<", "ReactiveSeq", "<", "V", ">", ">", "reactiveSeq", "(", "final", "K", "key", ")", "{", "return", "get", "(", "key", ")", ".", "map", "(", "a", ...
Create a ReactiveSeq from the Adapter identified by the provided Key <pre> {@code Queue<String> q = new Queue<>(); pipes.register("data-queue", q); pipes.push("data-queue", "world"); on a separate thread ReactiveSeq<String> stream = pipes.reactiveSeq("data-queue"); stream.forEach(System.out::println); "world" } </pre> @param key : Adapter identifier @return {@link ReactiveSeq} from selected Queue
[ "Create", "a", "ReactiveSeq", "from", "the", "Adapter", "identified", "by", "the", "provided", "Key" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java#L231-L234
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java
Pipes.xValues
public ListX<V> xValues(final K key, final long x) { return get(key).map(a -> a.stream() .limit(x) .to(ReactiveConvertableSequence::converter).listX()) .orElse(ListX.empty()); }
java
public ListX<V> xValues(final K key, final long x) { return get(key).map(a -> a.stream() .limit(x) .to(ReactiveConvertableSequence::converter).listX()) .orElse(ListX.empty()); }
[ "public", "ListX", "<", "V", ">", "xValues", "(", "final", "K", "key", ",", "final", "long", "x", ")", "{", "return", "get", "(", "key", ")", ".", "map", "(", "a", "->", "a", ".", "stream", "(", ")", ".", "limit", "(", "x", ")", ".", "to", ...
Extract the next x values from the Adapter identified by the provided Key If the Adapter doesn't exist an zero List is returned <pre> {@code Queue<String> q = new Queue<>(); pipes.register("hello", q); pipes.push("hello", "world"); pipes.push("hello", "world2"); pipes.push("hello", "world3"); pipes.push("hello", "world4"); on a separate thread pipes.xValues("hello",2) //ListX.of("world","world2") pipes.xValues("hello",2) //ListX.of("world3","world4") } </pre> @param key : Adapter identifier @param x Number of elements to return @return List of the next x elements from the Adapter identified by the provided key
[ "Extract", "the", "next", "x", "values", "from", "the", "Adapter", "identified", "by", "the", "provided", "Key", "If", "the", "Adapter", "doesn", "t", "exist", "an", "zero", "List", "is", "returned" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java#L262-L268
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java
Pipes.oneValue
@SuppressWarnings({ "unchecked", "rawtypes" }) public Option<V> oneValue(final K key) { final ValueSubscriber<V> sub = ValueSubscriber.subscriber(); return get(key).peek(a -> a.stream() .subscribe(sub)) .flatMap(a -> sub.toMaybe()); }
java
@SuppressWarnings({ "unchecked", "rawtypes" }) public Option<V> oneValue(final K key) { final ValueSubscriber<V> sub = ValueSubscriber.subscriber(); return get(key).peek(a -> a.stream() .subscribe(sub)) .flatMap(a -> sub.toMaybe()); }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", ",", "\"rawtypes\"", "}", ")", "public", "Option", "<", "V", ">", "oneValue", "(", "final", "K", "key", ")", "{", "final", "ValueSubscriber", "<", "V", ">", "sub", "=", "ValueSubscriber", ".", "subscriber...
Extract one value from the selected pipe, if it exists @param key : Adapter identifier @return Maybe containing next value from the Adapter identified by the provided key
[ "Extract", "one", "value", "from", "the", "selected", "pipe", "if", "it", "exists" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java#L276-L282
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java
Pipes.subscribeTo
public void subscribeTo(final K key, final Subscriber<V> subscriber) { registered.get(key) .stream() .subscribe(subscriber); }
java
public void subscribeTo(final K key, final Subscriber<V> subscriber) { registered.get(key) .stream() .subscribe(subscriber); }
[ "public", "void", "subscribeTo", "(", "final", "K", "key", ",", "final", "Subscriber", "<", "V", ">", "subscriber", ")", "{", "registered", ".", "get", "(", "key", ")", ".", "stream", "(", ")", ".", "subscribe", "(", "subscriber", ")", ";", "}" ]
Subscribe synchronously to a pipe @param key for registered simple-react async.Adapter @param subscriber Reactive Streams reactiveSubscriber for data on this pipe
[ "Subscribe", "synchronously", "to", "a", "pipe" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java#L544-L549
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java
Pipes.subscribeTo
public void subscribeTo(final K key, final Subscriber<V> subscriber, final Executor subscribeOn) { CompletableFuture.runAsync(() -> subscribeTo(key, subscriber), subscribeOn); }
java
public void subscribeTo(final K key, final Subscriber<V> subscriber, final Executor subscribeOn) { CompletableFuture.runAsync(() -> subscribeTo(key, subscriber), subscribeOn); }
[ "public", "void", "subscribeTo", "(", "final", "K", "key", ",", "final", "Subscriber", "<", "V", ">", "subscriber", ",", "final", "Executor", "subscribeOn", ")", "{", "CompletableFuture", ".", "runAsync", "(", "(", ")", "->", "subscribeTo", "(", "key", ","...
Subscribe asynchronously to a pipe <pre> {@code SeqSubscriber<String> reactiveSubscriber = SeqSubscriber.reactiveSubscriber(); Queue<String> queue = new Queue(); pipes.register("hello", queue); pipes.subscribeTo("hello",reactiveSubscriber,ForkJoinPool.commonPool()); queue.offer("world"); queue.close(); assertThat(reactiveSubscriber.stream().findAny().getValue(),equalTo("world")); } </pre> @param key for registered simple-react async.Adapter @param subscriber Reactive Streams reactiveSubscriber for data on this pipe
[ "Subscribe", "asynchronously", "to", "a", "pipe" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java#L573-L576
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java
Pipes.publishTo
public void publishTo(final K key, final Publisher<V> publisher) { registered.get(key).fromStream(Spouts.from(publisher)); }
java
public void publishTo(final K key, final Publisher<V> publisher) { registered.get(key).fromStream(Spouts.from(publisher)); }
[ "public", "void", "publishTo", "(", "final", "K", "key", ",", "final", "Publisher", "<", "V", ">", "publisher", ")", "{", "registered", ".", "get", "(", "key", ")", ".", "fromStream", "(", "Spouts", ".", "from", "(", "publisher", ")", ")", ";", "}" ]
Synchronously publish data to the Adapter specified by the provided Key, blocking the current thread @param key for registered cylops-react async.Adapter @param publisher Reactive Streams publisher to push data onto this pipe
[ "Synchronously", "publish", "data", "to", "the", "Adapter", "specified", "by", "the", "provided", "Key", "blocking", "the", "current", "thread" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java#L584-L586
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java
Pipes.publishToAsync
public void publishToAsync(final K key, final Publisher<V> publisher) { SequentialElasticPools.simpleReact.react(er -> er.of(publisher) .peek(p -> publishTo(key, p))); }
java
public void publishToAsync(final K key, final Publisher<V> publisher) { SequentialElasticPools.simpleReact.react(er -> er.of(publisher) .peek(p -> publishTo(key, p))); }
[ "public", "void", "publishToAsync", "(", "final", "K", "key", ",", "final", "Publisher", "<", "V", ">", "publisher", ")", "{", "SequentialElasticPools", ".", "simpleReact", ".", "react", "(", "er", "->", "er", ".", "of", "(", "publisher", ")", ".", "peek...
Asynchronously publish data to the Adapter specified by the provided Key <pre> {@code Pipes<String,Integer> pipes = Pipes.of(); Queue<Integer> queue = new Queue(); pipes.register("hello", queue); pipes.publishToAsync("hello",ReactiveSeq.of(1,2,3)); Thread.sleep(100); queue.offer(4); queue.close(); assertThat(queue.stream().toList(),equalTo(Arrays.asList(1,2,3,4))); } </pre> @param key for registered simple-react async.Adapter @param publisher Reactive Streams publisher to push data onto this pipe
[ "Asynchronously", "publish", "data", "to", "the", "Adapter", "specified", "by", "the", "provided", "Key" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java#L613-L616
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java
Pipes.close
public void close(final String key) { Optional.ofNullable(registered.get(key)) .ifPresent(a -> a.close()); }
java
public void close(final String key) { Optional.ofNullable(registered.get(key)) .ifPresent(a -> a.close()); }
[ "public", "void", "close", "(", "final", "String", "key", ")", "{", "Optional", ".", "ofNullable", "(", "registered", ".", "get", "(", "key", ")", ")", ".", "ifPresent", "(", "a", "->", "a", ".", "close", "(", ")", ")", ";", "}" ]
Close the Adapter identified by the provided Key if it exists @param key : Adapter identifier
[ "Close", "the", "Adapter", "identified", "by", "the", "provided", "Key", "if", "it", "exists" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/Pipes.java#L623-L627
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/LazyReact.java
LazyReact.from
public <U> FutureStream<U> from(final CompletableFuture<U> cf) { return this.constructFutures(Stream.of(cf)); }
java
public <U> FutureStream<U> from(final CompletableFuture<U> cf) { return this.constructFutures(Stream.of(cf)); }
[ "public", "<", "U", ">", "FutureStream", "<", "U", ">", "from", "(", "final", "CompletableFuture", "<", "U", ">", "cf", ")", "{", "return", "this", ".", "constructFutures", "(", "Stream", ".", "of", "(", "cf", ")", ")", ";", "}" ]
Construct a FutureStream containing a single Future @param cf CompletableFuture to create Stream from @return FutureStream of a single value
[ "Construct", "a", "FutureStream", "containing", "a", "single", "Future" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/LazyReact.java#L224-L228
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/LazyReact.java
LazyReact.constructFutures
public <U> FutureStream<U> constructFutures(final Stream<CompletableFuture<U>> s) { final LazyReact toUse = withStreamOfFutures(true); return toUse.construct((Stream<U>) s); }
java
public <U> FutureStream<U> constructFutures(final Stream<CompletableFuture<U>> s) { final LazyReact toUse = withStreamOfFutures(true); return toUse.construct((Stream<U>) s); }
[ "public", "<", "U", ">", "FutureStream", "<", "U", ">", "constructFutures", "(", "final", "Stream", "<", "CompletableFuture", "<", "U", ">", ">", "s", ")", "{", "final", "LazyReact", "toUse", "=", "withStreamOfFutures", "(", "true", ")", ";", "return", "...
Construct a FutureStream from a Stream of CompletableFutures @param s Stream of CompletableFutures @return FutureStream
[ "Construct", "a", "FutureStream", "from", "a", "Stream", "of", "CompletableFutures" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/LazyReact.java#L276-L279
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/LazyReact.java
LazyReact.fromPublisher
public <T> FutureStream<T> fromPublisher(final Publisher<? extends T> publisher) { Objects.requireNonNull(publisher); Publisher<T> narrowed = (Publisher<T>)publisher; return fromStream(Spouts.from(narrowed)); }
java
public <T> FutureStream<T> fromPublisher(final Publisher<? extends T> publisher) { Objects.requireNonNull(publisher); Publisher<T> narrowed = (Publisher<T>)publisher; return fromStream(Spouts.from(narrowed)); }
[ "public", "<", "T", ">", "FutureStream", "<", "T", ">", "fromPublisher", "(", "final", "Publisher", "<", "?", "extends", "T", ">", "publisher", ")", "{", "Objects", ".", "requireNonNull", "(", "publisher", ")", ";", "Publisher", "<", "T", ">", "narrowed"...
Construct a FutureStream from an Publisher <pre> {@code new LazyReact().fromPublisher(Flux.just(1,2,3)).toList(); } </pre> @param publisher to construct FutureStream from @return FutureStream
[ "Construct", "a", "FutureStream", "from", "an", "Publisher" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/LazyReact.java#L414-L418
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/LazyReact.java
LazyReact.parallelBuilder
public static LazyReact parallelBuilder(final int parallelism) { return LazyReact.builder() .executor(Executors.newFixedThreadPool(parallelism)) .build(); }
java
public static LazyReact parallelBuilder(final int parallelism) { return LazyReact.builder() .executor(Executors.newFixedThreadPool(parallelism)) .build(); }
[ "public", "static", "LazyReact", "parallelBuilder", "(", "final", "int", "parallelism", ")", "{", "return", "LazyReact", ".", "builder", "(", ")", ".", "executor", "(", "Executors", ".", "newFixedThreadPool", "(", "parallelism", ")", ")", ".", "build", "(", ...
Construct a new LazyReact builder, with a new task executor and retry executor with configured number of threads @param parallelism Number of threads task executor should have @return LazyReact instance
[ "Construct", "a", "new", "LazyReact", "builder", "with", "a", "new", "task", "executor", "and", "retry", "executor", "with", "configured", "number", "of", "threads" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/LazyReact.java#L729-L733
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/LazyReact.java
LazyReact.iterate
public <U> FutureStream<U> iterate(final U seed, final UnaryOperator<U> f) { final Subscription sub = new Subscription(); final Supplier<U> supplier = new Supplier<U>() { @SuppressWarnings("unchecked") U t = (U) NONE; @Override public U get() { return t = t == NONE ? seed : f.apply(t); } }; return construct(StreamSupport.<U> stream(new InfiniteClosingSpliteratorFromSupplier<U>( Long.MAX_VALUE, supplier, sub), false)); }
java
public <U> FutureStream<U> iterate(final U seed, final UnaryOperator<U> f) { final Subscription sub = new Subscription(); final Supplier<U> supplier = new Supplier<U>() { @SuppressWarnings("unchecked") U t = (U) NONE; @Override public U get() { return t = t == NONE ? seed : f.apply(t); } }; return construct(StreamSupport.<U> stream(new InfiniteClosingSpliteratorFromSupplier<U>( Long.MAX_VALUE, supplier, sub), false)); }
[ "public", "<", "U", ">", "FutureStream", "<", "U", ">", "iterate", "(", "final", "U", "seed", ",", "final", "UnaryOperator", "<", "U", ">", "f", ")", "{", "final", "Subscription", "sub", "=", "new", "Subscription", "(", ")", ";", "final", "Supplier", ...
Iterate infinitely using the supplied seed and function Iteration is synchronized to support multiple threads using the same iterator. <pre> {@code new LazyReact().objectPoolingOn() .iterate(1,i->i+1) .limit(1_000_000) .map(this::process) .forEach(this::save); } </pre> @see FutureStream#iterate for an alternative which does not synchronize iteration @param seed Initial value @param f Function that performs the iteration @return FutureStream
[ "Iterate", "infinitely", "using", "the", "supplied", "seed", "and", "function", "Iteration", "is", "synchronized", "to", "support", "multiple", "threads", "using", "the", "same", "iterator", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/LazyReact.java#L809-L825
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/LazyReact.java
LazyReact.generate
public <U> FutureStream<U> generate(final Supplier<U> generate) { return construct(StreamSupport.<U> stream(new InfiniteClosingSpliteratorFromSupplier<U>( Long.MAX_VALUE, generate, new Subscription()), false)); }
java
public <U> FutureStream<U> generate(final Supplier<U> generate) { return construct(StreamSupport.<U> stream(new InfiniteClosingSpliteratorFromSupplier<U>( Long.MAX_VALUE, generate, new Subscription()), false)); }
[ "public", "<", "U", ">", "FutureStream", "<", "U", ">", "generate", "(", "final", "Supplier", "<", "U", ">", "generate", ")", "{", "return", "construct", "(", "StreamSupport", ".", "<", "U", ">", "stream", "(", "new", "InfiniteClosingSpliteratorFromSupplier"...
Generate an infinite Stream <pre> {@code new LazyReact().generate(()->"hello") .limit(5) .reduce(SemigroupK.stringConcat); Optional[hellohellohellohellohello] }</pre> @param generate Supplier that generates stream input @return Infinite FutureStream
[ "Generate", "an", "infinite", "Stream" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/LazyReact.java#L876-L881
train
aol/cyclops
cyclops-futurestream/src/main/java/cyclops/futurestream/LazyReact.java
LazyReact.generateAsync
public <U> FutureStream<U> generateAsync(final Supplier<U> s) { return this.constructFutures(ReactiveSeq.generate(() -> 1) .map(n -> CompletableFuture.supplyAsync(s, getExecutor()))); }
java
public <U> FutureStream<U> generateAsync(final Supplier<U> s) { return this.constructFutures(ReactiveSeq.generate(() -> 1) .map(n -> CompletableFuture.supplyAsync(s, getExecutor()))); }
[ "public", "<", "U", ">", "FutureStream", "<", "U", ">", "generateAsync", "(", "final", "Supplier", "<", "U", ">", "s", ")", "{", "return", "this", ".", "constructFutures", "(", "ReactiveSeq", ".", "generate", "(", "(", ")", "->", "1", ")", ".", "map"...
Generate an infinite FutureStream executing the provided Supplier continually and asynhcronously <pre> {@code new LazyReact().generate(this::load) .limit(5) .reduce(SemigroupK.stringConcat); Optional["data1data2data3data4data5"] }</pre> @param s Supplier to execute asynchronously to create an infinite Stream @return Infinite FutureStream
[ "Generate", "an", "infinite", "FutureStream", "executing", "the", "provided", "Supplier", "continually", "and", "asynhcronously" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/cyclops/futurestream/LazyReact.java#L898-L902
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/async/adapters/Signal.java
Signal.set
public T set(final T newValue) { if(continuous!=null) continuous.offer(newValue); setDiscreteIfDiff(newValue); return newValue; }
java
public T set(final T newValue) { if(continuous!=null) continuous.offer(newValue); setDiscreteIfDiff(newValue); return newValue; }
[ "public", "T", "set", "(", "final", "T", "newValue", ")", "{", "if", "(", "continuous", "!=", "null", ")", "continuous", ".", "offer", "(", "newValue", ")", ";", "setDiscreteIfDiff", "(", "newValue", ")", ";", "return", "newValue", ";", "}" ]
Set the current value of this signal @param newValue Replacement value @return newValue
[ "Set", "the", "current", "value", "of", "this", "signal" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/async/adapters/Signal.java#L76-L82
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/internal/stream/spliterators/push/Concat.java
Concat.addMissingRequests
public void addMissingRequests(){ int missed=1; long toRequest=0L; do { long localQueued = queued.getAndSet(0l); Subscription localSub = next.getAndSet(null); long missedOutput = produced.get(); Subscription localActive = active.get(); long reqs = requested.get() + localQueued; if(reqs<0 || toRequest<0) { processAll=true; if(localSub!=null) localSub.request(Long.MAX_VALUE); if(localActive!=null) localActive.request(Long.MAX_VALUE); return; } requested.set(reqs); if(localSub!=null){ active.set(localSub); toRequest +=reqs; }else if(localQueued !=0 && localActive!=null) { toRequest += reqs; } missed = wip.accumulateAndGet(missed,(a,b)->a-b); }while(missed!=0); if(toRequest>0) active.get().request(toRequest); }
java
public void addMissingRequests(){ int missed=1; long toRequest=0L; do { long localQueued = queued.getAndSet(0l); Subscription localSub = next.getAndSet(null); long missedOutput = produced.get(); Subscription localActive = active.get(); long reqs = requested.get() + localQueued; if(reqs<0 || toRequest<0) { processAll=true; if(localSub!=null) localSub.request(Long.MAX_VALUE); if(localActive!=null) localActive.request(Long.MAX_VALUE); return; } requested.set(reqs); if(localSub!=null){ active.set(localSub); toRequest +=reqs; }else if(localQueued !=0 && localActive!=null) { toRequest += reqs; } missed = wip.accumulateAndGet(missed,(a,b)->a-b); }while(missed!=0); if(toRequest>0) active.get().request(toRequest); }
[ "public", "void", "addMissingRequests", "(", ")", "{", "int", "missed", "=", "1", ";", "long", "toRequest", "=", "0L", ";", "do", "{", "long", "localQueued", "=", "queued", ".", "getAndSet", "(", "0l", ")", ";", "Subscription", "localSub", "=", "next", ...
transfer demand from previous to next
[ "transfer", "demand", "from", "previous", "to", "next" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/internal/stream/spliterators/push/Concat.java#L97-L136
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/types/reactive/ReactiveTask.java
ReactiveTask.requestAsync
public ReactiveTask requestAsync(final long n) { return withSubscriptionAndTask(subscriptionAndTask.map2(c -> CompletableFuture.runAsync(() -> subscriptionAndTask._1().join() .request(n), exec))); }
java
public ReactiveTask requestAsync(final long n) { return withSubscriptionAndTask(subscriptionAndTask.map2(c -> CompletableFuture.runAsync(() -> subscriptionAndTask._1().join() .request(n), exec))); }
[ "public", "ReactiveTask", "requestAsync", "(", "final", "long", "n", ")", "{", "return", "withSubscriptionAndTask", "(", "subscriptionAndTask", ".", "map2", "(", "c", "->", "CompletableFuture", ".", "runAsync", "(", "(", ")", "->", "subscriptionAndTask", ".", "_...
Asyncrhonously request more elements from the Stream @param n Number of elements to request @return New ReactiveTask that references the execution of the new async task
[ "Asyncrhonously", "request", "more", "elements", "from", "the", "Stream" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/types/reactive/ReactiveTask.java#L63-L67
train
aol/cyclops
cyclops-anym/src/main/java/cyclops/monads/transformers/EitherT.java
EitherT.map
@Override public <B> EitherT<W,ST,B> map(final Function<? super T, ? extends B> f) { return new EitherT<W,ST,B>( run.map(o -> o.map(f))); }
java
@Override public <B> EitherT<W,ST,B> map(final Function<? super T, ? extends B> f) { return new EitherT<W,ST,B>( run.map(o -> o.map(f))); }
[ "@", "Override", "public", "<", "B", ">", "EitherT", "<", "W", ",", "ST", ",", "B", ">", "map", "(", "final", "Function", "<", "?", "super", "T", ",", "?", "extends", "B", ">", "f", ")", "{", "return", "new", "EitherT", "<", "W", ",", "ST", "...
Map the wrapped Maybe <pre> {@code MaybeWT.of(AnyM.fromStream(Arrays.asMaybeW(10)) .map(t->t=t+1); //MaybeWT<AnyMSeq<Stream<Maybe[11]>>> } </pre> @param f Mapping function for the wrapped Maybe @return MaybeWT that applies the transform function to the wrapped Maybe
[ "Map", "the", "wrapped", "Maybe" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-anym/src/main/java/cyclops/monads/transformers/EitherT.java#L119-L123
train
aol/cyclops
cyclops-anym/src/main/java/cyclops/monads/transformers/EitherT.java
EitherT.lift
public static <W extends WitnessType<W>,U,ST, R> Function<EitherT<W,ST,U>, EitherT<W,ST,R>> lift(final Function<? super U, ? extends R> fn) { return optTu -> optTu.map(input -> fn.apply(input)); }
java
public static <W extends WitnessType<W>,U,ST, R> Function<EitherT<W,ST,U>, EitherT<W,ST,R>> lift(final Function<? super U, ? extends R> fn) { return optTu -> optTu.map(input -> fn.apply(input)); }
[ "public", "static", "<", "W", "extends", "WitnessType", "<", "W", ">", ",", "U", ",", "ST", ",", "R", ">", "Function", "<", "EitherT", "<", "W", ",", "ST", ",", "U", ">", ",", "EitherT", "<", "W", ",", "ST", ",", "R", ">", ">", "lift", "(", ...
Lift a function into one that accepts and returns an MaybeWT This allows multiple monad types to add functionality to existing function and methods e.g. to add list handling / iteration (via Maybe) and iteration (via Stream) to an existing function <pre> {@code Function<Integer,Integer> add2 = i -> i+2; Function<MaybeWT<Integer>, MaybeWT<Integer>> optTAdd2 = MaybeWT.lift(add2); Stream<Integer> withNulls = Stream.of(1,2,3); AnyMSeq<Integer> stream = AnyM.fromStream(withNulls); AnyMSeq<Maybe<Integer>> streamOpt = stream.map(Maybe::completedMaybe); List<Integer> results = optTAdd2.applyHKT(MaybeWT.of(streamOpt)) .unwrap() .<Stream<Maybe<Integer>>>unwrap() .map(Maybe::join) .collect(CyclopsCollectors.toList()); Maybe.completedMaybe(List[3,4]); }</pre> @param fn Function to enhance with functionality from Maybe and another monad type @return Function that accepts and returns an MaybeWT
[ "Lift", "a", "function", "into", "one", "that", "accepts", "and", "returns", "an", "MaybeWT", "This", "allows", "multiple", "monad", "types", "to", "add", "functionality", "to", "existing", "function", "and", "methods" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-anym/src/main/java/cyclops/monads/transformers/EitherT.java#L187-L189
train
aol/cyclops
cyclops-anym/src/main/java/cyclops/monads/transformers/EitherT.java
EitherT.of
public static <W extends WitnessType<W>,ST,A> EitherT<W,ST,A> of(final AnyM<W,Either<ST,A>> monads) { return new EitherT<>( monads); }
java
public static <W extends WitnessType<W>,ST,A> EitherT<W,ST,A> of(final AnyM<W,Either<ST,A>> monads) { return new EitherT<>( monads); }
[ "public", "static", "<", "W", "extends", "WitnessType", "<", "W", ">", ",", "ST", ",", "A", ">", "EitherT", "<", "W", ",", "ST", ",", "A", ">", "of", "(", "final", "AnyM", "<", "W", ",", "Either", "<", "ST", ",", "A", ">", ">", "monads", ")",...
Construct an MaybeWT from an AnyM that wraps a monad containing MaybeWs @param monads AnyM that contains a monad wrapping an Maybe @return MaybeWT
[ "Construct", "an", "MaybeWT", "from", "an", "AnyM", "that", "wraps", "a", "monad", "containing", "MaybeWs" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-anym/src/main/java/cyclops/monads/transformers/EitherT.java#L243-L246
train
aol/cyclops
cyclops-anym/src/main/java/cyclops/monads/transformers/EvalT.java
EvalT.of
public static <W extends WitnessType<W>,A> EvalT<W,A> of(final AnyM<W,Eval<A>> monads) { return new EvalT<>( monads); }
java
public static <W extends WitnessType<W>,A> EvalT<W,A> of(final AnyM<W,Eval<A>> monads) { return new EvalT<>( monads); }
[ "public", "static", "<", "W", "extends", "WitnessType", "<", "W", ">", ",", "A", ">", "EvalT", "<", "W", ",", "A", ">", "of", "(", "final", "AnyM", "<", "W", ",", "Eval", "<", "A", ">", ">", "monads", ")", "{", "return", "new", "EvalT", "<>", ...
Construct an EvalWT from an AnyM that wraps a monad containing EvalWs @param monads AnyM that contains a monad wrapping an Eval @return EvalWT
[ "Construct", "an", "EvalWT", "from", "an", "AnyM", "that", "wraps", "a", "monad", "containing", "EvalWs" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-anym/src/main/java/cyclops/monads/transformers/EvalT.java#L250-L253
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/async/adapters/Queue.java
Queue.add
public boolean add(final T data) { try { final boolean result = queue.add((T) nullSafe(data)); if (result) { if (sizeSignal != null) this.sizeSignal.set(queue.size()); } return result; } catch (final IllegalStateException e) { return false; } }
java
public boolean add(final T data) { try { final boolean result = queue.add((T) nullSafe(data)); if (result) { if (sizeSignal != null) this.sizeSignal.set(queue.size()); } return result; } catch (final IllegalStateException e) { return false; } }
[ "public", "boolean", "add", "(", "final", "T", "data", ")", "{", "try", "{", "final", "boolean", "result", "=", "queue", ".", "add", "(", "(", "T", ")", "nullSafe", "(", "data", ")", ")", ";", "if", "(", "result", ")", "{", "if", "(", "sizeSignal...
Add a single data point to the queue If the queue is a bounded queue and is full, will return false @param data Data to add @return true if successfully added.
[ "Add", "a", "single", "data", "point", "to", "the", "queue" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/async/adapters/Queue.java#L530-L544
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/async/adapters/Queue.java
Queue.offer
@Override public boolean offer(final T data) { if (!open) { throw new ClosedQueueException(); } try { final boolean result = producerWait.offer(() -> this.queue.offer((T) nullSafe(data), this.offerTimeout, this.offerTimeUnit)); if (sizeSignal != null) this.sizeSignal.set(queue.size()); return result; } catch (final InterruptedException e) { Thread.currentThread() .interrupt(); throw ExceptionSoftener.throwSoftenedException(e); } }
java
@Override public boolean offer(final T data) { if (!open) { throw new ClosedQueueException(); } try { final boolean result = producerWait.offer(() -> this.queue.offer((T) nullSafe(data), this.offerTimeout, this.offerTimeUnit)); if (sizeSignal != null) this.sizeSignal.set(queue.size()); return result; } catch (final InterruptedException e) { Thread.currentThread() .interrupt(); throw ExceptionSoftener.throwSoftenedException(e); } }
[ "@", "Override", "public", "boolean", "offer", "(", "final", "T", "data", ")", "{", "if", "(", "!", "open", ")", "{", "throw", "new", "ClosedQueueException", "(", ")", ";", "}", "try", "{", "final", "boolean", "result", "=", "producerWait", ".", "offer...
Offer a single datapoint to this Queue If the queue is a bounded queue and is full it will block until space comes available or until offer time out is reached (default is Integer.MAX_VALUE DAYS). @param data data to add @return self
[ "Offer", "a", "single", "datapoint", "to", "this", "Queue" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/async/adapters/Queue.java#L571-L590
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/async/adapters/Queue.java
Queue.close
@Override public boolean close() { this.open = false; for (int i = 0; i < listeningStreams.get(); i++) { try{ this.queue.offer((T) POISON_PILL); }catch(Exception e){ } } return true; }
java
@Override public boolean close() { this.open = false; for (int i = 0; i < listeningStreams.get(); i++) { try{ this.queue.offer((T) POISON_PILL); }catch(Exception e){ } } return true; }
[ "@", "Override", "public", "boolean", "close", "(", ")", "{", "this", ".", "open", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listeningStreams", ".", "get", "(", ")", ";", "i", "++", ")", "{", "try", "{", "this", ".", ...
Close this Queue Poison Pills are used to communicate closure to connected Streams A Poison Pill is added per connected Stream to the Queue If a BlockingQueue is backing this async.Queue it will block until able to add to the Queue. @return true if closed
[ "Close", "this", "Queue", "Poison", "Pills", "are", "used", "to", "communicate", "closure", "to", "connected", "Streams", "A", "Poison", "Pill", "is", "added", "per", "connected", "Stream", "to", "the", "Queue", "If", "a", "BlockingQueue", "is", "backing", "...
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/async/adapters/Queue.java#L624-L638
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/util/box/LazyImmutable.java
LazyImmutable.map
@Override public <R> LazyImmutable<R> map(final Function<? super T, ? extends R> fn) { final T val = get(); if (val == UNSET) return (LazyImmutable<R>) this; else return LazyImmutable.of(fn.apply(val)); }
java
@Override public <R> LazyImmutable<R> map(final Function<? super T, ? extends R> fn) { final T val = get(); if (val == UNSET) return (LazyImmutable<R>) this; else return LazyImmutable.of(fn.apply(val)); }
[ "@", "Override", "public", "<", "R", ">", "LazyImmutable", "<", "R", ">", "map", "(", "final", "Function", "<", "?", "super", "T", ",", "?", "extends", "R", ">", "fn", ")", "{", "final", "T", "val", "=", "get", "(", ")", ";", "if", "(", "val", ...
Map the value stored in this Immutable Closed Value from one Value to another If this is an unitiatilised ImmutableClosedValue, an uninitialised closed value will be returned instead @param fn Mapper function @return new ImmutableClosedValue with new mapped value
[ "Map", "the", "value", "stored", "in", "this", "Immutable", "Closed", "Value", "from", "one", "Value", "to", "another", "If", "this", "is", "an", "unitiatilised", "ImmutableClosedValue", "an", "uninitialised", "closed", "value", "will", "be", "returned", "instea...
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/util/box/LazyImmutable.java#L95-L102
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/util/box/LazyImmutable.java
LazyImmutable.flatMap
public <R> LazyImmutable<? extends R> flatMap(final Function<? super T, ? extends LazyImmutable<? extends R>> fn) { final T val = get(); if (val == UNSET) return (LazyImmutable<R>) this; else return fn.apply(val); }
java
public <R> LazyImmutable<? extends R> flatMap(final Function<? super T, ? extends LazyImmutable<? extends R>> fn) { final T val = get(); if (val == UNSET) return (LazyImmutable<R>) this; else return fn.apply(val); }
[ "public", "<", "R", ">", "LazyImmutable", "<", "?", "extends", "R", ">", "flatMap", "(", "final", "Function", "<", "?", "super", "T", ",", "?", "extends", "LazyImmutable", "<", "?", "extends", "R", ">", ">", "fn", ")", "{", "final", "T", "val", "="...
FlatMap the value stored in Immutable Closed Value from one Value to another If this is an unitiatilised ImmutableClosedValue, an uninitialised closed value will be returned instead @param fn Flat Mapper function @return new ImmutableClosedValue with new mapped value
[ "FlatMap", "the", "value", "stored", "in", "Immutable", "Closed", "Value", "from", "one", "Value", "to", "another", "If", "this", "is", "an", "unitiatilised", "ImmutableClosedValue", "an", "uninitialised", "closed", "value", "will", "be", "returned", "instead" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/util/box/LazyImmutable.java#L113-L120
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/util/box/LazyImmutable.java
LazyImmutable.computeIfAbsent
public T computeIfAbsent(final Supplier<T> lazy) { final T val = get(); if (val == UNSET) return setOnceFromSupplier(lazy); return val; }
java
public T computeIfAbsent(final Supplier<T> lazy) { final T val = get(); if (val == UNSET) return setOnceFromSupplier(lazy); return val; }
[ "public", "T", "computeIfAbsent", "(", "final", "Supplier", "<", "T", ">", "lazy", ")", "{", "final", "T", "val", "=", "get", "(", ")", ";", "if", "(", "val", "==", "UNSET", ")", "return", "setOnceFromSupplier", "(", "lazy", ")", ";", "return", "val"...
Get the current value or set if it has not been set yet @param lazy Supplier to generate new value @return Current value
[ "Get", "the", "current", "value", "or", "set", "if", "it", "has", "not", "been", "set", "yet" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/util/box/LazyImmutable.java#L150-L157
train
aol/cyclops
cyclops-futurestream/src/main/java/com/oath/cyclops/react/threads/ReactPool.java
ReactPool.elasticPool
public static <REACTOR extends ReactBuilder> ReactPool<REACTOR> elasticPool(final Supplier<REACTOR> supplier) { return new ReactPool<>( supplier); }
java
public static <REACTOR extends ReactBuilder> ReactPool<REACTOR> elasticPool(final Supplier<REACTOR> supplier) { return new ReactPool<>( supplier); }
[ "public", "static", "<", "REACTOR", "extends", "ReactBuilder", ">", "ReactPool", "<", "REACTOR", ">", "elasticPool", "(", "final", "Supplier", "<", "REACTOR", ">", "supplier", ")", "{", "return", "new", "ReactPool", "<>", "(", "supplier", ")", ";", "}" ]
If all REACTORs are in use calling react will create a new REACTOR to handle the extra demand. Generate an elastic pool of REACTORs @param supplier To create new REACTORs @return ReactPool
[ "If", "all", "REACTORs", "are", "in", "use", "calling", "react", "will", "create", "a", "new", "REACTOR", "to", "handle", "the", "extra", "demand", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/com/oath/cyclops/react/threads/ReactPool.java#L83-L87
train
aol/cyclops
cyclops-reactor-integration/src/main/java/cyclops/monads/transformers/reactor/MonoT.java
MonoT.flatMapT
public <B> MonoT<W,B> flatMapT(final Function<? super T, MonoT<W,B>> f) { MonoT<W, B> r = of(run.map(future -> Mono.from(future.flatMap(a -> { Mono<B> m = f.apply(a).run.stream() .toList() .get(0); return m; })))); return r; }
java
public <B> MonoT<W,B> flatMapT(final Function<? super T, MonoT<W,B>> f) { MonoT<W, B> r = of(run.map(future -> Mono.from(future.flatMap(a -> { Mono<B> m = f.apply(a).run.stream() .toList() .get(0); return m; })))); return r; }
[ "public", "<", "B", ">", "MonoT", "<", "W", ",", "B", ">", "flatMapT", "(", "final", "Function", "<", "?", "super", "T", ",", "MonoT", "<", "W", ",", "B", ">", ">", "f", ")", "{", "MonoT", "<", "W", ",", "B", ">", "r", "=", "of", "(", "ru...
Flat Map the wrapped Mono @param f FlatMap function @return MonoT that applies the flatMap function to the wrapped Mono
[ "Flat", "Map", "the", "wrapped", "Mono" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-reactor-integration/src/main/java/cyclops/monads/transformers/reactor/MonoT.java#L143-L151
train
aol/cyclops
cyclops-reactor-integration/src/main/java/cyclops/monads/transformers/reactor/MonoT.java
MonoT.of
public static <W extends WitnessType<W>,A> MonoT<W,A> of(final AnyM<W,Mono<A>> monads) { return new MonoT<>( monads); }
java
public static <W extends WitnessType<W>,A> MonoT<W,A> of(final AnyM<W,Mono<A>> monads) { return new MonoT<>( monads); }
[ "public", "static", "<", "W", "extends", "WitnessType", "<", "W", ">", ",", "A", ">", "MonoT", "<", "W", ",", "A", ">", "of", "(", "final", "AnyM", "<", "W", ",", "Mono", "<", "A", ">", ">", "monads", ")", "{", "return", "new", "MonoT", "<>", ...
Construct an MonoT from an AnyM that wraps a monad containing MonoWs @param monads AnyM that contains a monad wrapping an Mono @return MonoT
[ "Construct", "an", "MonoT", "from", "an", "AnyM", "that", "wraps", "a", "monad", "containing", "MonoWs" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-reactor-integration/src/main/java/cyclops/monads/transformers/reactor/MonoT.java#L187-L190
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/util/box/MutableInt.java
MutableInt.fromExternal
public static MutableInt fromExternal(final IntSupplier s, final IntConsumer c) { return new MutableInt() { @Override public int getAsInt() { return s.getAsInt(); } @Override public Integer get() { return getAsInt(); } @Override public MutableInt set(final int value) { c.accept(value); return this; } }; }
java
public static MutableInt fromExternal(final IntSupplier s, final IntConsumer c) { return new MutableInt() { @Override public int getAsInt() { return s.getAsInt(); } @Override public Integer get() { return getAsInt(); } @Override public MutableInt set(final int value) { c.accept(value); return this; } }; }
[ "public", "static", "MutableInt", "fromExternal", "(", "final", "IntSupplier", "s", ",", "final", "IntConsumer", "c", ")", "{", "return", "new", "MutableInt", "(", ")", "{", "@", "Override", "public", "int", "getAsInt", "(", ")", "{", "return", "s", ".", ...
Construct a MutableInt that gets and sets an external value using the provided Supplier and Consumer e.g. <pre> {@code MutableInt mutable = MutableInt.fromExternal(()->!this.value,val->!this.value); } </pre> @param s Supplier of an external value @param c Consumer that sets an external value @return MutableInt that gets / sets an external (mutable) value
[ "Construct", "a", "MutableInt", "that", "gets", "and", "sets", "an", "external", "value", "using", "the", "provided", "Supplier", "and", "Consumer" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/util/box/MutableInt.java#L80-L98
train
aol/cyclops
cyclops/src/main/java/com/oath/cyclops/util/box/MutableByte.java
MutableByte.fromExternal
public static MutableByte fromExternal(final Supplier<Byte> s, final Consumer<Byte> c) { return new MutableByte() { @Override public byte getAsByte() { return s.get(); } @Override public Byte get() { return getAsByte(); } @Override public MutableByte set(final byte value) { c.accept(value); return this; } }; }
java
public static MutableByte fromExternal(final Supplier<Byte> s, final Consumer<Byte> c) { return new MutableByte() { @Override public byte getAsByte() { return s.get(); } @Override public Byte get() { return getAsByte(); } @Override public MutableByte set(final byte value) { c.accept(value); return this; } }; }
[ "public", "static", "MutableByte", "fromExternal", "(", "final", "Supplier", "<", "Byte", ">", "s", ",", "final", "Consumer", "<", "Byte", ">", "c", ")", "{", "return", "new", "MutableByte", "(", ")", "{", "@", "Override", "public", "byte", "getAsByte", ...
Construct a MutableByte that gets and sets an external value using the provided Supplier and Consumer e.g. <pre> {@code MutableByte mutable = MutableByte.fromExternal(()->!this.value,val->!this.value); } </pre> @param s Supplier of an external value @param c Consumer that sets an external value @return MutableByte that gets / sets an external (mutable) value
[ "Construct", "a", "MutableByte", "that", "gets", "and", "sets", "an", "external", "value", "using", "the", "provided", "Supplier", "and", "Consumer" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/com/oath/cyclops/util/box/MutableByte.java#L81-L99
train
aol/cyclops
cyclops/src/main/java/cyclops/function/Predicates.java
Predicates.any
public static final <Y> Predicate<Y> any(final Class<Y> c) { return a -> a.getClass() .isAssignableFrom(c); }
java
public static final <Y> Predicate<Y> any(final Class<Y> c) { return a -> a.getClass() .isAssignableFrom(c); }
[ "public", "static", "final", "<", "Y", ">", "Predicate", "<", "Y", ">", "any", "(", "final", "Class", "<", "Y", ">", "c", ")", "{", "return", "a", "->", "a", ".", "getClass", "(", ")", ".", "isAssignableFrom", "(", "c", ")", ";", "}" ]
MatchType against any object that is an instance of supplied type <pre> {@code import static com.oath.cyclops.control.Matchable.whenGuard; import static com.oath.cyclops.control.Matchable.otherwise; import static com.oath.cyclops.control.Matchable.transform; import static cyclops2.function.Predicates.eq; import static cyclops2.function.Predicates.any; Matchable.of(Arrays.asList(1,2,3)) .matches(c->c.is(whenGuard(eq(1),any(Integer.class),eq(4)),transform("2")),otherwise("45")); } </pre> @param c Class type to fold against @return Predicate that mathes against type
[ "MatchType", "against", "any", "object", "that", "is", "an", "instance", "of", "supplied", "type" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops/src/main/java/cyclops/function/Predicates.java#L247-L250
train
aol/cyclops
cyclops-pure/src/main/java/cyclops/control/State.java
State.forEach2
public <R1, R4> State<S,R4> forEach2(Function<? super T, State<S,R1>> value2, BiFunction<? super T, ? super R1, ? extends R4> yieldingFunction) { return this.flatMap(in -> { State<S,R1> a = value2.apply(in); return a.map(in2 -> { return yieldingFunction.apply(in, in2); }); }); }
java
public <R1, R4> State<S,R4> forEach2(Function<? super T, State<S,R1>> value2, BiFunction<? super T, ? super R1, ? extends R4> yieldingFunction) { return this.flatMap(in -> { State<S,R1> a = value2.apply(in); return a.map(in2 -> { return yieldingFunction.apply(in, in2); }); }); }
[ "public", "<", "R1", ",", "R4", ">", "State", "<", "S", ",", "R4", ">", "forEach2", "(", "Function", "<", "?", "super", "T", ",", "State", "<", "S", ",", "R1", ">", ">", "value2", ",", "BiFunction", "<", "?", "super", "T", ",", "?", "super", ...
Perform a For Comprehension over a State, accepting a generating function. This results in a two level nested internal iteration over the provided States. <pre> {@code import static com.oath.cyclops.reactor.States.forEach; forEach(State.just(1), a-> State.just(a+1), Tuple::tuple) } </pre> @param value2 Nested State @param yieldingFunction Generates a result per combination @return State with a combined value generated by the yielding function
[ "Perform", "a", "For", "Comprehension", "over", "a", "State", "accepting", "a", "generating", "function", ".", "This", "results", "in", "a", "two", "level", "nested", "internal", "iteration", "over", "the", "provided", "States", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-pure/src/main/java/cyclops/control/State.java#L185-L198
train
aol/cyclops
cyclops-futurestream/src/main/java/com/oath/cyclops/internal/react/async/future/FastFuture.java
FastFuture.join
public T join() { try { long spin = 1; while (!done) { LockSupport.parkNanos(spin++); } if (completedExceptionally) throw new SimpleReactCompletionException( exception()); return result(); } finally { markComplete(); } }
java
public T join() { try { long spin = 1; while (!done) { LockSupport.parkNanos(spin++); } if (completedExceptionally) throw new SimpleReactCompletionException( exception()); return result(); } finally { markComplete(); } }
[ "public", "T", "join", "(", ")", "{", "try", "{", "long", "spin", "=", "1", ";", "while", "(", "!", "done", ")", "{", "LockSupport", ".", "parkNanos", "(", "spin", "++", ")", ";", "}", "if", "(", "completedExceptionally", ")", "throw", "new", "Simp...
Join which can be called exactly once! @return Result
[ "Join", "which", "can", "be", "called", "exactly", "once!" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/com/oath/cyclops/internal/react/async/future/FastFuture.java#L104-L118
train
aol/cyclops
cyclops-futurestream/src/main/java/com/oath/cyclops/internal/react/async/future/FastFuture.java
FastFuture.fromCompletableFuture
public static <T> FastFuture<T> fromCompletableFuture(final CompletableFuture<T> cf) { final FastFuture<T> f = new FastFuture<>(); cf.thenAccept(i -> f.set(i)); cf.exceptionally(t -> { f.completedExceptionally(t); return f.join(); }); return f; }
java
public static <T> FastFuture<T> fromCompletableFuture(final CompletableFuture<T> cf) { final FastFuture<T> f = new FastFuture<>(); cf.thenAccept(i -> f.set(i)); cf.exceptionally(t -> { f.completedExceptionally(t); return f.join(); }); return f; }
[ "public", "static", "<", "T", ">", "FastFuture", "<", "T", ">", "fromCompletableFuture", "(", "final", "CompletableFuture", "<", "T", ">", "cf", ")", "{", "final", "FastFuture", "<", "T", ">", "f", "=", "new", "FastFuture", "<>", "(", ")", ";", "cf", ...
Internal conversion method to convert CompletableFutures to FastFuture.
[ "Internal", "conversion", "method", "to", "convert", "CompletableFutures", "to", "FastFuture", "." ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/com/oath/cyclops/internal/react/async/future/FastFuture.java#L191-L200
train
aol/cyclops
cyclops-futurestream/src/main/java/com/oath/cyclops/types/futurestream/EagerFutureStreamFunctions.java
EagerFutureStreamFunctions.closeOthers
static void closeOthers(final Queue active, final List<Queue> all) { all.stream() .filter(next -> next != active) .forEach(Queue::closeAndClear); }
java
static void closeOthers(final Queue active, final List<Queue> all) { all.stream() .filter(next -> next != active) .forEach(Queue::closeAndClear); }
[ "static", "void", "closeOthers", "(", "final", "Queue", "active", ",", "final", "List", "<", "Queue", ">", "all", ")", "{", "all", ".", "stream", "(", ")", ".", "filter", "(", "next", "->", "next", "!=", "active", ")", ".", "forEach", "(", "Queue", ...
Close all queues except the active one @param active Queue not to close @param all All queues potentially including the active queue
[ "Close", "all", "queues", "except", "the", "active", "one" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/com/oath/cyclops/types/futurestream/EagerFutureStreamFunctions.java#L24-L29
train
aol/cyclops
cyclops-futurestream/src/main/java/com/oath/cyclops/types/futurestream/EagerFutureStreamFunctions.java
EagerFutureStreamFunctions.closeOthers
static void closeOthers(final SimpleReactStream active, final List<SimpleReactStream> all) { all.stream() .filter(next -> next != active) .filter(s -> s instanceof BaseSimpleReactStream) .forEach(SimpleReactStream::cancel); }
java
static void closeOthers(final SimpleReactStream active, final List<SimpleReactStream> all) { all.stream() .filter(next -> next != active) .filter(s -> s instanceof BaseSimpleReactStream) .forEach(SimpleReactStream::cancel); }
[ "static", "void", "closeOthers", "(", "final", "SimpleReactStream", "active", ",", "final", "List", "<", "SimpleReactStream", ">", "all", ")", "{", "all", ".", "stream", "(", ")", ".", "filter", "(", "next", "->", "next", "!=", "active", ")", ".", "filte...
Close all streams except the active one @param active Stream not to close @param all All streams potentially including the active stream
[ "Close", "all", "streams", "except", "the", "active", "one" ]
59a9fde30190a4d1faeb9f6d9851d209d82b81dd
https://github.com/aol/cyclops/blob/59a9fde30190a4d1faeb9f6d9851d209d82b81dd/cyclops-futurestream/src/main/java/com/oath/cyclops/types/futurestream/EagerFutureStreamFunctions.java#L37-L43
train