Java entry Use

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.