当前位置: 编程技术>移动开发
本页文章导读:
▪快速排序的高效实现方法 快速排序的高效率实现方法
/**
*
*/
package com.me.shuai;
/**
* @author Administrator
*
*/
public class testing {
/**
*
*/
public testing() {
// TODO Auto-generated constructor stub
}
/**
* @param args
*/
public sta.........
▪ scrollview+listview的高度自动顺应 scrollview+listview的高度自动适应
很多时间我们在scorllview中嵌入listview的时候,都只能看到listview显示一行数据,而我们的要求是显示多行,即我们数据的行数,那么请看下面的代码: .........
▪ 小弟我架设的软件工程师问答网站 我架设的程序员问答网站
我架设了一个程序员问答网站,欢迎来http://programmerask.sinaapp.com提问。
......
[1]快速排序的高效实现方法
来源: 互联网 发布时间: 2014-02-18
快速排序的高效率实现方法
/**
*
*/
package com.me.shuai;
/**
* @author Administrator
*
*/
public class testing {
/**
*
*/
public testing() {
// TODO Auto-generated constructor stub
}
/**
* @param args
*/
public static void main(String[] args) {
int[] testingValue = { 10, 2,2,13, 3, 4, 5, 8, 6, 7, 23,10, 20, 15, 50, 51 };
quickSort(testingValue, 0, testingValue.length - 1);
}
static void printCurrentStatus(int[] arr) {
System.out.println("begin");
for (int i : arr) {
System.out.print(i + " ");
}
System.out.println("the end");
}
static void quickSort(int[] arr, int low, int high) {
if (low > high)
return;
int result = 0;
result = Partition2(arr, low, high);
printCurrentStatus(arr);
quickSort(arr, low, result - 1);
quickSort(arr, result + 1, high);
}
static int Partition2(int[] arr, int low, int high) {
int piviot = arr[low];
while(low < high){
while(low < high && arr[high] >= piviot){ high--;}
{
int temp = arr[low];
arr[low] = arr[high];
arr[high] = temp;
}
while(low < high && arr[low] <= piviot){ low++;}
{
int temp = arr[low];
arr[low] = arr[high];
arr[high] = temp;
}
}
return low;
}
static int Partition3(int[] arr, int low, int high) {
int piviot = arr[low];
while(low < high){
while(low < high && arr[high] >= piviot){ high--;}
{
arr[low] = arr[high];
}
while(low < high && arr[low] <= piviot){ low++;}
{
arr[low] = arr[high];
}
}
arr[low] = piviot;
return low;
}
static int Partition(int[] arr, int low, int high) {
int sartPiviotIndex = low;
int piviot = arr[sartPiviotIndex];
while (true) {
for (; low <= high; --high) {
if (arr[high] <= piviot) {
break;
}
}
if (low > high) {
arr[sartPiviotIndex] = arr[low - 1];
arr[low - 1] = piviot;
return low - 1;
}
for (; low <= high; ++low) {
if (arr[low] > piviot) {
break;
}
}
if (low > high) {
arr[sartPiviotIndex] = arr[low - 1];
arr[low - 1] = piviot;
return low - 1;
}
int temp = arr[low];
arr[low] = arr[high];
arr[high] = temp;
if (low == high - 1) {
arr[sartPiviotIndex] = arr[low];
arr[low] = piviot;
return low;
}
low++;
high--;
}
}
}
[2] scrollview+listview的高度自动顺应
来源: 互联网 发布时间: 2014-02-18
scrollview+listview的高度自动适应
很多时间我们在scorllview中嵌入listview的时候,都只能看到listview显示一行数据,而我们的要求是显示多行,即我们数据的行数,那么请看下面的代码:
int totalHeight = 0;//总的高度
for (int i = 0; i < initData(0).size(); i++) { //initData(0).size()数据的行数
View listItem = myAdapter.getView(i, null, list1); //list1,当前listview
listItem.measure(0, 0);
totalHeight += listItem.getMeasuredHeight();
}
ViewGroup.LayoutParams params = list1.getLayoutParams();
params.height = totalHeight
+ (list1.getDividerHeight() * (myAdapter.getCount() - 1));
list1.setLayoutParams(params);
很多时间我们在scorllview中嵌入listview的时候,都只能看到listview显示一行数据,而我们的要求是显示多行,即我们数据的行数,那么请看下面的代码:
int totalHeight = 0;//总的高度
for (int i = 0; i < initData(0).size(); i++) { //initData(0).size()数据的行数
View listItem = myAdapter.getView(i, null, list1); //list1,当前listview
listItem.measure(0, 0);
totalHeight += listItem.getMeasuredHeight();
}
ViewGroup.LayoutParams params = list1.getLayoutParams();
params.height = totalHeight
+ (list1.getDividerHeight() * (myAdapter.getCount() - 1));
list1.setLayoutParams(params);
[3] 小弟我架设的软件工程师问答网站
来源: 互联网 发布时间: 2014-02-18
我架设的程序员问答网站
我架设了一个程序员问答网站,欢迎来http://programmerask.sinaapp.com提问。
我架设了一个程序员问答网站,欢迎来http://programmerask.sinaapp.com提问。
最新技术文章: