类 SortUtils
- java.lang.Object
-
- org.meteoinfo.math.sort.SortUtils
-
public class SortUtils extends java.lang.ObjectSome useful functions such as swap and swif-down used in many sorting algorithms.- 作者:
- Haifeng Li
-
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static voidsiftDown(double[] arr, int k, int n)To restore the max-heap condition when a node's priority is decreased.static voidsiftDown(float[] arr, int k, int n)To restore the max-heap condition when a node's priority is decreased.static voidsiftDown(int[] arr, int k, int n)To restore the max-heap condition when a node's priority is decreased.static <T extends java.lang.Comparable<? super T>>
voidsiftDown(T[] arr, int k, int n)To restore the max-heap condition when a node's priority is decreased.static voidsiftUp(double[] arr, int k)To restore the max-heap condition when a node's priority is increased.static voidsiftUp(float[] arr, int k)To restore the max-heap condition when a node's priority is increased.static voidsiftUp(int[] arr, int k)To restore the max-heap condition when a node's priority is increased.static <T extends java.lang.Comparable<? super T>>
voidsiftUp(T[] arr, int k)To restore the max-heap condition when a node's priority is increased.static voidswap(double[] arr, int i, int j)Swap two positions.static voidswap(float[] arr, int i, int j)Swap two positions.static voidswap(int[] arr, int i, int j)Swap two positions.static voidswap(java.lang.Object[] arr, int i, int j)Swap two positions.
-
-
-
方法详细资料
-
swap
public static void swap(int[] arr, int i, int j)Swap two positions.
-
swap
public static void swap(float[] arr, int i, int j)Swap two positions.
-
swap
public static void swap(double[] arr, int i, int j)Swap two positions.
-
swap
public static void swap(java.lang.Object[] arr, int i, int j)Swap two positions.
-
siftUp
public static void siftUp(int[] arr, int k)To restore the max-heap condition when a node's priority is increased. We move up the heap, exchaning the node at position k with its parent (at postion k/2) if necessary, continuing as long as a[k/2] < a[k] or until we reach the top of the heap.
-
siftUp
public static void siftUp(float[] arr, int k)To restore the max-heap condition when a node's priority is increased. We move up the heap, exchaning the node at position k with its parent (at postion k/2) if necessary, continuing as long as a[k/2] < a[k] or until we reach the top of the heap.
-
siftUp
public static void siftUp(double[] arr, int k)To restore the max-heap condition when a node's priority is increased. We move up the heap, exchaning the node at position k with its parent (at postion k/2) if necessary, continuing as long as a[k/2] < a[k] or until we reach the top of the heap.
-
siftUp
public static <T extends java.lang.Comparable<? super T>> void siftUp(T[] arr, int k)To restore the max-heap condition when a node's priority is increased. We move up the heap, exchaning the node at position k with its parent (at postion k/2) if necessary, continuing as long as a[k/2] < a[k] or until we reach the top of the heap.
-
siftDown
public static void siftDown(int[] arr, int k, int n)To restore the max-heap condition when a node's priority is decreased. We move down the heap, exchanging the node at position k with the larger of that node's two children if necessary and stopping when the node at k is not smaller than either child or the bottom is reached. Note that if n is even and k is n/2, then the node at k has only one child -- this case must be treated properly.
-
siftDown
public static void siftDown(float[] arr, int k, int n)To restore the max-heap condition when a node's priority is decreased. We move down the heap, exchanging the node at position k with the larger of that node's two children if necessary and stopping when the node at k is not smaller than either child or the bottom is reached. Note that if n is even and k is n/2, then the node at k has only one child -- this case must be treated properly.
-
siftDown
public static void siftDown(double[] arr, int k, int n)To restore the max-heap condition when a node's priority is decreased. We move down the heap, exchanging the node at position k with the larger of that node's two children if necessary and stopping when the node at k is not smaller than either child or the bottom is reached. Note that if n is even and k is n/2, then the node at k has only one child -- this case must be treated properly.
-
siftDown
public static <T extends java.lang.Comparable<? super T>> void siftDown(T[] arr, int k, int n)To restore the max-heap condition when a node's priority is decreased. We move down the heap, exchanging the node at position k with the larger of that node's two children if necessary and stopping when the node at k is not smaller than either child or the bottom is reached. Note that if n is even and k is n/2, then the node at k has only one child -- this case must be treated properly.
-
-