Skip to content

Commit

Permalink
0.9.77
Browse files Browse the repository at this point in the history
  • Loading branch information
landawn committed Jul 30, 2017
1 parent 169e0e1 commit aa69d10
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<classpathentry kind="src" path="samples"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="lib/abacus-util-0.9.76.jar"/>
<classpathentry kind="lib" path="lib/abacus-util-0.9.77.jar"/>
<classpathentry kind="lib" path="lib/log4j-1.2-api-2.3.jar"/>
<classpathentry kind="lib" path="lib/log4j-api-2.3.jar"/>
<classpathentry kind="lib" path="lib/log4j-core-2.3.jar"/>
Expand Down
8 changes: 8 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@


========Changes in 0.9.77=========================================================================

1*, change the return types of sumInt/sumLong/sumDouble from Long/Long/Double/ to int/long/double.

2, Improvements and bug fix.


========Changes in 0.9.76=========================================================================

1*, Refactoring: change the order of parameters from :
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
28 changes: 14 additions & 14 deletions src/com/landawn/abacus/DataSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -2756,7 +2756,7 @@ DataSet groupBy(Collection<String> columnNames, int fromRowIndex, int toRowIndex
* @param columnName
* @return
*/
Long sumInt(String columnName);
int sumInt(String columnName);

/**
*
Expand All @@ -2765,15 +2765,15 @@ DataSet groupBy(Collection<String> columnNames, int fromRowIndex, int toRowIndex
* @param toRowIndex
* @return
*/
Long sumInt(String columnName, int fromRowIndex, int toRowIndex);
int sumInt(String columnName, int fromRowIndex, int toRowIndex);

/**
*
* @param columnName
* @param mapper
* @return
*/
Long sumInt(String columnName, ToIntFunction<?> mapper);
int sumInt(String columnName, ToIntFunction<?> mapper);

/**
*
Expand All @@ -2783,13 +2783,13 @@ DataSet groupBy(Collection<String> columnNames, int fromRowIndex, int toRowIndex
* @param mapper
* @return
*/
Long sumInt(String columnName, int fromRowIndex, int toRowIndex, ToIntFunction<?> mapper);
int sumInt(String columnName, int fromRowIndex, int toRowIndex, ToIntFunction<?> mapper);

/**
* @param columnName
* @return
*/
Long sumLong(String columnName);
long sumLong(String columnName);

/**
*
Expand All @@ -2798,15 +2798,15 @@ DataSet groupBy(Collection<String> columnNames, int fromRowIndex, int toRowIndex
* @param toRowIndex
* @return
*/
Long sumLong(String columnName, int fromRowIndex, int toRowIndex);
long sumLong(String columnName, int fromRowIndex, int toRowIndex);

/**
*
* @param columnName
* @param mapper
* @return
*/
Long sumLong(String columnName, ToLongFunction<?> mapper);
long sumLong(String columnName, ToLongFunction<?> mapper);

/**
*
Expand All @@ -2816,13 +2816,13 @@ DataSet groupBy(Collection<String> columnNames, int fromRowIndex, int toRowIndex
* @param mapper
* @return
*/
Long sumLong(String columnName, int fromRowIndex, int toRowIndex, ToLongFunction<?> mapper);
long sumLong(String columnName, int fromRowIndex, int toRowIndex, ToLongFunction<?> mapper);

/**
* @param columnName
* @return
*/
Double sumDouble(String columnName);
double sumDouble(String columnName);

/**
*
Expand All @@ -2831,15 +2831,15 @@ DataSet groupBy(Collection<String> columnNames, int fromRowIndex, int toRowIndex
* @param toRowIndex
* @return
*/
Double sumDouble(String columnName, int fromRowIndex, int toRowIndex);
double sumDouble(String columnName, int fromRowIndex, int toRowIndex);

// /**
// *
// * @param columnName
// * @param mapper
// * @return
// */
// Long sum(String columnName, ToLongFunction<?> mapper);
// long sum(String columnName, ToLongFunction<?> mapper);
//
// /**
// *
Expand All @@ -2849,15 +2849,15 @@ DataSet groupBy(Collection<String> columnNames, int fromRowIndex, int toRowIndex
// * @param mapper
// * @return
// */
// Long sum(String columnName, int fromRowIndex, int toRowIndex, ToLongFunction<?> mapper);
// long sum(String columnName, int fromRowIndex, int toRowIndex, ToLongFunction<?> mapper);

/**
*
* @param columnName
* @param mapper
* @return
*/
Double sumDouble(String columnName, ToDoubleFunction<?> mapper);
double sumDouble(String columnName, ToDoubleFunction<?> mapper);

/**
*
Expand All @@ -2867,7 +2867,7 @@ DataSet groupBy(Collection<String> columnNames, int fromRowIndex, int toRowIndex
* @param mapper
* @return
*/
Double sumDouble(String columnName, int fromRowIndex, int toRowIndex, ToDoubleFunction<?> mapper);
double sumDouble(String columnName, int fromRowIndex, int toRowIndex, ToDoubleFunction<?> mapper);

/**
* @param columnName
Expand Down
2 changes: 1 addition & 1 deletion src/com/landawn/abacus/util/Fn.java
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ public static ToDoubleFunction<Double> unboxD() {
return Collectors.countingInt();
}

public static <T> Collector<T, ?, Long> summingInt(final ToIntFunction<? super T> mapper) {
public static <T> Collector<T, ?, Integer> summingInt(final ToIntFunction<? super T> mapper) {
return Collectors.summingInt(mapper);
}

Expand Down
36 changes: 18 additions & 18 deletions src/com/landawn/abacus/util/N.java
Original file line number Diff line number Diff line change
Expand Up @@ -19326,22 +19326,22 @@ public static <T, R, C extends Collection<R>> C map(final Collection<? extends T
return result;
}

public static <T> Long sumInt(final T[] a, final ToIntFunction<? super T> func) {
public static <T> int sumInt(final T[] a, final ToIntFunction<? super T> func) {
if (N.isNullOrEmpty(a)) {
return 0L;
return 0;
}

return sumInt(a, 0, a.length, func);
}

public static <T> Long sumInt(final T[] a, final int fromIndex, final int toIndex, final ToIntFunction<? super T> func) {
public static <T> int sumInt(final T[] a, final int fromIndex, final int toIndex, final ToIntFunction<? super T> func) {
checkFromToIndex(fromIndex, toIndex, a == null ? 0 : a.length);

if (fromIndex == toIndex) {
return 0L;
return 0;
}

long result = 0;
int result = 0;

for (int i = fromIndex; i < toIndex; i++) {
result += func.applyAsInt(a[i]);
Expand All @@ -19350,22 +19350,22 @@ public static <T> Long sumInt(final T[] a, final int fromIndex, final int toInde
return result;
}

public static <T> Long sumInt(final Collection<? extends T> c, final ToIntFunction<? super T> func) {
public static <T> int sumInt(final Collection<? extends T> c, final ToIntFunction<? super T> func) {
if (N.isNullOrEmpty(c)) {
return 0L;
return 0;
}

return sumInt(c, 0, c.size(), func);
}

public static <T> Long sumInt(final Collection<? extends T> c, final int fromIndex, final int toIndex, final ToIntFunction<? super T> func) {
public static <T> int sumInt(final Collection<? extends T> c, final int fromIndex, final int toIndex, final ToIntFunction<? super T> func) {
checkFromToIndex(fromIndex, toIndex, c == null ? 0 : c.size());

if (fromIndex == toIndex) {
return 0L;
return 0;
}

long result = 0;
int result = 0;

if (c instanceof List && c instanceof RandomAccess) {
final List<T> list = (List<T>) c;
Expand All @@ -19392,15 +19392,15 @@ public static <T> Long sumInt(final Collection<? extends T> c, final int fromInd
return result;
}

public static <T> Long sumLong(final T[] a, final ToLongFunction<? super T> func) {
public static <T> long sumLong(final T[] a, final ToLongFunction<? super T> func) {
if (N.isNullOrEmpty(a)) {
return 0L;
}

return sumLong(a, 0, a.length, func);
}

public static <T> Long sumLong(final T[] a, final int fromIndex, final int toIndex, final ToLongFunction<? super T> func) {
public static <T> long sumLong(final T[] a, final int fromIndex, final int toIndex, final ToLongFunction<? super T> func) {
checkFromToIndex(fromIndex, toIndex, a == null ? 0 : a.length);

if (fromIndex == toIndex) {
Expand All @@ -19416,15 +19416,15 @@ public static <T> Long sumLong(final T[] a, final int fromIndex, final int toInd
return result;
}

public static <T> Long sumLong(final Collection<? extends T> c, final ToLongFunction<? super T> func) {
public static <T> long sumLong(final Collection<? extends T> c, final ToLongFunction<? super T> func) {
if (N.isNullOrEmpty(c)) {
return 0L;
}

return sumLong(c, 0, c.size(), func);
}

public static <T> Long sumLong(final Collection<? extends T> c, final int fromIndex, final int toIndex, final ToLongFunction<? super T> func) {
public static <T> long sumLong(final Collection<? extends T> c, final int fromIndex, final int toIndex, final ToLongFunction<? super T> func) {
checkFromToIndex(fromIndex, toIndex, c == null ? 0 : c.size());

if (fromIndex == toIndex) {
Expand Down Expand Up @@ -19458,15 +19458,15 @@ public static <T> Long sumLong(final Collection<? extends T> c, final int fromIn
return result;
}

public static <T> Double sumDouble(final T[] a, final ToDoubleFunction<? super T> func) {
public static <T> double sumDouble(final T[] a, final ToDoubleFunction<? super T> func) {
if (N.isNullOrEmpty(a)) {
return 0D;
}

return sumDouble(a, 0, a.length, func);
}

public static <T> Double sumDouble(final T[] a, final int fromIndex, final int toIndex, final ToDoubleFunction<? super T> func) {
public static <T> double sumDouble(final T[] a, final int fromIndex, final int toIndex, final ToDoubleFunction<? super T> func) {
checkFromToIndex(fromIndex, toIndex, a == null ? 0 : a.length);

if (fromIndex == toIndex) {
Expand All @@ -19482,15 +19482,15 @@ public static <T> Double sumDouble(final T[] a, final int fromIndex, final int t
return result;
}

public static <T> Double sumDouble(final Collection<? extends T> c, final ToDoubleFunction<? super T> func) {
public static <T> double sumDouble(final Collection<? extends T> c, final ToDoubleFunction<? super T> func) {
if (N.isNullOrEmpty(c)) {
return 0D;
}

return sumDouble(c, 0, c.size(), func);
}

public static <T> Double sumDouble(final Collection<? extends T> c, final int fromIndex, final int toIndex, final ToDoubleFunction<? super T> func) {
public static <T> double sumDouble(final Collection<? extends T> c, final int fromIndex, final int toIndex, final ToDoubleFunction<? super T> func) {
checkFromToIndex(fromIndex, toIndex, c == null ? 0 : c.size());

if (fromIndex == toIndex) {
Expand Down
30 changes: 15 additions & 15 deletions src/com/landawn/abacus/util/Seq.java
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,12 @@ public NullabLe<T> kthLargest(final int k, Comparator<? super T> cmp) {
return size() < k ? (NullabLe<T>) NullabLe.empty() : NullabLe.of(N.kthLargest(coll, k, cmp));
}

public Long sumInt() {
public int sumInt() {
if (N.isNullOrEmpty(coll)) {
return 0L;
return 0;
}

long result = 0L;
int result = 0;

for (T e : coll) {
if (e != null) {
Expand All @@ -371,12 +371,12 @@ public Long sumInt() {
return result;
}

public Long sumInt(final ToIntFunction<? super T> mapper) {
public int sumInt(final ToIntFunction<? super T> mapper) {
if (N.isNullOrEmpty(coll)) {
return 0L;
return 0;
}

long result = 0L;
int result = 0;

for (T e : coll) {
result += mapper.applyAsInt(e);
Expand All @@ -385,12 +385,12 @@ public Long sumInt(final ToIntFunction<? super T> mapper) {
return result;
}

public Long sumLong() {
public long sumLong() {
if (N.isNullOrEmpty(coll)) {
return 0L;
}

long result = 0L;
long result = 0;

for (T e : coll) {
if (e != null) {
Expand All @@ -401,7 +401,7 @@ public Long sumLong() {
return result;
}

public Long sumLong(final ToLongFunction<? super T> mapper) {
public long sumLong(final ToLongFunction<? super T> mapper) {
if (N.isNullOrEmpty(coll)) {
return 0L;
}
Expand All @@ -415,7 +415,7 @@ public Long sumLong(final ToLongFunction<? super T> mapper) {
return result;
}

public Double sumDouble() {
public double sumDouble() {
if (N.isNullOrEmpty(coll)) {
return 0D;
}
Expand All @@ -428,24 +428,24 @@ public double applyAsDouble(Number value) {
});
}

public Double sumDouble(final ToDoubleFunction<? super T> mapper) {
public double sumDouble(final ToDoubleFunction<? super T> mapper) {
return size() == 0 ? 0d : N.sumDouble(coll, mapper);
}

public OptionalDouble averageInt() {
return size() == 0 ? OptionalDouble.empty() : OptionalDouble.of(sumInt().doubleValue() / size());
return size() == 0 ? OptionalDouble.empty() : OptionalDouble.of(((double) sumInt()) / size());
}

public OptionalDouble averageInt(final ToIntFunction<? super T> mapper) {
return size() == 0 ? OptionalDouble.empty() : OptionalDouble.of(sumInt(mapper).doubleValue() / size());
return size() == 0 ? OptionalDouble.empty() : OptionalDouble.of(((double) sumInt(mapper)) / size());
}

public OptionalDouble averageLong() {
return size() == 0 ? OptionalDouble.empty() : OptionalDouble.of(sumLong().doubleValue() / size());
return size() == 0 ? OptionalDouble.empty() : OptionalDouble.of(((double) sumLong()) / size());
}

public OptionalDouble averageLong(final ToLongFunction<? super T> mapper) {
return size() == 0 ? OptionalDouble.empty() : OptionalDouble.of(sumLong(mapper).doubleValue() / size());
return size() == 0 ? OptionalDouble.empty() : OptionalDouble.of(((double) sumLong(mapper)) / size());
}

public OptionalDouble averageDouble() {
Expand Down
6 changes: 3 additions & 3 deletions src/com/landawn/abacus/util/stream/AbstractStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -1289,17 +1289,17 @@ public T[] apply(int value) {
}

@Override
public Long sumInt(ToIntFunction<? super T> mapper) {
public int sumInt(ToIntFunction<? super T> mapper) {
return collect(Collectors.summingInt(mapper));
}

@Override
public Long sumLong(ToLongFunction<? super T> mapper) {
public long sumLong(ToLongFunction<? super T> mapper) {
return collect(Collectors.summingLong(mapper));
}

@Override
public Double sumDouble(ToDoubleFunction<? super T> mapper) {
public double sumDouble(ToDoubleFunction<? super T> mapper) {
return collect(Collectors.summingDouble(mapper));
}

Expand Down
Loading

0 comments on commit aa69d10

Please sign in to comment.