Skip to content

Commit

Permalink
Update FlatDataCollection API, modify Descriptives class to handle nu…
Browse files Browse the repository at this point in the history
…lls.
  • Loading branch information
datumbox committed Aug 30, 2017
1 parent 8fe6ef9 commit de9ceeb
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 177 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
@@ -1,10 +1,16 @@
CHANGELOG
=========

Version 0.8.1-SNAPSHOT - Build 20170310
Version 0.8.1-SNAPSHOT - Build 20170830
---------------------------------------

- Updated the Maven Compiler, Nexus Staging, SLF4J and Logback Classic plugins to the latest stable versions.
- FlatDataColletion changes:
- The copyCollection2DoubleArray() and copyCollection2Array() methods are removed.
- It now implements the Collection Interface instead of the Iterable.
- Descriptives class:
- New count() method returns the number of non-null elements.
- All methods can now handle null values. Null values are considered missing and they are ignored from the calculations.

Version 0.8.0 - Build 20170114
------------------------------
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -27,7 +27,7 @@ The latest stable version of the framework is 0.8.0 (Build 20170114). To use it,
</dependency>
```

The latest snapshot version of the framework is 0.8.1-SNAPSHOT (Build 20170310). To test it, update your pom.xml as follows:
The latest snapshot version of the framework is 0.8.1-SNAPSHOT (Build 20170830). To test it, update your pom.xml as follows:
```
<repository>
<id>sonatype-snapshots</id>
Expand Down
Expand Up @@ -15,7 +15,6 @@
*/
package com.datumbox.framework.common.dataobjects;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
Expand All @@ -29,45 +28,9 @@
*
* @author Vasilis Vryniotis <bbriniotis@datumbox.com>
*/
public class FlatDataCollection extends AbstractDataStructureCollection<Collection<Object>> implements Iterable<Object> {
public class FlatDataCollection extends AbstractDataStructureCollection<Collection<Object>> implements Collection<Object> {
private static final long serialVersionUID = 1L;

/**
* Converts to Object[] the original FlatDataCollection. The method is used to
* generate a copy of the flatDataCollection and it is called in order to
* avoid modifying the original array.
*
* @param <T>
* @param c
* @return
*/
public final <T> T[] copyCollection2Array(Class<T> c) {
int n = internalData.size();
T[] copy = (T[]) Array.newInstance(c, n);
int i = 0;
for (Object value : internalData) {
copy[i++] = c.cast(value);
}
return copy;
}

/**
* Converts to Double[] safely the original FlatDataCollection by using the
* iteratorDouble.
*
* @return
*/
public final Double[] copyCollection2DoubleArray() {
int n = internalData.size();
Double[] doubleArray = new Double[n];
int i = 0;
Iterator<Double> it = this.iteratorDouble();
while (it.hasNext()) {
doubleArray[i++] = it.next();
}
return doubleArray;
}

/**
* Public constructor which accepts as argument a Collection of Objects.
*
Expand All @@ -87,7 +50,31 @@ public FlatDataCollection(Collection<Object> internalData) {
public final boolean remove(Object o) {
return internalData.remove(o);
}


/** {@inheritDoc} */
@Override
public boolean containsAll(Collection<?> c) {
return internalData.containsAll(c);
}

/** {@inheritDoc} */
@Override
public boolean addAll(Collection<?> c) {
return internalData.addAll(c);
}

/** {@inheritDoc} */
@Override
public boolean removeAll(Collection<?> c) {
return internalData.removeAll(c);
}

/** {@inheritDoc} */
@Override
public boolean retainAll(Collection<?> c) {
return internalData.retainAll(c);
}

/**
* It adds an object in the collection. It returns a boolean which indicates
* whether the collection changed as a result of the call.
Expand All @@ -99,24 +86,18 @@ public final boolean add(Object e) {
return internalData.add(e);
}

/**
* Adds all the objects of the provided collection to the internal data. It
* returns a boolean which indicates whether the collection changed as a
* result of the call.
*
* @param c
* @return
*/
public final boolean addAll(Collection<Object> c) {
return internalData.addAll(c);
}

/** {@inheritDoc} */
@Override
public final Iterator<Object> iterator() {
return internalData.iterator();
}


/** {@inheritDoc} */
@Override
public <T> T[] toArray(T[] a) {
return internalData.toArray(a);
}

/**
* Converts the FlatDataCollection to a FlatDataList trying (if possible)
* not to copy the data.
Expand Down

0 comments on commit de9ceeb

Please sign in to comment.