随笔分类 -  算法实现

摘要:public static String[] split(String str, String limit) { List result = new ArrayList(); char[] chars = limit.toCharArray(); ... 阅读全文
posted @ 2014-06-16 16:38 rilley 阅读(355) 评论(0) 推荐(0)
摘要:public class KnnTest { public static void readFileToList(String path, List<List<Double>> list) { BufferedReader br = null; try { br = new BufferedReader(new FileReader(path)); while (br.ready()) { String line = br.readLine(); ... 阅读全文
posted @ 2012-09-18 09:59 rilley 阅读(663) 评论(0) 推荐(0)
摘要:org.apache.hadoop.io.WritableUtils 1 public static void writeVLong(DataOutput stream, long i) throws IOException 2 { 3 // 直接写数据 4 if (i >= -112 && i <= 127) { 5 stream.writeByte((byte) i); 6 return; 7 } 8 9 int len = -112;10 1... 阅读全文
posted @ 2012-08-16 16:12 rilley 阅读(431) 评论(0) 推荐(0)
摘要:运算符 ~ 按位非(NOT)(一元运算) & 按位与(AND) | 按位或(OR) ^ 按位异或(XOR) >> 右移 >>> 右移,左边空出的位以0填充 << 左移 &= 按位与赋值 |= 按位或赋值 ^= 按位异或赋值 >>= 右移赋值 >>>= 右移赋值,左边空出的位以0填充 <<= 左移赋值优先级 1 ()[] 2 ++(后缀) --(后缀) 3 ++(前缀) --(前缀) +(正) -(负) ! ~ instanceof 4 New(类型) 5 * / % 6 +(加) -(减) 7 阅读全文
posted @ 2012-07-16 17:00 rilley 阅读(174) 评论(0) 推荐(0)
摘要:插入排序 1 public static void insertSort(Comparable[] array) 2 { 3 int j = 0; 4 5 for (int i = 1; i < array.length; i++) { 6 Comparable temp = array[i]; 7 8 for (j = i; j > 0 && (temp.compareTo(array[j - 1]) < 0); j--) { 9 ... 阅读全文
posted @ 2012-07-02 16:06 rilley 阅读(267) 评论(0) 推荐(0)
摘要:1 public class BinarySearch 2 { 3 4 public static int search(int[] array, int n) 5 { 6 int low = 0, mid = 0; 7 int high = array.length - 1; 8 9 while (low <= high) {10 11 mid = (low + high) >> 1;12 13 if (arr... 阅读全文
posted @ 2012-03-21 22:41 rilley 阅读(184) 评论(0) 推荐(0)
摘要:package java.util.concurrent;import java.util.concurrent.locks.*;import java.util.*;public class ThreadPoolExecutor extends AbstractExecutorService { /** * runState provides the main lifecyle control, taking on values: * * RUNNING: Accept new tasks and process queued tasks * ... 阅读全文
posted @ 2012-02-07 17:47 rilley 阅读(2461) 评论(2) 推荐(1)