Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Java Arrays.sort Ô´Âë½âÎö primitive

    Java ArraysÖÐÌṩÁ˶ÔËùÓÐÀàÐ͵ÄÅÅÐò¡£ÆäÖÐÖ÷Òª·ÖΪprimitiveºÍObjectÁ½´óÀ࣬·Ö±ðʹÓÃÁË¿ìËÙÅÅÐòÓëºÏ²¢ÅÅÐò¡£±¾ÕÂÒÔint[] µÄÅÅÐò£¬½²½âJava¶ÔprimitiveÅÅÐò¡£
    Ê×ÏÈ´ó¼ÒÒªÁ˽âʲôÊÇ¿ìËÙÅÅÐò£¬ËüÓÐʲôÓŵ㣬ÕâЩÎҾͲ»ÀÛÊöÁË£¬¸ø³öµØÖ·¡£http://zh.wikipedia.org/zh/%E5%BF%AB%E9%80%9F%E6%8E%92%E5%BA%8F
ÔÚÁ˽âÁË»ù±¾Ô­ÀíÖ®ºó£¬ÉÏͼ¿ÉÒÔ¶¯Ì¬µÄչʾ¿ìËÙÅÅÐòµÄ»ù±¾Ë¼Â·¡£ºÜ¾­µä~
½ÓÏÂÀ´£¬ÎÒÃÇչʾԴÂ룬²¢×Ðϸ½²½â£¡
public static void sort(int[] a) {
sort1(a, 0, a.length);
}

Õâ¸ö·½·¨ÊǶÔÍⱩ¶µÄµ÷Óýӿڡ£ sort1 ÊÇÅÅÐò·½·¨µÄÖ÷Ì壬´«Èë²ÎÊý·Ö±ðΪ£º´ýÅÅÐòÊý×飬ÅÅÐòÆðʼλÖ㬴ýÅÅÐòÔªËس¤¶È¡£
sort1ÖÐʹÓõ½ÁíÍâ3¸ö·½·¨£¬Ê×ÏȽéÉÜ¡£
1. swap£º¼òµ¥µÄʹÓÃÖмä±äÁ¿À´½»»»Êý×éÄÚÔªËØ¡£
private static void swap(int x[], int a, int b) {
int t = x[a];
x[a] = x[b];
x[b] = t;
}

2.med3£º¼ÆËãÖÐÖµ¡£
private static int med3(int x[], int a, int b, int c) {
return (x[a] < x[b] ?
(x[b] < x[c] ? b : x[a] < x[c] ? c : a) :
(x[b] > x[c] ? b : x[a] > x[c] ? c : a));
}

3.vecswap£ºÅúÁ¿Òƶ¯ÔªËØ
private static void vecswap(int x[], int a, int b, int n) {
for (int i=0; i<n; i++, a++, b++)
swap(x, a, b);
}

