欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

java算法實現(xiàn)紅黑樹完整代碼示例

 更新時間:2017年11月09日 16:48:18   投稿:mengwei  
這篇文章主要介紹了java算法實現(xiàn)紅黑樹完整代碼示例,具有一定參考價值,需要的朋友可以了解下。

紅黑樹

定義

紅黑樹(英語:Red–black tree)是一種自平衡二叉查找樹,是在計算機(jī)科學(xué)中用到的一種數(shù)據(jù)結(jié)構(gòu),典型的用途是實現(xiàn)關(guān)聯(lián)數(shù)組。

紅黑樹的另一種定義是含有紅黑鏈接并滿足下列條件的二叉查找樹:

紅鏈接均為左鏈接;沒有任何一個結(jié)點(diǎn)同時和兩條紅鏈接相連;該樹是完美黑色平衡的,即任意空鏈接到根結(jié)點(diǎn)的路徑上的黑鏈接數(shù)量相同。

滿足這樣定義的紅黑樹和相應(yīng)的2-3樹是一一對應(yīng)的。

旋轉(zhuǎn)

旋轉(zhuǎn)又分為左旋和右旋。通常左旋操作用于將一個向右傾斜的紅色鏈接旋轉(zhuǎn)為向左鏈接。對比操作前后,可以看出,該操作實際上是將紅線鏈接的兩個節(jié)點(diǎn)中的一個較大的節(jié)點(diǎn)移動到根節(jié)點(diǎn)上。

左旋操作如下圖:

右旋旋操作如下圖:

即:

復(fù)雜度

紅黑樹的平均高度大約為lgN。

下圖是紅黑樹在各種情況下的時間復(fù)雜度,可以看出紅黑樹是2-3查找樹的一種實現(xiàn),他能保證最壞情況下仍然具有對數(shù)的時間復(fù)雜度。

Java代碼

import java.util.NoSuchElementException;
import java.util.Scanner;
public class RedBlackBST<key extends="" key="">, Value> {
  private static final boolean RED = true;
  private static final boolean BLACK = false;
  private Node root; //root of the BST
  private class Node {
    private Key key;      //key
    private Value val;     //associated data
    private Node left, right;  //links to left and right subtrees
    private boolean color;   //color of parent link
    private int size;      //subtree count
    public Node(Key key, Value val, boolean color, int size) {
      this.key = key;
      this.val = val;
      this.color = color;
      this.size = size;
    }
  }
  //is node x red?
  private boolean isRed(Node x) {
    if(x == null) {
      return false;
    }
    return x.color == RED;
  }
  //number of node in subtree rooted at x; 0 if x is null
  private int size(Node x) {
    if(x == null) {
      return 0;
    }
    return x.size;
  }  
  /**
   * return the number of key-value pairs in this symbol table
   * @return the number of key-value pairs in this symbol table
   */
  public int size() {
    return size(root);
  }
  /**
   * is this symbol table empty?
   * @return true if this symbol table is empty and false otherwise
   */
  public boolean isEmpty() {
    return root == null;
  }
  /**
   * return the value associated with the given key
   * @param key the key
   * @return the value associated with the given key if the key is in the symbol table, and null if it is not.
   */
  public Value get(Key key) {
    if(key == null) {
      throw new NullPointerException("argument to get() is null");
    }
    return get(root, key);
  }
  //value associated with the given key in subtree rooted at x; null if no such key
  private Value get(Node x, Key key) {
    while(x != null) {
      int cmp = key.compareTo(x.key);
      if(cmp < 0) {
        x = x.left;
      }
      else if(cmp > 0) {
        x = x.right;
      }
      else {
        return x.val;
      }        
    }
    return null;
  }
  /**
   * does this symbol table contain the given key?
   * @param key the key
   * @return true if this symbol table contains key and false otherwise
   */
  public boolean contains(Key key) {
    return get(key) != null;
  }
  /***************************************************************************
  * Red-black tree insertion.
  ***************************************************************************/
  /**
   * Inserts the specified key-value pair into the symbol table, overwriting the old 
   * value with the new value if the symbol table already contains the specified key.
   * Deletes the specified key (and its associated value) from this symbol table
   * if the specified value is null.
   *
   * @param key the key
   * @param val the value
   * @throws NullPointerException if key is null
   */
  public void put(Key key, Value val) {
    if (key == null) {
      throw new NullPointerException("first argument to put() is null");
    }
    if (val == null) {
      delete(key);
      return;
    }
    root = put(root, key, val);
    root.color = BLACK;    
  }
  // insert the key-value pair in the subtree rooted at h
  private Node put(Node h, Key key, Value val) {
    if(h == null) {
      return new Node(key, val, RED, 1);
    }
    int cmp = key.compareTo(h.key);
    if(cmp < 0) {
      h.left = put(h.left, key, val);
    }
    else if(cmp > 0) {
      h.right = put(h.right, key, val);
    }
    else {
      h.val = val;
    }
    if(isRed(h.right) && !isRed(h.left)) {
      h = rotateLeft(h);
    }
    if(isRed(h.left) && isRed(h.left.left)) {
      h = rotateRight(h);
    }
    if(isRed(h.left) && isRed(h.right)) {
      flipColors(h);
    }
    h.size = size(h.left) + size(h.right) + 1;
    return h;
  }
  /***************************************************************************
  * Red-black tree deletion.
  ***************************************************************************/
 
