@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); }
@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); } }