Changeset 3453 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2010-08-21T14:59:31+02:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java
r3157 r3453 575 575 return true; 576 576 } 577 // If anyone has suggestions for how to fix578 // this properly, I'm listening :)579 @SuppressWarnings("unchecked")580 private T convert(Object raw)581 {582 return (T)raw;583 }584 577 public boolean remove(Object o) { 585 return this.remove(convert(o)); 586 } 587 public boolean remove(T o) { 578 @SuppressWarnings("unchecked") T t = (T) o; 588 579 synchronized (split_lock) { 589 580 search_cache = null; // Search cache might point to one of removed buckets 590 QBLevel bucket = root.findBucket( o.getBBox());591 if (bucket.remove_content( o)) {581 QBLevel bucket = root.findBucket(t.getBBox()); 582 if (bucket.remove_content(t)) { 592 583 size--; 593 584 return true; … … 597 588 } 598 589 public boolean contains(Object o) { 599 QBLevel bucket = root.findBucket(convert(o).getBBox()); 600 return bucket != null && bucket.content != null && bucket.content.contains(o); 590 @SuppressWarnings("unchecked") T t = (T) o; 591 QBLevel bucket = root.findBucket(t.getBBox()); 592 return bucket != null && bucket.content != null && bucket.content.contains(t); 601 593 } 602 594 -
trunk/src/org/openstreetmap/josm/data/osm/Storage.java
r3398 r3453 111 111 this.hash = ha; 112 112 int cap = 1 << (int)(Math.ceil(Math.log(capacity/loadFactor) / Math.log(2))); 113 data = (T[]) new Object[cap]; 113 @SuppressWarnings("unchecked") T[] newData = (T[]) new Object[cap]; 114 data = newData; 114 115 mask = data.length - 1; 115 116 this.safeIterator = safeIterator; … … 118 119 private void copyArray() { 119 120 if (arrayCopyNecessary) { 120 T[] newData = (T[]) new Object[data.length];121 @SuppressWarnings("unchecked") T[] newData = (T[]) new Object[data.length]; 121 122 System.arraycopy(data, 0, newData, 0, data.length); 122 123 data = newData; … … 143 144 @Override 144 145 public synchronized boolean contains(Object o) { 145 int bucket = getBucket(hash, (T)o); 146 @SuppressWarnings("unchecked") T t = (T) o; 147 int bucket = getBucket(hash, t); 146 148 return bucket >= 0; 147 149 } … … 155 157 @Override 156 158 public synchronized boolean remove(Object o) { 157 T orig = removeElem((T)o); 158 return orig != null; 159 @SuppressWarnings("unchecked") T t = (T) o; 160 T tOrig = removeElem(t); 161 return tOrig != null; 159 162 } 160 163 … … 292 295 private void ensureSpace() { 293 296 if (size > data.length*loadFactor) { // rehash 294 T[] big = (T[]) new Object[data.length * 2];297 @SuppressWarnings("unchecked") T[] big = (T[]) new Object[data.length * 2]; 295 298 int nMask = big.length - 1; 296 299 … … 355 358 } 356 359 357 public boolean containsKey(Object key) { 358 int bucket = getBucket(fHash, (K)key); 360 public boolean containsKey(Object o) { 361 @SuppressWarnings("unchecked") K key = (K) o; 362 int bucket = getBucket(fHash, key); 359 363 return bucket >= 0; 360 364 } … … 364 368 } 365 369 366 public T get(Object key) { 367 int bucket = getBucket(fHash, (K)key); 370 public T get(Object o) { 371 @SuppressWarnings("unchecked") K key = (K) o; 372 int bucket = getBucket(fHash, key); 368 373 return bucket < 0 ? null : data[bucket]; 369 374 } … … 374 379 } 375 380 376 public T remove(Object key) {381 public T remove(Object o) { 377 382 modCount++; 378 int bucket = getBucket(fHash,(K)key); 383 @SuppressWarnings("unchecked") K key = (K) o; 384 int bucket = getBucket(fHash, key); 379 385 380 386 return bucket < 0 ? null : doRemove(bucket);
Note:
See TracChangeset
for help on using the changeset viewer.