<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 閱讀(1140) 評論(1)  編輯  收藏 所屬分類: Algorithm

    評論

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

    不錯,如果能加入多線程的控制就更好了
    2006-02-06 11:54 | 愛拼才會贏
    主站蜘蛛池模板: 黄网站色视频免费看无下截| 又黄又爽一线毛片免费观看| 一道本在线免费视频| 亚洲 欧洲 日韩 综合在线| 亚洲国产精品线在线观看| 亚洲伊人成无码综合网 | 国产高清免费在线| 91精品国产免费久久久久久青草| 中文字幕视频在线免费观看| 男女男精品网站免费观看 | 日韩中文字幕免费| 免费成人福利视频| 无码专区AAAAAA免费视频| 国产精品成人69XXX免费视频| 直接进入免费看黄的网站| 亚洲欧美日韩自偷自拍| 一本色道久久综合亚洲精品蜜桃冫| 久久亚洲精品成人AV| 亚洲AV乱码久久精品蜜桃| 国产成人A人亚洲精品无码| 亚洲一区二区三区香蕉| 久久久精品国产亚洲成人满18免费网站 | A在线观看免费网站大全| 4399影视免费观看高清直播| 日本在线免费观看| 久久黄色免费网站| 久久免费线看线看| 久久久久国产免费| 性无码免费一区二区三区在线 | 亚洲欧洲在线观看| 亚洲图片一区二区| 亚洲熟妇av一区| 亚洲国语在线视频手机在线| 亚洲六月丁香六月婷婷色伊人| 亚洲国产精品网站久久| 亚洲丰满熟女一区二区v| 久久精品国产亚洲av麻豆图片| 美女视频黄免费亚洲| 性色av极品无码专区亚洲 | 午夜亚洲av永久无码精品| 亚洲成av人在片观看|