锘??xml version="1.0" encoding="utf-8" standalone="yes"?>一本色道久久88—综合亚洲精品,亚洲中久无码不卡永久在线观看,亚洲一级二级三级不卡http://www.tkk7.com/liuwenbo200285/zh-cnTue, 13 May 2025 18:28:38 GMTTue, 13 May 2025 18:28:38 GMT60鍦╦ava-web欏圭洰涓祵鍏etty錛屽揩閫熻繘琛岃皟璇曪紒http://www.tkk7.com/liuwenbo200285/articles/410594.html涔愰殢蹇冨姩涔愰殢蹇冨姩Tue, 04 Mar 2014 07:40:00 GMThttp://www.tkk7.com/liuwenbo200285/articles/410594.htmlhttp://www.tkk7.com/liuwenbo200285/comments/410594.htmlhttp://www.tkk7.com/liuwenbo200285/articles/410594.html#Feedback0http://www.tkk7.com/liuwenbo200285/comments/commentRss/410594.htmlhttp://www.tkk7.com/liuwenbo200285/services/trackbacks/410594.html        <dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>7.2.2.v20101205</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1-glassfish</artifactId>
<version>2.1.v20100127</version>
</dependency>
       鍒涘緩涓涓猨ava綾伙細
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
public class GameAdmin {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        try {
            Server server = buildNormalServer(8080, "/gameweb");
            server.start();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    
    /**
     * 鍒涘緩鐢ㄤ簬姝e父榪愯璋冭瘯鐨凧etty Server, 浠rc/main/webapp涓篧eb搴旂敤鐩綍.
     
*/
    public static Server buildNormalServer(int port, String contextPath) {
        Server server = new Server(port);
        WebAppContext webContext = new WebAppContext("src/main/webapp", contextPath);
        webContext.setClassLoader(Thread.currentThread().getContextClassLoader());
        server.setHandler(webContext);
        server.setStopAtShutdown(true);
        return server;
    }

}


]]>
java涓殑Comparable涓嶤omparatorhttp://www.tkk7.com/liuwenbo200285/articles/364890.html涔愰殢蹇冨姩涔愰殢蹇冨姩Sat, 26 Nov 2011 09:44:00 GMThttp://www.tkk7.com/liuwenbo200285/articles/364890.htmlhttp://www.tkk7.com/liuwenbo200285/comments/364890.htmlhttp://www.tkk7.com/liuwenbo200285/articles/364890.html#Feedback0http://www.tkk7.com/liuwenbo200285/comments/commentRss/364890.htmlhttp://www.tkk7.com/liuwenbo200285/services/trackbacks/364890.html       鍏堟潵鐪嬬湅榪?涓帴鍙e湪jdk API縐嶇殑瑙i噴錛?br />              Comparable:姝ゆ帴鍙e己琛屽瀹炵幇瀹冪殑姣忎釜綾葷殑瀵硅薄榪涜鏁翠綋鎺掑簭銆傝繖縐嶆帓搴忚縐頒負綾葷殑鑷劧鎺掑簭錛岀被鐨?compareTo 鏂規硶琚О涓哄畠鐨勮嚜鐒舵瘮杈冩柟娉曘?br />瀹炵幇姝ゆ帴鍙g殑瀵硅薄鍒楄〃錛堝拰鏁扮粍錛夊彲浠ラ氳繃 Collections.sort錛堝拰 Arrays.sort錛夎繘琛岃嚜鍔ㄦ帓搴忋傚疄鐜版鎺ュ彛鐨勫璞″彲浠ョ敤浣滄湁搴忔槧灝勪腑鐨勯敭鎴栨湁搴忛泦鍚堜腑鐨勫厓绱狅紝鏃犻渶鎸囧畾姣旇緝鍣ㄣ?br />              Comparator:寮鴻瀵規煇涓璞?collection 榪涜鏁翠綋鎺掑簭 鐨勬瘮杈冨嚱鏁般傚彲浠ュ皢 Comparator 浼犻掔粰 sort 鏂規硶錛堝 Collections.sort 鎴?Arrays.sort錛夛紝浠庤屽厑璁稿湪鎺掑簭欏哄簭涓婂疄鐜扮簿紜帶鍒躲傝繕鍙互浣跨敤 Comparator 鏉ユ帶鍒舵煇浜涙暟鎹粨鏋勶紙濡傛湁搴?set鎴栨湁搴忔槧灝勶級鐨勯『搴忥紝鎴栬呬負閭d簺娌℃湁鑷劧欏哄簭鐨勫璞?collection 鎻愪緵鎺掑簭銆?br />              瀹炵幇姝ゆ帴鍙g殑瀵硅薄鍙互鐢ㄤ綔鏈夊簭鏄犲皠涓殑閿垨鏈夊簭闆嗗悎涓殑鍏冪礌錛屾棤闇鎸囧畾姣旇緝鍣ㄣ備粠榪欏彞璇濆彲浠ョ湅鍑烘垜浠箣鎵浠ュ彲浠ュ鏁板瓧鎴栬呭瓧姣嶈繘琛屾帓搴忚屼笉闇鍒跺畾姣旇緝鍣紝鏄洜涓哄湪JDK涓粬浠凡緇忓疄鐜頒簡Comparable鎺ュ彛,鎵浠ラ氳繃Collections.sort鍜?Arrays.sort鏂規硶鍙互緇欎粬浠寜鑷劧欏哄簭鎺掑簭錛屽綋鎴戜滑瑕佸涓涓嚜瀹氫箟瀵硅薄榪涜鎺掑簭鐨勬椂鍊欙紝涔熷彲浠ュ疄鐜癈omparable鎺ュ彛錛屽疄鐜板畠鐨刢ompareTo鏂規硶銆?br />          
1 @Override
2     public int compareTo(User user) {
3         if(this == null || user == null || this.getAge() > user.getAge())
4             return 1;
5         if(this.getAge() < user.getAge())
6             return -1;
7         return 0;
8     }
     濡傛灉璇ュ璞″皬浜庛佺瓑浜庢垨澶т簬鎸囧畾瀵硅薄錛屽垯鍒嗗埆榪斿洖璐熸暣鏁般侀浂鎴栨鏁存暟錛屽彲浠ラ氳繃榪斿洖鐨勫兼潵鎺у埗瀵硅薄鍦ㄩ泦鍚堢殑浣嶇疆錛屽彲浠ユ寜騫撮緞鐨勫皬鍒板ぇ鎺掑簭錛屼篃鍙互鎸夊勾榫勭殑澶у埌灝忔帓搴忋?br />     濡傛灉瑕佺敤Comparator鎺ュ彛鏉ュ疄鐜板璞″湪闆嗗悎涓殑鎺掑簭錛岀洿鎺ュ湪瀵硅薄涓疄鐜癈omparator鎺ュ彛鏄笉璧蜂綔鐢ㄧ殑(閽堝TreeSet,涓嬫枃涓竴鏍鳳紝鍏跺畠鐨勯泦鍚堢被榪樻病鍙戠幇鍙互鍦ㄥ璞′腑瀹炵幇Comparator鏉ヨ繘琛屾帓搴?錛岄渶瑕佸彟澶栨柊寤轟竴涓被瀹炵幇Comparator鎺ュ彛錛岀劧鍚庨氳繃闆嗗悎鐨勬瀯閫犲嚱鏁頒紶鍒伴泦鍚堜腑錛屾墠浼氳搗浣滅敤錛岀洿鎺ョ湅TreeSet鐨勬簮浠g爜鍚с?br />
 1 int cmp;
 2         Entry<K,V> parent;
 3         // split comparator and comparable paths
 4         Comparator<? super K> cpr = comparator;
 5         if (cpr != null) {
 6             do {
 7                 parent = t;
 8                 cmp = cpr.compare(key, t.key);
 9                 if (cmp < 0)
10                     t = t.left;
11                 else if (cmp > 0)
12                     t = t.right;
13                 else
14                     return t.setValue(value);
15             } while (t != null);
16         }
17         else {
18             if (key == null)
19                 throw new NullPointerException();
20             Comparable<? super K> k = (Comparable<? super K>) key;
21             do {
22                 parent = t;
23                 cmp = k.compareTo(t.key);
24                 if (cmp < 0)
25                     t = t.left;
26                 else if (cmp > 0)
27                     t = t.right;
28                 else
29                     return t.setValue(value);
30             } while (t != null);
31         }
32         Entry<K,V> e = new Entry<K,V>(key, value, parent);
33         if (cmp < 0)
34             parent.left = e;
35         else
36             parent.right = e;
37         fixAfterInsertion(e);
38         size++;
39         modCount++;
40         return null;
comparator鏄湪鏋勯燭reeSet瀵硅薄鐨勬椂鍊欎紶榪涘幓鐨勶紝鎵浠ュ鏋?/span>comparator涓簄ull錛屽畠灝變細鎸夌収Comparable鎺掑簭錛屽鏋滃璞℃病鏈夊疄鐜?/span>Comparable鎺ュ彛錛屽氨浼氭姏鍑哄紓甯革紝鎵浠ュ埌鐜板湪涓烘錛屾垜榪樻病鍙戠幇鐩存帴鍦ㄥ璞′腑瀹炵幇comparator鎺ュ彛鍙互鎺掑簭鐨勩傜湅瀹岃繖孌典唬鐮佹垜浠繕鍙互鍙戠幇濡傛灉瀵硅薄娌℃湁瀹炵幇Comparable鎺ュ彛鎴栬呮病鏈夐氳繃鏋勯犱竴涓互comparator涓烘帓搴忕殑闆嗗悎錛屾槸涓嶈兘鍦═reeSet鎴朤reeMap涓嬌鐢ㄧ殑(瀹為檯TreeSet灝辨槸閫氳繃TreeMap瀹炵幇鐨勶紝涓嶄簡瑙g殑鍙互鐪?/span>TreeSet鐨勬簮浠g爜)錛屾渶澶氬彧鑳芥坊鍔犱竴涓璞oot銆?br />
 1 Entry<K,V> t = root;
 2         if (t == null) {
 3         // TBD:
 4         // 5045147: (coll) Adding null to an empty TreeSet should
 5         // throw NullPointerException
 6         //
 7         // compare(key, key); // type check
 8             root = new Entry<K,V>(key, value, null);
 9             size = 1;
10             modCount++;
11             return null;
12         }
    comparator鐨勭敤澶勫湪浜庡彲浠ラ氳繃涓嶅悓鐨?/span>comparator瀹炵幇綾?/span>錛屽湪涓嶉氱殑鏉′歡涓嬪鍦ㄩ泦鍚堜腑鐨勫璞℃寜涓嶅悓鐨勯『搴忚繘琛屾帓搴忥紝榪欐牱鍏呭垎鍒╃敤浜唈ava鐨勫鎬侊紝涔熻鎴戜滑鍦ㄧ紪紼嬬殑榪囩▼涓兘寰堝ソ鐨勮В鑰︺?br />    鍒╃敤Arrays.sort(T[] a, Comparator<? super T> c)鍙互瀵規暟緇勮繘琛屾帓搴忥紝鍒╃敤Collections.sort(List<T> list, Comparator<? super T> c) 鍙互瀵瑰疄鐜頒簡list鎺ュ彛鐨勯泦鍚堣繘琛屾帓搴忥紝濡傛灉闇瑕佸Set榪涜鎺掑簭,鍙互鍏堟妸Set杞崲鎴怉rrayList錛岀劧鍚庡啀榪涜鎺掑簭銆?br />
 1         Set<User> users = new TreeSet<User>(new UserComparator());
 2         User user = new User();
 3         user.setAge(24);
 4         user.setName("wenbo");
 5         users.add(user);
 6         User user1 = new User();
 7         user1.setAge(23);
 8         user1.setName("wenbo1");
 9         users.add(user1);
10         List<User> useList = new ArrayList<User>(users);
11         Collections.sort(useList,new UserMaxComparator());
     閫氳繃涓婇潰鐨勫垎鏋愶紝涓嶇煡閬撳ぇ瀹舵湁娌℃湁鐞嗚В榪?涓帴鍙o紝鎴戣涓哄鏋滈渶瑕佸涓涓璞¤繘琛屾帓搴忥紝寤鴻浣跨敤comparator鎺ュ彛錛屽洜涓哄畠鏇寸伒媧伙紝鎴栬鏁堢巼鏇撮珮銆?br />   













]]>
主站蜘蛛池模板: 亚洲香蕉成人AV网站在线观看| 亚洲爆乳无码一区二区三区| 亚洲精品天堂成人片?V在线播放| 国产午夜亚洲精品国产| 黄色免费网站网址| 午夜亚洲福利在线老司机| 色综合久久精品亚洲国产| 成人午夜性A级毛片免费| 亚洲国产综合人成综合网站| 色妞www精品视频免费看| 免费国产综合视频在线看| 日韩大片免费观看视频播放 | 亚洲精品免费视频| 色拍自拍亚洲综合图区| 亚洲 欧洲 日韩 综合在线| 永久免费AV无码国产网站| 亚洲 日韩 色 图网站| 日本19禁啪啪无遮挡免费动图| 风间由美在线亚洲一区| 亚洲国产精品综合久久一线| a毛片在线还看免费网站| 亚洲AV无码成人精品区天堂 | 999在线视频精品免费播放观看| 在线电影你懂的亚洲| 国产大片免费天天看| 亚洲AV一宅男色影视| 999久久久免费精品国产| 国产成人精品日本亚洲语音| 亚洲综合激情另类专区| 亚洲欧美国产欧美色欲| 免费人成网站7777视频| 十八禁视频在线观看免费无码无遮挡骂过 | 精品亚洲AV无码一区二区 | 久久精品免费一区二区喷潮| 亚洲精品免费观看| 国产在线观看xxxx免费| 免费一级毛片在线观看| 国产成人无码区免费网站| 亚洲免费在线视频播放| 亚洲视频在线精品| 国产大片免费网站不卡美女|