| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public boolean add(Integer e) |
| 68 | { |
| 69 | if(e == null) |
| 70 | return false; |
| 71 | int insertionPoint = Arrays.binarySearch(store, 0, size, e); |
| 72 | if(insertionPoint >= 0 ) |
| 73 | return false;//Already in the set |
| 74 | //Fix up to where we would like to place it |
| 75 | insertionPoint = (-(insertionPoint) - 1); |
| 76 | |
| 77 | //Increase store size if needed |
| 78 | if(size >= store.length) |
| 79 | store = Arrays.copyOf(store, Math.max(1, store.length)*2); |
| 80 | |
| 81 | for(int i = size; i > insertionPoint; i--) |
| 82 | store[i] = store[i-1]; |
| 83 | store[insertionPoint] = e; |
| 84 | size++; |
| 85 | |
| 86 | return true; |
| 87 | } |
| 88 | |
| 89 | public boolean contains(int o) |
| 90 | { |