Reference: http://blog.csdn.net/sunmenggmail/article/details/8952712
Http://www.cnblogs.com/fstang/archive/2013/04/20/3032097.html
I want a arraylist<entry>, like a pair object in C + +, but Map.entry is an interface that cannot be instantiated and can be written like this
/**
* Select a total of 2 columns of the Continuity attribute column and the dependent variable column ———— based on the column index of the continuous attribute--to indicate that the dependent variable can have only 1 columns
* For example, temperature is the third column, find these 2 columns of data for temperature and Decisionindex
* @paramColumn index of index continuous property
* @returnArraylist<entry<metacell, Metacell>> returns the continuity attribute column and the dependent variable column data--all 2 are hot, corresponding to the same case where the value of the dependent variable is no--no map, Available Arraylist<entry<metacell, metacell>>
*/
PublicArraylist<entry<metacell, Metacell>> Getdecisionvalue (intIndex) {
if( This. decisionindex.length!=1) {
SYSTEM.OUT.PRINTLN ("Error! Model requirements dependent variable is a single dependent variable");
System.exit (-1);//Exit
return NULL;
}
//1. The following implementation of the key can be the same ArrayList type of map function (key can be repeated)
Arraylist<entry<metacell, metacell>> list =NewArraylist<entry<metacell, Metacell>> ( This. celldata.m);//Initialize--entry reference http://blog.csdn.net/sunmenggmail/article/details/8952712 andhttp://www.cnblogs.com/fstang/archive/2013/04/20/3032097.html
for(inti = 0; I < This. celldata.m; i++) {
List.add (NewAbstractmap.simpleentry<metacell, Metacell> ( This. CellData.data.get (i). Get (Index), This. CellData.data.get (i). Get ( This. Decisionindex[0].getvalue ())));
}
//2. Sorting
Collections.sort (list,NewComparator<entry<metacell, metacell>> () {
@Override
PublicintCompare (Entry<metacell, metacell> O1, Entry<metacell, metacell> O2) {
returnO1.getkey (). CompareTo (O2.getkey ());//key comparison--greater than 0 means ascending--here key must be Doublecell, automatically call Doublecell in CompareTo (override)
}
});
returnList
}
Java entry Use