equal
deleted
inserted
replaced
300 if (m.size()==0 && c.size() > 0 && |
300 if (m.size()==0 && c.size() > 0 && |
301 c instanceof SortedSet && |
301 c instanceof SortedSet && |
302 m instanceof TreeMap) { |
302 m instanceof TreeMap) { |
303 SortedSet<? extends E> set = (SortedSet<? extends E>) c; |
303 SortedSet<? extends E> set = (SortedSet<? extends E>) c; |
304 TreeMap<E,Object> map = (TreeMap<E, Object>) m; |
304 TreeMap<E,Object> map = (TreeMap<E, Object>) m; |
305 Comparator<? super E> cc = (Comparator<? super E>) set.comparator(); |
305 Comparator<?> cc = set.comparator(); |
306 Comparator<? super E> mc = map.comparator(); |
306 Comparator<? super E> mc = map.comparator(); |
307 if (cc==mc || (cc != null && cc.equals(mc))) { |
307 if (cc==mc || (cc != null && cc.equals(mc))) { |
308 map.addAllForTreeSet(set, PRESENT); |
308 map.addAllForTreeSet(set, PRESENT); |
309 return true; |
309 return true; |
310 } |
310 } |
467 * Returns a shallow copy of this {@code TreeSet} instance. (The elements |
467 * Returns a shallow copy of this {@code TreeSet} instance. (The elements |
468 * themselves are not cloned.) |
468 * themselves are not cloned.) |
469 * |
469 * |
470 * @return a shallow copy of this set |
470 * @return a shallow copy of this set |
471 */ |
471 */ |
|
472 @SuppressWarnings("unchecked") |
472 public Object clone() { |
473 public Object clone() { |
473 TreeSet<E> clone = null; |
474 TreeSet<E> clone; |
474 try { |
475 try { |
475 clone = (TreeSet<E>) super.clone(); |
476 clone = (TreeSet<E>) super.clone(); |
476 } catch (CloneNotSupportedException e) { |
477 } catch (CloneNotSupportedException e) { |
477 throw new InternalError(e); |
478 throw new InternalError(e); |
478 } |
479 } |
517 throws java.io.IOException, ClassNotFoundException { |
518 throws java.io.IOException, ClassNotFoundException { |
518 // Read in any hidden stuff |
519 // Read in any hidden stuff |
519 s.defaultReadObject(); |
520 s.defaultReadObject(); |
520 |
521 |
521 // Read in Comparator |
522 // Read in Comparator |
522 Comparator<? super E> c = (Comparator<? super E>) s.readObject(); |
523 @SuppressWarnings("unchecked") |
|
524 Comparator<? super E> c = (Comparator<? super E>) s.readObject(); |
523 |
525 |
524 // Create backing TreeMap |
526 // Create backing TreeMap |
525 TreeMap<E,Object> tm; |
527 TreeMap<E,Object> tm = new TreeMap<>(c); |
526 if (c==null) |
|
527 tm = new TreeMap<>(); |
|
528 else |
|
529 tm = new TreeMap<>(c); |
|
530 m = tm; |
528 m = tm; |
531 |
529 |
532 // Read in size |
530 // Read in size |
533 int size = s.readInt(); |
531 int size = s.readInt(); |
534 |
532 |