  /**
   * Removes the smallest key and associated value from the symbol table.
   * @throws NoSuchElementException if the symbol table is empty
   */
  public void deleteMin() {
    if (isEmpty()) {
      throw new NoSuchElementException("BST underflow");
    }
    // if both children of root are black, set root to red
    if (!isRed(root.left) && !isRed(root.right))
      root.color = RED;
    root = deleteMin(root);
    if (!isEmpty()) root.color = BLACK;
    // assert check();
  }
  // delete the key-value pair with the minimum key rooted at h
  // delete the key-value pair with the minimum key rooted at h
  private Node deleteMin(Node h) { 
    if (h.left == null){
      return null;
    }
    if (!isRed(h.left) && !isRed(h.left.left)) {
      h = moveRedLeft(h);
    }
    h.left = deleteMin(h.left);
    return balance(h);
  }
  /**
   * Removes the largest key and associated value from the symbol table.
   * @throws NoSuchElementException if the symbol table is empty
   */
  public void deleteMax() {
    if (isEmpty()) {
      throw new NoSuchElementException("BST underflow");
    }
    // if both children of root are black, set root to red
    if (!isRed(root.left) && !isRed(root.right))
      root.color = RED;
    root = deleteMax(root);
    if (!isEmpty()) root.color = BLACK;
    // assert check();
  }
  // delete the key-value pair with the maximum key rooted at h
  // delete the key-value pair with the maximum key rooted at h
  private Node deleteMax(Node h) { 
      if (isRed(h.left))
        h = rotateRight(h);
      if (h.right == null)
        return null;
      if (!isRed(h.right) && !isRed(h.right.left))
        h = moveRedRight(h);
      h.right = deleteMax(h.right);
      return balance(h);
    }
  /**
   * remove the specified key and its associated value from this symbol table   
   * (if the key is in this symbol table).  
   *
   * @param key the key
   * @throws NullPointerException if key is null
   */
  public void delete(Key key) {
    if (key == null) {
      throw new NullPointerException("argument to delete() is null");
    }
    if (!contains(key)) {
      return;
    }
    //if both children of root are black, set root to red
    if(!isRed(root.left) && !isRed(root.right)) {
      root.color = RED;
    }
    root = delete(root, key);
    if(!isEmpty()) {
      root.color = BLACK;
    }
  }
  // delete the key-value pair with the given key rooted at h
  // delete the key-value pair with the given key rooted at h
  private Node delete(Node h, Key key) {
    if(key.compareTo(h.key) < 0) {
      if(!isRed(h.left) && !isRed(h.left.left)) {
        h = moveRedLeft(h);
      }
      h.left = delete(h.left, key);
    }
    else {
      if(isRed(h.left)) {
        h = rotateRight(h);
      }
      if (key.compareTo(h.key) == 0 && (h.right == null)) {
        return null;
      }
      if (!isRed(h.right) && !isRed(h.right.left)) {
        h = moveRedRight(h);
      }
      if (key.compareTo(h.key) == 0) {
        Node x = min(h.right);
        h.key = x.key;
        h.val = x.val;
        h.right = deleteMin(h.right);
      }
      else {
        h.right = delete(h.right, key);
      }
    }
    return balance(h);
  }
  /***************************************************************************
  * Red-black tree helper functions.
  ***************************************************************************/
  // make a left-leaning link lean to the right
  // make a left-leaning link lean to the right
  private Node rotateRight(Node h) {
    // assert (h != null) && isRed(h.left);
    Node x = h.left;
    h.left = x.right;
    x.right = h;
    x.color = x.right.color;
    x.right.color = RED;
    x.size = h.size;
    h.size = size(h.left) + size(h.right) + 1;
    return x;
  }
  // make a right-leaning link lean to the left
  // make a right-leaning link lean to the left
  private Node rotateLeft(Node h) {
    // assert (h != null) && isRed(h.right);
    Node x = h.right;
    h.right = x.left;
    x.left = h;
    x.color = x.left.color;
    x.left.color = RED;
    x.size = h.size;
    h.size = size(h.left) + size(h.right) + 1;
    return x;
  }
  // flip the colors of a node and its two children
  // flip the colors of a node and its two children
  private void flipColors(Node h) {
    // h must have opposite color of its two children
    // assert (h != null) && (h.left != null) && (h.right != null);
    // assert (!isRed(h) && isRed(h.left) && isRed(h.right))
    //  || (isRed(h) && !isRed(h.left) && !isRed(h.right));
    h.color = !h.color;
    h.left.color = !h.left.color;
    h.right.color = !h.right.color;
  }
  // Assuming that h is red and both h.left and h.left.left
  // are black, make h.left or one of its children red.
  // Assuming that h is red and both h.left and h.left.left
  // are black, make h.left or one of its children red.
  private Node moveRedLeft(Node h) {
    // assert (h != null);
    // assert isRed(h) && !isRed(h.left) && !isRed(h.left.left);
    flipColors(h);
    if (isRed(h.right.left)) { 
      h.right = rotateRight(h.right);
      h = rotateLeft(h);
      flipColors(h);
    }
    return h;
  }
  // Assuming that h is red and both h.right and h.right.left
  // are black, make h.right or one of its children red.
  // Assuming that h is red and both h.right and h.right.left
  // are black, make h.right or one of its children red.
  private Node moveRedRight(Node h) {
    // assert (h != null);
    // assert isRed(h) && !isRed(h.right) && !isRed(h.right.left);
    flipColors(h);
    if (isRed(h.left.left)) { 
      h = rotateRight(h);
      flipColors(h);
    }
    return h;
  }
  // restore red-black tree invariant
  // restore red-black tree invariant
  private Node balance(Node h) {
    // assert (h != null);
    if (isRed(h.right)) {
      h = rotateLeft(h);
    }
    if (isRed(h.left) && isRed(h.left.left)) {
      h = rotateRight(h);
    }
    if (isRed(h.left) && isRed(h.right)) {
      flipColors(h);
    }
    h.size = size(h.left) + size(h.right) + 1;
    return h;
  }
  /***************************************************************************
   * Utility functions.
   ***************************************************************************/
   /**
   * Returns the height of the BST (for debugging).
   * @return the height of the BST (a 1-node tree has height 0)
   */
   public int height() {
     return height(root);
   }
   private int height(Node x) {
     if (x == null) {
       return -1;
     }
     return 1 + Math.max(height(x.left), height(x.right));
   }
  /***************************************************************************
   * Ordered symbol table methods.
   ***************************************************************************/
   /**
   * Returns the smallest key in the symbol table.
   * @return the smallest key in the symbol table
   * @throws NoSuchElementException if the symbol table is empty
   */
   public Key min() {
     if (isEmpty()) {
       throw new NoSuchElementException("called min() with empty symbol table");
     }
     return min(root).key;
   } 
   // the smallest key in subtree rooted at x; null if no such key
   private Node min(Node x) { 
     // assert x != null;
     if (x.left == null) {
       return x; 
     }
     else {
       return min(x.left); 
     }
   } 
   /**
   * Returns the largest key in the symbol table.
   * @return the largest key in the symbol table
   * @throws NoSuchElementException if the symbol table is empty
   */
   public Key max() {
     if (isEmpty()) {
       throw new NoSuchElementException("called max() with empty symbol table");
     }
     return max(root).key;
   } 
   // the largest key in the subtree rooted at x; null if no such key
   private Node max(Node x) { 
     // assert x != null;
     if (x.right == null) {
       return x; 
     }
     else {
       return max(x.right);     
     }
   } 
   /**
   * Returns the largest key in the symbol table less than or equal to key.
   * @param key the key
   * @return the largest key in the symbol table less than or equal to key
   * @throws NoSuchElementException if there is no such key
   * @throws NullPointerException if key is null
   */
   public Key floor(Key key) {
     if (key == null) {
       throw new NullPointerException("argument to floor() is null");
     }
     if (isEmpty()) {
       throw new NoSuchElementException("called floor() with empty symbol table");
     }
     Node x = floor(root, key);
     if (x == null) {
       return null;     
     }
     else {
       return x.key;
     }
   }  
   // the largest key in the subtree rooted at x less than or equal to the given key
   private Node floor(Node x, Key key) {
     if (x == null) {
       return null;
     }
     int cmp = key.compareTo(x.key);
     if (cmp == 0) {
       return x;
     }
     if (cmp < 0) {
       return floor(x.left, key);     
     }
     Node t = floor(x.right, key);
     if (t != null) {
       return t;     
     }
     else {
       return x;
     }
   }
   /**
   * Returns the smallest key in the symbol table greater than or equal to key.
   * @param key the key
   * @return the smallest key in the symbol table greater than or equal to key
   * @throws NoSuchElementException if there is no such key
   * @throws NullPointerException if key is null
   */
   public Key ceiling(Key key) {
     if (key == null) {
       throw new NullPointerException("argument to ceiling() is null");
     }
     if (isEmpty()) {
       throw new NoSuchElementException("called ceiling() with empty symbol table");
     }
     Node x = ceiling(root, key);
     if (x == null) {
       return null;
     }
     else {
       return x.key; 
     }
   }
   // the smallest key in the subtree rooted at x greater than or equal to the given key
   private Node ceiling(Node x, Key key) { 
     if (x == null) {
       return null;
     }     
     int cmp = key.compareTo(x.key);
     if (cmp == 0) {
       return x;
     }
     if (cmp > 0) {
       return ceiling(x.right, key);
     }
     Node t = ceiling(x.left, key);
     if (t != null) {
       return t; 
     }
     else {
       return x;
     }
   }
   /**
   * Return the kth smallest key in the symbol table.
   * @param k the order statistic
   * @return the kth smallest key in the symbol table
   * @throws IllegalArgumentException unless k is between 0 and
   *   <em>N</em> − 1
   */
   public Key select(int k) {
     if (k < 0 || k >= size()) {
       throw new IllegalArgumentException();
     }
     Node x = select(root, k);
     return x.key;
   }
   // the key of rank k in the subtree rooted at x
   private Node select(Node x, int k) {
     // assert x != null;
     // assert k >= 0 && k < size(x);
     int t = size(x.left); 
     if   (t > k) {
       return select(x.left, k); 
     }
     else if (t < k) {
       return select(x.right, k-t-1); 
     }
     else {
       return x; 
     }
   } 
   /**
   * Return the number of keys in the symbol table strictly less than key.
   * @param key the key
   * @return the number of keys in the symbol table strictly less than key
   * @throws NullPointerException if key is null
   */
   public int rank(Key key) {
     if (key == null) {
       throw new NullPointerException("argument to rank() is null");
     }
     return rank(key, root);
   } 
   // number of keys less than key in the subtree rooted at x
   private int rank(Key key, Node x) {
     if (x == null) {
       return 0; 
     }
     int cmp = key.compareTo(x.key); 
     if   (cmp < 0) {
       return rank(key, x.left); 
     }
     else if (cmp > 0) {
       return 1 + size(x.left) + rank(key, x.right); 
     }
     else {
       return size(x.left); 
     }
   } 
  /***************************************************************************
   * Range count and range search.
   ***************************************************************************/
   /**
   * Returns all keys in the symbol table as an Iterable.
   * To iterate over all of the keys in the symbol table named st,
   * use the foreach notation: for (Key key : st.keys()).
   * @return all keys in the symbol table as an Iterable
   */
   public Iterable<key> keys() {
     if (isEmpty()) {
       return new Queue<key>();
     }
     return keys(min(), max());
   }
   /**
   * Returns all keys in the symbol table in the given range,
   * as an Iterable.
   * @return all keys in the symbol table between lo 
   *  (inclusive) and hi (exclusive) as an Iterable
   * @throws NullPointerException if either lo or hi
   *  is null
   */
   public Iterable<key> keys(Key lo, Key hi) {
     if (lo == null) {
       throw new NullPointerException("first argument to keys() is null");
     }
     if (hi == null) {
       throw new NullPointerException("second argument to keys() is null");
     }
     Queue<key> queue = new Queue<key>();
     // if (isEmpty() || lo.compareTo(hi) > 0) return queue;
     keys(root, queue, lo, hi);
     return queue;
   } 
   // add the keys between lo and hi in the subtree rooted at x
   // to the queue
   private void keys(Node x, Queue<key> queue, Key lo, Key hi) { 
     if (x == null) {
       return; 
     }
     int cmplo = lo.compareTo(x.key); 
     int cmphi = hi.compareTo(x.key); 
     if (cmplo < 0) {
       keys(x.left, queue, lo, hi); 
     }
     if (cmplo <= 0 && cmphi >= 0) {
       queue.enqueue(x.key); 
     }
     if (cmphi > 0) {
       keys(x.right, queue, lo, hi); 
     }
   } 
   /**
   * Returns the number of keys in the symbol table in the given range.
   * @return the number of keys in the symbol table between lo 
   *  (inclusive) and hi (exclusive)
   * @throws NullPointerException if either lo or hi
   *  is null
   */
   public int size(Key lo, Key hi) {
     if (lo == null) {
       throw new NullPointerException("first argument to size() is null");
     }
     if (hi == null) {
       throw new NullPointerException("second argument to size() is null");
     }
     if (lo.compareTo(hi) > 0) {
       return 0;
     }
     if (contains(hi)) {
       return rank(hi) - rank(lo) + 1;
     }
     else {
       return rank(hi) - rank(lo);     
     }
   }
  /***************************************************************************
   * Check integrity of red-black tree data structure.
   ***************************************************************************/
   private boolean check() {
     if (!isBST())      System.out.println("Not in symmetric order");
     if (!isSizeConsistent()) System.out.println("Subtree counts not consistent");
     if (!isRankConsistent()) System.out.println("Ranks not consistent");
     if (!is23())       System.out.println("Not a 2-3 tree");
     if (!isBalanced())    System.out.println("Not balanced");
     return isBST() && isSizeConsistent() && isRankConsistent() && is23() && isBalanced();
   }
   // does this binary tree satisfy symmetric order?
   // Note: this test also ensures that data structure is a binary tree since order is strict
   private boolean isBST() {
     return isBST(root, null, null);
   }
   // is the tree rooted at x a BST with all keys strictly between min and max
   // (if min or max is null, treat as empty constraint)
   // Credit: Bob Dondero's elegant solution
   private boolean isBST(Node x, Key min, Key max) {
     if (x == null) {
       return true;
     }
     if (min != null && x.key.compareTo(min) <= 0) {
       return false;     
     }
     if (max != null && x.key.compareTo(max) >= 0) {
       return false;
     }
     return isBST(x.left, min, x.key) && isBST(x.right, x.key, max);
   } 
   // are the size fields correct?
   private boolean isSizeConsistent() { 
     return isSizeConsistent(root); 
   }
   private boolean isSizeConsistent(Node x) {
     if (x == null) {
       return true;
     }
     if (x.size != size(x.left) + size(x.right) + 1) {
       return false;
     }
     return isSizeConsistent(x.left) && isSizeConsistent(x.right);
   } 
   // check that ranks are consistent
   private boolean isRankConsistent() {
     for (int i = 0; i < size(); i++) {
       if (i != rank(select(i))) {
         return false;
       }
     }
     for (Key key : keys()) {
       if (key.compareTo(select(rank(key))) != 0) {
         return false;
       }
     }
     return true;
   }
   // Does the tree have no red right links, and at most one (left)
   // red links in a row on any path?
   private boolean is23() { 
     return is23(root); 
   }
   private boolean is23(Node x) {
     if (x == null) {
       return true;
     }
     if (isRed(x.right)) {
       return false;
     }
     if (x != root && isRed(x) && isRed(x.left)){
       return false;
     }
     return is23(x.left) && is23(x.right);
   } 
   // do all paths from root to leaf have same number of black edges?
   private boolean isBalanced() { 
     int black = 0;   // number of black links on path from root to min
     Node x = root;
     while (x != null) {
       if (!isRed(x)) black++;
       x = x.left;
     }
     return isBalanced(root, black);
   }
   // does every path from the root to a leaf have the given number of black links?
   private boolean isBalanced(Node x, int black) {
     if (x == null) {
       return black == 0;     
     }
     if (!isRed(x)) {
       black--;
     }
     return isBalanced(x.left, black) && isBalanced(x.right, black);
   } 
   /**
   * Unit tests the RedBlackBST data type.
   */
   public static void main(String[] args) { 
     RedBlackBST<string, integer=""> st = new RedBlackBST<string, integer="">();
     String data = "a b c d e f g h m n o p";
     Scanner sc = new Scanner(data);
     int i = 0;
     while (sc.hasNext()) {     
      String key = sc.next();
      st.put(key, i);
      i++;
     }
     sc.close();   
     for (String s : st.keys())
       System.out.println(s + " " + st.get(s));
     System.out.println();
     boolean result = st.check();
     System.out.println("check: " + result);
   }
 }

