Java±à³Ì ÓÐ1ÒÚ¸ö¸¡µãÊý£¬ÇëÕÒ³öÆäÖжԴóµÄ10000¸ö
ÓÐ1ÒÚ¸ö¸¡µãÊý£¬ÇëÕÒ³öÆäÖжԴóµÄ10000¸ö¡£Ìáʾ£º¼ÙÉèÿ¸ö¸¡µãÊýÕ¼4¸ö×Ö½Ú£¬1ÒÚ¸ö¸¡µãÊý¾ÍÒªÕ¾µ½Ï൱´óµÄ¿Õ¼ä£¬Òò´Ë²»ÄÜÒ»´Î½«È«²¿¶ÁÈëÄÚ´æ½øÐÐÅÅÐò¡£
/**
*
*/
package com.code;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import junit.framework.Assert;
import org.junit.Test;
/**
* @author Chi
*
*/
public class FloatSelector {
// @Test
public void testGenerateData(){
this.generate(100000000);
}
@Test
public void select(){
long start = System.currentTimeMillis();
final int SIZE = 10000;
Float[] selected = new Float[SIZE];
BufferedInputStream in = new BufferedInputStream(this.getClass().getResourceAsStream("data"));
//Set buffer to load array for one time.
final int BUFFER_SIZE = SIZE * 4;
final byte[] buffer = new byte[BUFFER_SIZE];
//1, Fill selected array
int pointer = 0;
int read = 0;
try {
read = in.read(buffer);
for(int i = 0; i < read / 4; i++ ){
selected[pointer ++] = Float.intBitsToFloat(bytes2int(buffer, i*4));
}
//2, sort the array
Arrays.sort(selected, Collections.reverseOrder());
while((read = in.read(buffer)) > 0){
for(int i = 0; i < read / 4; i++ ){
float newValue = Float.intBitsToFloat(bytes2int(buffer, i*4));
int j;
for(j = selected.length - 1; j >= 0 && newValue > selected[j]; j--);
if(j < selected.length - 1){
//move
for(int k = selected.length - 1; k > j + 1; k --){
selected[k] = selected[k - 1];
}
Ïà¹ØÎĵµ£º
ºÜÔç֮ǰд¹ýÀûÓ÷ºÐͺͷ´Éä»úÖƳéÏóDAO £¬¶ÔÆäÖлñÈ¡×ÓÀà·ºÐ͵ÄclassÒ»Ö±²»ÊǺÜÀí½â¡£¹Ø¼üµÄµØ·½ÊÇHibernateBaseDaoµÄ¹¹Ôì·½·¨ÖеÄ
Type genType = getClass().getGenericSuperclass();
Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
entityClass = (Class)params[0] ......
- ¼ÓÈë²ËÄñѧϰÍø£¬»ñµÃÕä²Ø×ÊÔ´
Java´úÂë Êý¾ÝÍÚ¾òÖоö²ßÊ÷C4.5Ô¤²âË㷨ʵÏÖ(°ë³ÉÆ·£¬»¹ÒªÐ´¹æÔòºó¼ôÖ¦¼°¶Ô·ÇÀëÉ¢Êý¾ÝÐÅÏ¢ÔöÒæ¼ÆËã) Java´úÂë package org.struct.decisiontree; import java.util.ArrayList; import java.util.Arrays; ......
µ¥ÀýģʽµÄʵÏÖ·½Ê½ÓкܶàÖÖ£¬ÔÚÕâÀï½éÉÜ×î¼òµ¥µÄÁ½ÖÖ¡£
µ¥ÀýģʽÄܹ»È·±£Ò»¸öÀàÖ»ÓÐÒ»¸öʵÀý£¨Õý³£Çé¿öÎÒÃÇ¿ÉÒÔnew³öÒ»¸öÀàµÄÎÞÊý¸öʵÀý£©£¬×ÔÐÐÌṩÕâ¸öʵÀý²¢ÏòÕû¸öϵͳÌṩÕâ¸öʵÀý¡£ÏÂÃæ½éÉܵ¥ÀýģʽµÄʵÏÖ·½·¨£º
1. µ¥ÀýģʽÓÐÁ½ÖÖʵÏÖ·½Ê½£ºÒ»ÖÖÊǽ«Àൠ......
JAVAµÄÈÝÆ÷---List,Map,Set
Collection
©ÀList
©¦©ÀLinkedList
©¦©ÀArrayList
©¦©¸Vector
©¦¡¡©¸Stack
©¸Set
Map
©ÀHashtable
©ÀHashMap
©¸WeakHashMap
Collection½Ó¿Ú
¡¡¡¡CollectionÊÇ×î»ù±¾µÄ¼¯ºÏ½Ó¿Ú£¬Ò»¸öCollection´ú±íÒ»×éObject£¬¼´CollectionµÄÔªËØ£¨Elements£©¡£Ò»Ð© CollectionÔÊÐíÏà ......