Skip to content

Commit

Permalink
0.9.52
Browse files Browse the repository at this point in the history
  • Loading branch information
landawn committed Feb 22, 2017
1 parent 96a3bf0 commit 101c181
Show file tree
Hide file tree
Showing 34 changed files with 924 additions and 263 deletions.
6 changes: 4 additions & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

2, Remove type parameter from SQLBuilder and CQLBuilder.

3, Import collapse from StreamEx.
3, Import collapse from StreamEx to Stream/IntStream/...

4, Improvements and bug fix.
4, add map2/map3 to Stream

5, Improvements and bug fix.


========Changes in 0.9.51=========================================================================
Expand Down
Binary file modified lib/abacus-util-0.9.52.jar
Binary file not shown.
Binary file modified lib/abacus-util-all-0.9.52.jar
Binary file not shown.
82 changes: 0 additions & 82 deletions src/com/landawn/abacus/android/util/EventBus.java

This file was deleted.

6 changes: 5 additions & 1 deletion src/com/landawn/abacus/eventBus/EventBus.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import com.landawn.abacus.logging.Logger;
import com.landawn.abacus.logging.LoggerFactory;
Expand All @@ -37,6 +39,8 @@
public class EventBus {
private static final Logger logger = LoggerFactory.getLogger(EventBus.class);

private static final ExecutorService asyncExecutor = Executors.newFixedThreadPool(32);

private static final Multimap<Class<?>, Method, List<Method>> classSubscriberMethodMap = new Multimap<>(ConcurrentHashMap.class, ArrayList.class);

private final Multimap<Object, MethodIdentifier, Set<MethodIdentifier>> subscriberMethodMap = new Multimap<>(LinkedHashMap.class, HashSet.class);
Expand Down Expand Up @@ -207,7 +211,7 @@ protected void executeEvent(final Object obj, final Method method, final Object
return;

case THREAD_POOL_EXECUTOR:
N.asyncExecute(new Runnable() {
asyncExecutor.execute(new Runnable() {
@Override
public void run() {
invokeMethod(obj, method, event);
Expand Down
5 changes: 3 additions & 2 deletions src/com/landawn/abacus/util/Profiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;

import com.landawn.abacus.exception.AbacusException;
Expand Down Expand Up @@ -221,7 +222,7 @@ private static MultiLoopsStatistics run(final Object instance, final String meth

N.sleep(1000);

final AsyncExecutor asyncExecutor = new AsyncExecutor(threadNum, 300, TimeUnit.SECONDS);
final ExecutorService asyncExecutor = Executors.newFixedThreadPool(threadNum);
final AtomicInteger threadCounter = new AtomicInteger();

// MXBean mxBean = new MXBean();
Expand Down
31 changes: 31 additions & 0 deletions src/com/landawn/abacus/util/stream/AbstractByteStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import com.landawn.abacus.util.function.BiFunction;
import com.landawn.abacus.util.function.BinaryOperator;
import com.landawn.abacus.util.function.ByteBiFunction;
import com.landawn.abacus.util.function.ByteBiPredicate;
import com.landawn.abacus.util.function.ByteConsumer;
import com.landawn.abacus.util.function.ByteFunction;
import com.landawn.abacus.util.function.BytePredicate;
Expand Down Expand Up @@ -172,6 +173,36 @@ public ByteStream apply(ByteList t) {
});
}

@Override
public ByteStream collapse(final ByteBiPredicate collapsible, final ByteBiFunction<Byte> mergeFunction) {
final ImmutableByteIterator iter = byteIterator();

return this.newStream(new ImmutableByteIterator() {
private byte pre = 0;
private boolean hasNext = false;

@Override
public boolean hasNext() {
return hasNext || iter.hasNext();
}

@Override
public byte next() {
byte res = hasNext ? pre : (pre = iter.next());

while ((hasNext = iter.hasNext())) {
if (collapsible.test(pre, (pre = iter.next()))) {
res = mergeFunction.apply(res, pre);
} else {
break;
}
}

return res;
}
}, false);
}

@Override
public <K> Map<K, List<Byte>> toMap(ByteFunction<? extends K> classifier) {
@SuppressWarnings("rawtypes")
Expand Down
31 changes: 31 additions & 0 deletions src/com/landawn/abacus/util/stream/AbstractCharStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import com.landawn.abacus.util.function.BiFunction;
import com.landawn.abacus.util.function.BinaryOperator;
import com.landawn.abacus.util.function.CharBiFunction;
import com.landawn.abacus.util.function.CharBiPredicate;
import com.landawn.abacus.util.function.CharConsumer;
import com.landawn.abacus.util.function.CharFunction;
import com.landawn.abacus.util.function.CharPredicate;
Expand Down Expand Up @@ -172,6 +173,36 @@ public CharStream apply(CharList t) {
});
}

@Override
public CharStream collapse(final CharBiPredicate collapsible, final CharBiFunction<Character> mergeFunction) {
final ImmutableCharIterator iter = charIterator();

return this.newStream(new ImmutableCharIterator() {
private char pre = 0;
private boolean hasNext = false;

@Override
public boolean hasNext() {
return hasNext || iter.hasNext();
}

@Override
public char next() {
char res = hasNext ? pre : (pre = iter.next());

while ((hasNext = iter.hasNext())) {
if (collapsible.test(pre, (pre = iter.next()))) {
res = mergeFunction.apply(res, pre);
} else {
break;
}
}

return res;
}
}, false);
}

@Override
public <K> Map<K, List<Character>> toMap(CharFunction<? extends K> classifier) {
@SuppressWarnings("rawtypes")
Expand Down
31 changes: 31 additions & 0 deletions src/com/landawn/abacus/util/stream/AbstractDoubleStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import com.landawn.abacus.util.function.BinaryOperator;
import com.landawn.abacus.util.function.Consumer;
import com.landawn.abacus.util.function.DoubleBiFunction;
import com.landawn.abacus.util.function.DoubleBiPredicate;
import com.landawn.abacus.util.function.DoubleConsumer;
import com.landawn.abacus.util.function.DoubleFunction;
import com.landawn.abacus.util.function.DoublePredicate;
Expand Down Expand Up @@ -172,6 +173,36 @@ public DoubleStream apply(DoubleList t) {
});
}

@Override
public DoubleStream collapse(final DoubleBiPredicate collapsible, final DoubleBiFunction<Double> mergeFunction) {
final ImmutableDoubleIterator iter = doubleIterator();

return this.newStream(new ImmutableDoubleIterator() {
private double pre = 0;
private boolean hasNext = false;

@Override
public boolean hasNext() {
return hasNext || iter.hasNext();
}

@Override
public double next() {
double res = hasNext ? pre : (pre = iter.next());

while ((hasNext = iter.hasNext())) {
if (collapsible.test(pre, (pre = iter.next()))) {
res = mergeFunction.apply(res, pre);
} else {
break;
}
}

return res;
}
}, false);
}

@Override
public <K> Map<K, List<Double>> toMap(DoubleFunction<? extends K> classifier) {
@SuppressWarnings("rawtypes")
Expand Down
47 changes: 39 additions & 8 deletions src/com/landawn/abacus/util/stream/AbstractFloatStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.landawn.abacus.util.function.BinaryOperator;
import com.landawn.abacus.util.function.Consumer;
import com.landawn.abacus.util.function.FloatBiFunction;
import com.landawn.abacus.util.function.FloatBiPredicate;
import com.landawn.abacus.util.function.FloatConsumer;
import com.landawn.abacus.util.function.FloatFunction;
import com.landawn.abacus.util.function.FloatPredicate;
Expand Down Expand Up @@ -163,14 +164,6 @@ public FloatStream apply(FloatList t) {
});
}

@Override
public <K> Map<K, List<Float>> toMap(FloatFunction<? extends K> classifier) {
@SuppressWarnings("rawtypes")
final Supplier<Map<K, List<Float>>> mapFactory = (Supplier) Supplier.MAP;

return toMap(classifier, mapFactory);
}

@Override
public Stream<FloatStream> sliding(final int windowSize, final int increment) {
return sliding0(windowSize, increment).map(new Function<FloatList, FloatStream>() {
Expand All @@ -181,6 +174,44 @@ public FloatStream apply(FloatList t) {
});
}

@Override
public FloatStream collapse(final FloatBiPredicate collapsible, final FloatBiFunction<Float> mergeFunction) {
final ImmutableFloatIterator iter = floatIterator();

return this.newStream(new ImmutableFloatIterator() {
private float pre = 0;
private boolean hasNext = false;

@Override
public boolean hasNext() {
return hasNext || iter.hasNext();
}

@Override
public float next() {
float res = hasNext ? pre : (pre = iter.next());

while ((hasNext = iter.hasNext())) {
if (collapsible.test(pre, (pre = iter.next()))) {
res = mergeFunction.apply(res, pre);
} else {
break;
}
}

return res;
}
}, false);
}

@Override
public <K> Map<K, List<Float>> toMap(FloatFunction<? extends K> classifier) {
@SuppressWarnings("rawtypes")
final Supplier<Map<K, List<Float>>> mapFactory = (Supplier) Supplier.MAP;

return toMap(classifier, mapFactory);
}

@Override
public <K, M extends Map<K, List<Float>>> M toMap(FloatFunction<? extends K> classifier, Supplier<M> mapFactory) {
final Collector<Float, ?, List<Float>> downstream = Collectors.toList();
Expand Down
31 changes: 31 additions & 0 deletions src/com/landawn/abacus/util/stream/AbstractIntStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.landawn.abacus.util.function.Consumer;
import com.landawn.abacus.util.function.Function;
import com.landawn.abacus.util.function.IntBiFunction;
import com.landawn.abacus.util.function.IntBiPredicate;
import com.landawn.abacus.util.function.IntConsumer;
import com.landawn.abacus.util.function.IntFunction;
import com.landawn.abacus.util.function.IntPredicate;
Expand Down Expand Up @@ -172,6 +173,36 @@ public IntStream apply(IntList t) {
});
}

@Override
public IntStream collapse(final IntBiPredicate collapsible, final IntBiFunction<Integer> mergeFunction) {
final ImmutableIntIterator iter = intIterator();

return this.newStream(new ImmutableIntIterator() {
private int pre = 0;
private boolean hasNext = false;

@Override
public boolean hasNext() {
return hasNext || iter.hasNext();
}

@Override
public int next() {
int res = hasNext ? pre : (pre = iter.next());

while ((hasNext = iter.hasNext())) {
if (collapsible.test(pre, (pre = iter.next()))) {
res = mergeFunction.apply(res, pre);
} else {
break;
}
}

return res;
}
}, false);
}

@Override
public <K> Map<K, List<Integer>> toMap(IntFunction<? extends K> classifier) {
@SuppressWarnings("rawtypes")
Expand Down
Loading

0 comments on commit 101c181

Please sign in to comment.