Íòʾ㱸£¬¿ªÊ¼Ïê½â¡£
private static void sort1(int x[], int off, int len) {
// Insertion sort on smallest arrays
if (len < 7) {
for (int i=off; i<len+off; i++)
for (int j=i; j>off && x[j-1]>x[j]; j--)
swap(x, j, j-1);
return;
}

¿ªÍ·²¿·Ö±ãÅжϣ¬Èç¹ûÊý×鳤¶ÈСÓÚ7£¬±ãʹÓòåÈë·½·¨ÅÅÐò¡£
// Choose a partition element, v
int m = off + (len >> 1); // Small arrays, middle element
if (len > 7) {
int l = off;
int n = off + len - 1;
if (len > 40) { // Big arrays, pseudomedian of 9
int s = len/8;
l = med3(x, l, l+s, l+2*s);
m = med3(x, m-s, m, m+s);
n = med3(x, n-2*s, n-s, n);
}
m = med3(x, l, m, n); // Mid-size, med of 3
}
int v = x[m];

Èç¹û³¤¶È½Ï³¤£¬±ãÐ


Ïà¹ØÎĵµ£º

Ubuntu9.10²Ù×÷ϵͳÏ´java¿ª·¢»·¾³

ÕâÊÇÎÒÔÚ°²×°ÍêUbuntu9.10ºó´ÓÍøÉÏËѵÄһЩ¹ØÓÚÅäÖÃJava¿ª·¢»·¾³µÄ×ÊÁÏ£¬ÔÚÕâÀïÒªÌرð¸ÐлԭÎÄ×÷ÕßµÄÐÁÇÚÀͶ¯
Ï£ÍûÄÜ°ï·½±ã¸ü¶àµÄÈË£¬ÎÒ»áÔÚUbuntuµÄʹÓùý³ÌÖмÌÐøÊÕ¼¯ºÍ´´×÷һЩÏà¹Ø֪ʶ£¬Ï£ÍûÄܶԴó¼ÒÓÐËù°ïÖú£¡£¡£¡
תÔØÇë±êÃ÷³ö´¦£º
xxm19820127
    http://blog.csdn.net/xxm19820127/archive/201 ......

[JAVAÓëģʽ]ѧϰ±Ê¼Ç Ò»

      ×÷ΪһÃû³ÌÐòÔ±£¬×ÜÒª¾­Àú´ÓС¹æÄ£µÄ¾Ö²¿±àÂëת»»µ½´óÐÍÈí¼þÉè¼Æ¡¢¿ª·¢µÄ¹ý³Ì¡£Ôڴ˹ý³ÌÖУ¬ÔÚÊìϤÁ˱à³ÌÓïÑÔºó£¬ÐèÒª½«ÑÛ¹âÉÏÉýÒ»¸ö²ãÃ棬´ÓÕûÌåÈ¥°ÑÎÕÕû¸öÈí¼þµÄ¼Ü¹¹£¬Õë¶ÔÒ»¸öÐÐÒµµÄ¾ßÌåÒµÎñ£¬Äܹ»Éè¼ÆÒ»¸öºÏÀíµÄ¼Ü¹¹£¬Ìá¸ßÈí¼þµÄ¿É¿¿ÐÔ¡¢¿Éά»¤ÐÔ¡¢¿É¸´ÓÃÐÔ¡£¾ÍÏñһλ¾­Ñé·á¸»µÄͬÊÂËùË ......

JavaÉè¼Æģʽ֮:IteratorÁ´±íģʽ

ÏÈÀ´Á˽âÒ»ÏÂÁ´±íģʽµÄÔ­Àí£º
Ê×ÏÈдһ¸öJavaBean£¬ÄÚÈÝÊÇÒªÌí¼ÓµÄÔªËغ͸ÃÔªËصĽڵ㡣
public class NodeBean implements Serializable
{
   
    private Object data; //ÔªËر¾Éí
    private NodeBean next; //ÏÂÒ»¸ö½Úµã
   
  &n ......

JavaÖеÄÊó±êʼþºÍ¼üÅÌʼþ

http://www.cnblogs.com/rookieport/archive/2005/09/05/163393.html
ÁôÏÂÔ­´´×÷ÕßµÄÁ´½Ó  10¸öÀý×Ó
ÁíÍ⻹ÓÐһƪ
//ÀûÓà java.awt.Robot ÀàÀ´×Ô¶¯Íê³ÉһЩ¼üÅÌ»òÊó±êµÄ¶¯×÷,ÏÂÃæÊÇÒ»¸öСÀý×Ó
//³ÌÐòÁ÷³Ì:Ä£ÄâÊó±ê×ó¼üµã»÷ ¿ªÊ¼-->ÔËÐÐ-->CMD-->DIR-->CLS-->EXIT
//Ä£ÄâÓÒ¼üµã»÷ Òƶ¯µ½ÓÒϽÇ--&g ......

javaÁÄÌìÊÒ¡¾×ª¡¿

¿Í»§¶Ë:
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.awt.*;

public class ClientPoint extends JFrame implements ActionListener,KeyListener{
static int SERVERPORT=8088;
sta ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