輸出:

<code>a 0
b 1
c 2
d 3
e 4
f 5
g 6
h 7
m 8
n 9
o 10
p 11
 
check: true</code>

總結(jié)

以上就是本文關(guān)于java算法實現(xiàn)紅黑樹完整代碼示例的全部內(nèi)容,希望對大家有所幫助。感興趣的朋友可以繼續(xù)參閱本站:java集合中l(wèi)ist的用法代碼示例Java微信支付之服務(wù)號支付代碼示例、快速理解Java設(shè)計模式中的組合模式等,有什么問題可以隨時留言,小編會及時回復(fù)大家的。感謝朋友們對本站的支持!

相關(guān)文章

  • Spring聲明式事務(wù)@Transactional知識點(diǎn)分享

    Spring聲明式事務(wù)@Transactional知識點(diǎn)分享

    在本篇文章里小編給大家整理了關(guān)于Spring聲明式事務(wù)@Transactional詳解內(nèi)容,需要的朋友們可以參考下。
    2020-02-02
  • idea web項目沒有小藍(lán)點(diǎn)的的兩種解決方法

    idea web項目沒有小藍(lán)點(diǎn)的的兩種解決方法

    本文主要介紹了idea web項目沒有小藍(lán)點(diǎn)的的兩種解決方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-07-07
  • java HttpClient傳輸json格式的參數(shù)實例講解

    java HttpClient傳輸json格式的參數(shù)實例講解

    這篇文章主要介紹了java HttpClient傳輸json格式的參數(shù)實例講解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2021-01-01
  • java發(fā)送http get請求的兩種方式

    java發(fā)送http get請求的兩種方式

    這篇文章主要為大家詳細(xì)介紹了java發(fā)送http get請求的兩種方式,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • Java中instanceof 關(guān)鍵字的使用

    Java中instanceof 關(guān)鍵字的使用

    instanceof通過返回一個布爾值來指出,某個對象是否是某個特定類或者是該特定類的子類的一個實例,本文就來詳細(xì)的介紹一下instanceof 關(guān)鍵字的使用,感興趣的可以了解一下
    2023-10-10
  • Java中Map的排序問題詳解

    Java中Map的排序問題詳解

    本文給大家分享的是java中的map的按值排序和按鍵排序問題,并通過具體的示例,希望對大家能有所幫助。
    2016-01-01
  • 了解java中的session

    了解java中的session

    這篇文章主要介紹了了解java中的session的相關(guān)問題,什么是session,session怎么用等,具有一定參考價值,需要的朋友可以了解下。
    2017-11-11
  • Spring中的@RestControllerAdvice注解使用方法解析

    Spring中的@RestControllerAdvice注解使用方法解析

    這篇文章主要介紹了Spring中的@RestControllerAdvice注解使用方法解析,@RestControllerAdvice是Controller的增強(qiáng) 常用于全局異常的捕獲處理 和請求參數(shù)的增強(qiáng),需要的朋友可以參考下
    2024-01-01
  • 使用Java完成Socket文件傳輸方式

    使用Java完成Socket文件傳輸方式

    這篇文章主要介紹了使用Java完成Socket文件傳輸方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-09-09
  • SpringBoot數(shù)據(jù)層測試事務(wù)回滾的實現(xiàn)流程

    SpringBoot數(shù)據(jù)層測試事務(wù)回滾的實現(xiàn)流程

    這篇文章主要介紹了SpringBoot數(shù)據(jù)層測試事務(wù)回滾的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧
    2022-10-10

最新評論