weka.core.Utils.partition()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(94)

本文整理了Java中weka.core.Utils.partition()方法的一些代码示例,展示了Utils.partition()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.partition()方法的具体详情如下:
包路径:weka.core.Utils
类名称:Utils
方法名:partition

Utils.partition介绍

[英]Partitions the instances around a pivot. Used by quicksort and kthSmallestValue.
[中]围绕一个轴划分实例。由快速排序和kthSmallestValue使用。

代码示例

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Implements quicksort according to Manber's "Introduction to Algorithms".
 * 
 * @param array the array of integers to be sorted
 * @param index the index into the array of integers
 * @param left the first index of the subset to be sorted
 * @param right the last index of the subset to be sorted
 */
// @ requires 0 <= first && first <= right && right < array.length;
// @ requires (\forall int i; 0 <= i && i < index.length; 0 <= index[i] &&
// index[i] < array.length);
// @ requires array != index;
// assignable index;
private static void quickSort(/* @non_null@ */int[] array, /* @non_null@ */
 int[] index, int left, int right) {
 if (left < right) {
  int middle = partition(array, index, left, right);
  quickSort(array, index, left, middle);
  quickSort(array, index, middle + 1, right);
 }
}

代码示例来源:origin: Waikato/weka-trunk

/**
 * Implements quicksort according to Manber's "Introduction to Algorithms".
 * 
 * @param array the array of integers to be sorted
 * @param index the index into the array of integers
 * @param left the first index of the subset to be sorted
 * @param right the last index of the subset to be sorted
 */
// @ requires 0 <= first && first <= right && right < array.length;
// @ requires (\forall int i; 0 <= i && i < index.length; 0 <= index[i] &&
// index[i] < array.length);
// @ requires array != index;
// assignable index;
private static void quickSort(/* @non_null@ */int[] array, /* @non_null@ */
 int[] index, int left, int right) {
 if (left < right) {
  int middle = partition(array, index, left, right);
  quickSort(array, index, left, middle);
  quickSort(array, index, middle + 1, right);
 }
}

代码示例来源:origin: Waikato/weka-trunk

/**
 * Implements computation of the kth-smallest element according to Manber's
 * "Introduction to Algorithms".
 * 
 * @param array the array of integers
 * @param index the index into the array of integers
 * @param left the first index of the subset
 * @param right the last index of the subset
 * @param k the value of k
 * 
 * @return the index of the kth-smallest element
 */
// @ requires 0 <= first && first <= right && right < array.length;
private static int select(/* @non_null@ */int[] array, /* @non_null@ */
 int[] index, int left, int right, int k) {
 if (left == right) {
  return left;
 } else {
  int middle = partition(array, index, left, right);
  if ((middle - left + 1) >= k) {
   return select(array, index, left, middle, k);
  } else {
   return select(array, index, middle + 1, right, k - (middle - left + 1));
  }
 }
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Implements computation of the kth-smallest element according to Manber's
 * "Introduction to Algorithms".
 * 
 * @param array the array of integers
 * @param index the index into the array of integers
 * @param left the first index of the subset
 * @param right the last index of the subset
 * @param k the value of k
 * 
 * @return the index of the kth-smallest element
 */
// @ requires 0 <= first && first <= right && right < array.length;
private static int select(/* @non_null@ */int[] array, /* @non_null@ */
 int[] index, int left, int right, int k) {
 if (left == right) {
  return left;
 } else {
  int middle = partition(array, index, left, right);
  if ((middle - left + 1) >= k) {
   return select(array, index, left, middle, k);
  } else {
   return select(array, index, middle + 1, right, k - (middle - left + 1));
  }
 }
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

partition(array, index, left, right, array[index[right - 1]]);
swap(index, center, right - 1);

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

partition(array, index, left, right, array[index[right - 1]]);
swap(index, center, right - 1);

代码示例来源:origin: Waikato/weka-trunk

partition(array, index, left, right, array[index[right - 1]]);
swap(index, center, right - 1);

代码示例来源:origin: Waikato/weka-trunk

partition(array, index, left, right, array[index[right - 1]]);
swap(index, center, right - 1);

相关文章

微信公众号

最新文章

更多