2013年12月4日星期三

List <> Scheduling


import java.util.List;
private List<UserCredential> userCredList;
userCredList=userCredSvr.mlist();

UserCredential is a model
I want to meet the specified conditions recorded Sticky , such UserCredential.name = "kevin", how to achieve , thank you !

------ Solution ------------------------------------ --------
if(UserCredential.name="kevin"){
    userCredList.add(0,UserCredential);
}else{
    userCredList.add(UserCredential);
}

------ For reference only ------------------------ ---------------
| --- List ( Interface )
Features: orderly, reusable elements , angular standard
| --- ArrayList
1.2 appears , asynchronous thread ( to improve efficiency ) , array implementation
Features: Find fast , deletions slow.
| --- LinkeList
1.2 appears threads asynchronously . doubly linked list
Features: Find slow, fast additions
| --- Vector
1.0 appears , thread synchronization , array implementation ( 100% ) , low performance
1.2 is ArrayList.
remove elements peculiar way : Enumeration
hasMoreElements
nextElement
method name is too long , we recommend using Iterator
hasNext
next
------ For reference only --------------------------------- ------
UserCredential achieve Comparator interface, you can call Collections.sort (userCredList), to achieve the sort.
------ For reference only -------------------------------------- -
If you just need a top element if the proposed lz swap it directly to the elements , if not the individual elements of it with the same upstairs .
------ For reference only -------------------------------------- -
achieve Comparator interface
------ For reference only ---------------------------- -----------

Collections.sort(userCredList, new Comparator<UserCredential>() {
....
});

没有评论:

发表评论