<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Flyingis

    Talking and thinking freely !
    Flying in the world of GIS !
    隨筆 - 156, 文章 - 16, 評論 - 589, 引用 - 0
    數據加載中……

    基本數據結構的Java實現

    鏈表

    class Node {

    Object item; Node next;

      Node (Object v) {

    item = v; next = null;

    }

    }

    頭指針,空尾指針

    初始化:head = null;

    x后插入t

    if ( x == null)

    { head = t; head.next = null; }

    else { t.next = x.next; x.next = t; }

    移走x之后的結點:t = x.next; x.next = t.next;

    循環遍歷:for ( t = head; t != null; t = t.next )

    檢查鏈表是否為空:if ( head == null )

    空頭結點,空尾指針

    初始化:head = new Node(); head.next = null;

    x后插入tt.next = x.next; x.next = t;

    移走x之后的結點:t = x.next; x.next = t.next;

    循環遍歷:for ( t = head.next; t != null; t = t.next )

    檢查鏈表是否為空:if ( head.next == null )

    空頭結點,空尾結點

    初始化:head = new Node(); z = new Node(); head.next = z; z.next = z;

    x后插入tt.next = x.next; x.next = t;

    移走x之后的結點:t = x.next; x.next = t.next;

    循環遍歷:for ( t = head.next; t != z; t = t.next )

    檢查鏈表是否為空:if ( head.next == z )

    循環鏈表

    第一次插入:head.next = head;

    x后插入tt.next = x.next; x.next = t;

    移走x之后的結點:t = x.next; x.next = t.next;

    循環遍歷:t = head; do { t = t.next; } while ( t != head );

    檢查是否只有一個數據項:if ( head.next == head )

     

    堆棧

    數組實現

    class Stack {

      private Object[] s;

      private int n;

      Stack ( int maxN ) {

        s = new Object[maxN]; n = 0;

    }

    boolean isEmpty() { return ( n == 0 ); }

    void push ( Object item ) { s[n++] = item; }

    Object pop() {

      Object t = s[--n]; s[n] = null; return t;

    }

    }

    鏈表實現

    class Stack {

      private Node head;

      private class Node {

    Object item; Node next;

    Node ( Object item, Node next ) {

      this.item = item; this.next = next;

    }

    }

    Stack ( Object maxN ) { head = null; }

    boolean isEmpty() { return ( head ==null ); }

    void push ( Object item ) { head = new Node(item, head); }

    Object pop() {

      Object v = head.item;

      Node t = head.next;

      head = t;

      return v;

    }

    }

     

    FIFO隊列的鏈表實現

    class Queue {

      private class Node {

    Object item; Node next;

    Node ( Object item ) {

      this.item = item; this.next = null;

    }

    }

    Private Node head, tail;

    Queue ( Object max ) { head = null; tail = null; }

    boolean isEmpty() { return ( head ==null ); }

    void put ( Object item ) {

      Node t = tail;

      tail = new Node(item);

      if ( empty() )

        head = tail;

      else t.next = tail

    }

    Object get() {

      Object v = head.item;

      Node t = head.next;

      head = t;

      return v;

    }

    }

    posted on 2006-02-05 23:08 Flyingis 閱讀(1147) 評論(1)  編輯  收藏 所屬分類: Algorithm

    評論

    # re: 基本數據結構的Java實現  回復  更多評論   

    不錯,如果能加入多線程的控制就更好了
    2006-02-06 11:54 | 愛拼才會贏
    主站蜘蛛池模板: 四虎永久免费观看| 日本免费xxxx| 国产亚洲欧洲Aⅴ综合一区| 最好2018中文免费视频| 亚洲一区二区无码偷拍| 大地资源在线观看免费高清| 亚洲国产综合无码一区二区二三区 | 最近中文字幕大全免费视频| 水蜜桃亚洲一二三四在线| 你懂的免费在线观看| 在线成人a毛片免费播放| 亚洲va久久久噜噜噜久久男同| 伊人久久亚洲综合影院| 亚洲自偷自拍另类图片二区| 美女视频免费看一区二区| AV大片在线无码永久免费| 亚洲成aⅴ人片久青草影院| 亚洲无砖砖区免费| 亚洲自国产拍揄拍| 天天看片天天爽_免费播放| 好看的亚洲黄色经典| 美女免费视频一区二区三区| 麻花传媒剧在线mv免费观看 | 一级毛片视频免费| 亚洲中文字幕在线观看| 日韩内射激情视频在线播放免费| 蜜臀98精品国产免费观看| 亚洲成av人片不卡无码| 大学生高清一级毛片免费| 一个人看的www免费在线视频| 精品久久久久久久免费人妻| 久久久久亚洲av无码专区导航| 在线亚洲午夜片AV大片| 国产极品粉嫩泬免费观看| 亚洲色www永久网站| 亚洲色欲久久久久综合网| 91久久精品国产免费直播| 久久精品国产亚洲av麻豆色欲| 成人无码a级毛片免费| 亚洲国产精品不卡毛片a在线| 亚洲av第一网站久章草|