435 public E ceiling(E e) { 436 return m.ceilingKey(e); 437 } 438 439 /** 440 * @throws ClassCastException {@inheritDoc} 441 * @throws NullPointerException if the specified element is null 442 * and this set uses natural ordering, or its comparator 443 * does not permit null elements 444 * @since 1.6 445 */ 446 public E higher(E e) { 447 return m.higherKey(e); 448 } 449 450 /** 451 * @since 1.6 452 */ 453 public E pollFirst() { 454 Map.Entry<E,?> e = m.pollFirstEntry(); 455 return (e == null)? null : e.getKey(); 456 } 457 458 /** 459 * @since 1.6 460 */ 461 public E pollLast() { 462 Map.Entry<E,?> e = m.pollLastEntry(); 463 return (e == null)? null : e.getKey(); 464 } 465 466 /** 467 * Returns a shallow copy of this {@code TreeSet} instance. (The elements 468 * themselves are not cloned.) 469 * 470 * @return a shallow copy of this set 471 */ 472 public Object clone() { 473 TreeSet<E> clone = null; 474 try { 475 clone = (TreeSet<E>) super.clone(); 476 } catch (CloneNotSupportedException e) { 477 throw new InternalError(); 478 } 479 480 clone.m = new TreeMap<E,Object>(m); 481 return clone; 482 } 483 | 435 public E ceiling(E e) { 436 return m.ceilingKey(e); 437 } 438 439 /** 440 * @throws ClassCastException {@inheritDoc} 441 * @throws NullPointerException if the specified element is null 442 * and this set uses natural ordering, or its comparator 443 * does not permit null elements 444 * @since 1.6 445 */ 446 public E higher(E e) { 447 return m.higherKey(e); 448 } 449 450 /** 451 * @since 1.6 452 */ 453 public E pollFirst() { 454 Map.Entry<E,?> e = m.pollFirstEntry(); 455 return (e == null) ? null : e.getKey(); 456 } 457 458 /** 459 * @since 1.6 460 */ 461 public E pollLast() { 462 Map.Entry<E,?> e = m.pollLastEntry(); 463 return (e == null) ? null : e.getKey(); 464 } 465 466 /** 467 * Returns a shallow copy of this {@code TreeSet} instance. (The elements 468 * themselves are not cloned.) 469 * 470 * @return a shallow copy of this set 471 */ 472 public Object clone() { 473 TreeSet<E> clone = null; 474 try { 475 clone = (TreeSet<E>) super.clone(); 476 } catch (CloneNotSupportedException e) { 477 throw new InternalError(); 478 } 479 480 clone.m = new TreeMap<E,Object>(m); 481 return clone; 482 } 483 |