Only remember last link for each node + changed node comparator to sort by id

This commit is contained in:
nifi 2010-09-14 22:40:59 +00:00
parent dc9f16131c
commit 85ca99f66a

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: Node.java,v 1.4 2010/09/14 10:38:12 nifi Exp $ * $Id: Node.java,v 1.5 2010/09/14 22:40:59 nifi Exp $
* *
* ----------------------------------------------------------------- * -----------------------------------------------------------------
* *
@ -34,8 +34,8 @@
* *
* Authors : Joakim Eriksson, Niclas Finne * Authors : Joakim Eriksson, Niclas Finne
* Created : 3 jul 2008 * Created : 3 jul 2008
* Updated : $Date: 2010/09/14 10:38:12 $ * Updated : $Date: 2010/09/14 22:40:59 $
* $Revision: 1.4 $ * $Revision: 1.5 $
*/ */
package se.sics.contiki.collect; package se.sics.contiki.collect;
@ -47,6 +47,8 @@ import java.util.Hashtable;
*/ */
public class Node implements Comparable<Node> { public class Node implements Comparable<Node> {
private static final boolean SINGLE_LINK = true;
private SensorDataAggregator sensorDataAggregator; private SensorDataAggregator sensorDataAggregator;
private ArrayList<SensorData> sensorDataList = new ArrayList<SensorData>(); private ArrayList<SensorData> sensorDataList = new ArrayList<SensorData>();
private ArrayList<Link> links = new ArrayList<Link>(); private ArrayList<Link> links = new ArrayList<Link>();
@ -101,7 +103,13 @@ public class Node implements Comparable<Node> {
@Override @Override
public int compareTo(Node o) { public int compareTo(Node o) {
return name.compareTo(o.name); String i1 = id;
String i2 = o.getID();
// Shorter id first (4.0 before 10.0)
if (i1.length() == i2.length()) {
return i1.compareTo(i2);
}
return i1.length() - i2.length();
} }
public String toString() { public String toString() {
@ -194,6 +202,9 @@ public class Node implements Comparable<Node> {
// Add new link // Add new link
Link l = new Link(node); Link l = new Link(node);
if (SINGLE_LINK) {
links.clear();
}
links.add(l); links.add(l);
return l; return l;
} }