?? arrays.java
字號:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: Arrays.java
package gnnt.MEBS.HQApplet;
import gnnt.MEBS.hq.ProductDataVO;
import java.io.PrintStream;
class Arrays
{
Arrays()
{
}
public static void sort(ProductDataVO a[], String strSortItem)
{
quickSort(a, 0, a.length - 1, strSortItem);
}
private static boolean lessThan(ProductDataVO one, ProductDataVO other, String strSortItem)
{
if(strSortItem.equals("Code"))
return one.code.compareTo(other.code) < 0;
if(strSortItem.equals("CurPrice"))
return one.curPrice < other.curPrice;
if(strSortItem.equals("TotalAmount"))
return one.totalAmount < other.totalAmount;
if(strSortItem.equals("UpValue"))
{
float oneUp = one.closePrice <= 0.0F || one.curPrice <= 0.0F ? 0.0F : one.curPrice - one.closePrice;
float otherUp = other.closePrice <= 0.0F || other.curPrice <= 0.0F ? 0.0F : other.curPrice - other.closePrice;
return oneUp < otherUp;
}
if(strSortItem.equals("UpRate"))
{
float oneUprate = one.closePrice != 0.0F ? ((one.curPrice - one.closePrice) / one.closePrice) * 100F : 0.0F;
float otherUprate = other.closePrice != 0.0F ? ((other.curPrice - other.closePrice) / other.closePrice) * 100F : 0.0F;
return oneUprate < otherUprate;
}
if(strSortItem.equals("TotalMoney"))
return one.totalMoney < other.totalMoney;
if(strSortItem.equals("AmountRate"))
return one.amountRate < other.amountRate;
if(strSortItem.equals("ConsignRate"))
return one.consignRate < other.consignRate;
else
return true;
}
private static void quickSort(ProductDataVO a[], int left, int right, String strSortItem)
{
if(left < right)
{
ProductDataVO tmp = a[left];
int i = left;
for(int j = right; i < j;)
{
while(i < j && lessThan(a[j], tmp, strSortItem))
j--;
if(i < j)
a[i++] = a[j];
for(; i < j && !lessThan(a[i], tmp, strSortItem); i++);
if(i < j)
a[j--] = a[i];
}
a[i] = tmp;
quickSort(a, left, i - 1, strSortItem);
quickSort(a, i + 1, right, strSortItem);
}
}
private static void quickSort(int a[], int left, int right)
{
if(left < right)
{
int tmp = a[left];
int i = left;
for(int j = right; i < j;)
{
while(i < j && a[j] < tmp)
j--;
if(i < j)
a[i++] = a[j];
for(; i < j && a[i] >= tmp; i++);
if(i < j)
a[j--] = a[i];
}
a[i] = tmp;
quickSort(a, left, i - 1);
quickSort(a, i + 1, right);
}
}
public static void main(String args[])
{
int a[] = {
1, 2, 3, 4, 5
};
int b[] = {
5, 4, 3, 2, 1
};
int c[] = {
3, 2, 1, 4, 5
};
int d[] = {
0x927c2, 0x927c1, 0x7a121
};
quickSort(a, 0, a.length - 1);
quickSort(b, 0, b.length - 1);
quickSort(c, 0, c.length - 1);
System.out.println("before sort...");
for(int i = 0; i < d.length; i++)
System.out.print(d[i] + "\t");
System.out.println("\n");
quickSort(d, 0, d.length - 1);
reverse(d);
System.out.println("after sort...");
for(int i = 0; i < d.length; i++)
System.out.print(d[i] + "\t");
System.out.println("\n");
}
static void reverse(int a[])
{
int size = a.length;
int count = size / 2;
for(int i = 0; i < count; i++)
{
int tmp = a[i];
a[i] = a[size - i - 1];
a[size - i - 1] = tmp;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -