コード例 #1
0
 @SuppressWarnings("unchecked")
 public PriorityBlockingDeque(PriorityDeque<? extends E> c) {
   this.lock = new ReentrantLock();
   this.notEmpty = lock.newCondition();
   this.comparator = (Comparator<? super E>) c.comparator();
   initFromPriorityDeque(c);
 }
コード例 #2
0
 @SuppressWarnings("unchecked")
 public PriorityBlockingDeque(Collection<? extends E> c) {
   this.lock = new ReentrantLock();
   this.notEmpty = lock.newCondition();
   if (c instanceof SortedSet<?>) {
     SortedSet<? extends E> ss = (SortedSet<? extends E>) c;
     this.comparator = (Comparator<? super E>) ss.comparator();
     addAll(ss);
   } else if (c instanceof PriorityDeque<?>) {
     PriorityDeque<? extends E> pq = (PriorityDeque<? extends E>) c;
     this.comparator = (Comparator<? super E>) pq.comparator();
     initFromPriorityDeque(pq);
   } else if (c instanceof PriorityBlockingDeque<?>) {
     PriorityBlockingDeque<? extends E> pq = (PriorityBlockingDeque<? extends E>) c;
     this.comparator = (Comparator<? super E>) pq.comparator();
     initFromPriorityBlockingDeque(pq);
   } else {
     this.comparator = null;
     addAll(c);
   }
 }