摘要: 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 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 1 public class ArrayDeque<E> 2 { 3 4 private static final int MIN_INITIAL_CAPACITY = 16; 5 6 private E[] elements; 7 8 private int head; 9 10 private int tail; 11 12 13 public ArrayDeque() 14 { 15 elements = (E[]) new Object[MIN_IN... 阅读全文
posted @ 2012-03-21 15:59 rilley 阅读(312) 评论(0) 推荐(0) 编辑
摘要: 1 package queue; 2 3 import java.lang.reflect.Array; 4 import java.util.Arrays; 5 import java.util.Comparator; 6 7 8 public class PriorityQueue<T> 9 { 10 11 private static final int DEFAULT_SIZE = 32; 12 private int size = 0; 13 private Object[] queue; 14 private final... 阅读全文
posted @ 2012-03-21 10:53 rilley 阅读(232) 评论(0) 推荐(0) 编辑