/*
@awisniew - ADDED

Same as poll, only throws exception if queue is empty

@see java.util.Queue#remove()
182781
@Override
    public T remove() {

        T retrievedElement = poll();

        if (retrievedElement == null) {
            throw new NoSuchElementException();
        }

        return retrievedElement;
    }
1030213
private void emptyQueue() {
        if (queue == null) {
            return;
        }
        int startSize = cacheMap.size();
        while (true) {
            @SuppressWarnings("unchecked")
            CacheEntry<K,V> entry = (CacheEntry<K,V>)queue.poll();
            if (entry == null) {
                break;
            }
            K key = entry.getKey();
            if (key == null) {
                // key is null, entry has already been removed
                continue;
            }
            CacheEntry<K,V> currentEntry = cacheMap.remove(key);
            // check if the entry in the map corresponds to the expired
            // entry. If not, readd the entry
            if ((currentEntry != null) && (entry != currentEntry)) {
                cacheMap.put(key, currentEntry);
            }
        }
        if (DEBUG) {
            int endSize = cacheMap.size();
            if (startSize != endSize) {
                System.out.println("*** Expunged " + (startSize - endSize)
                        + " entries, " + endSize + " entries left");
            }
        }
    }
1001377
public ByteArrayQueue remove(byte[] b, int off, int len) {
		System.arraycopy(array, offset, b, off, len);
		return remove(len);
	}
1106107
public E remove(){
        E head = queue.poll();      // remove head from queue
        if(head != null){
            set.remove(head);       // also remove this element from the hash set
        }
        return head;
    }
1167353
@Override
    public void destroy() throws Exception {
        final boolean trace = TraceComponent.isAnyTracingEnabled();
        if (trace && tc.isEntryEnabled())
            Tr.entry(this, tc, "destroy", id);

        tracker.close();

        StringBuilder filter = new StringBuilder(FilterUtils.createPropertyFilter(AbstractConnectionFactoryService.ID, id));
        filter.insert(filter.length() - 1, '*');

        builder.removeExistingConfigurations(filter.toString());

        if (trace && tc.isEntryEnabled())
            Tr.exit(this, tc, "destroy");
    }
1311720
public static void emptyAndRemoveQueue( String strQueueName )
  {
    TaskQueue taskQueue = QUEUE_MAP.get( strQueueName );
    if( taskQueue != null )
    {
      taskQueue.emptyQueue();
      synchronized( taskQueue._queue )
      {
        taskQueue._shutdown = true;
        taskQueue._queue.notifyAll();
      }
      QUEUE_MAP.remove( strQueueName );
    }
  }
379946
@Override
    public <E extends Exception> void remove(Iteration<? extends Statement, E> statements) throws RepositoryException, E {
        while(statements.hasNext()){
            Statement st = statements.next();
            getClient().sendRemove(null, st.getSubject(), st.getPredicate(), st.getObject());
        }
    }
654947
public void remove( Widget w )
	{
		int index = indexOf( w );
		if( index == -1 )
		{
			throw new NoSuchElementException();
		}

		remove( index );
	}
697737
@SuppressWarnings("unchecked")
    private void delete(SoftHandle<K, V> n) {
        if (n.tree == null) {
            throw new IllegalArgumentException("Invalid handle!");
        }

        /*
         * Delete from belonging list. Care must be taken as the tree reference
         * is valid only if the node is the first in the list.
         */
        TreeNode<K, V> tree = n.tree;

        if (tree.cHead != n) {
            /*
             * Not first in list. Each case, remove and leave as ghost element.
             */
            if (n.next != null) {
                n.next.prev = n.prev;
            }
            n.prev.next = n.next;
        } else {
            /*
             * First in list
             */
            SoftHandle<K, V> nNext = n.next;
            tree.cHead = nNext;
            if (nNext != null) {
                /*
                 * More elements exists, remove and leave as ghost element.
                 * Update new first element to point to correct tree.
                 */
                nNext.prev = null;
                nNext.tree = tree;
            } else {
                /*
                 * No more elements, sift.
                 */
                sift(tree);

                /*
                 * If still no elements, remove tree.
                 */
                if (tree.cHead == null) {
                    if (tree.parent instanceof TreeNode) {
                        TreeNode<K, V> p = (TreeNode<K, V>) tree.parent;
                        if (p.left == tree) {
                            p.left = null;
                        } else {
                            p.right = null;
                        }
                    } else {
                        delete((RootListNode<K, V>) tree.parent);
                    }
                }

            }
        }

        n.tree = null;
        n.prev = null;
        n.next = null;

        size--;
    }
1148779
public void remove(QueueElement qe) {

		if (head == qe) {
			removeHead();
		} else if (tail == qe) {
			removeTail();
		} else {
			qe.previous.next = qe.next;
			qe.next.previous = qe.previous;
			qe.previous = null;
			qe.next = null;
			qe.queue = null;
			numElements--;
		}

	}
275736
private void destroyRequestQueue(Queue<AsyncResourceRequest<V>> requestQueue) {
        if(requestQueue != null) {
            AsyncResourceRequest<V> resourceRequest = requestQueue.poll();
            while(resourceRequest != null) {
                destroyRequest(resourceRequest);
                resourceRequest = requestQueue.poll();
            }
        }
    }
343470
public void purge()
    {
        WeakElement<?>    element;

        while( ( element = (WeakElement<?>) _queue.poll() ) != null )
        {
            _set.remove( element );
        }
    }
628322
private void removeAt(int i) {
        Object[] array = queue;
        int n = size - 1;
        if (n == i) // removed last element
            array[i] = null;
        else {
            E moved = (E) array[n];
            array[n] = null;
            Comparator<? super E> cmp = comparator;
            if (cmp == null)
                siftDownComparable(i, moved, array, n);
            else
                siftDownUsingComparator(i, moved, array, n, cmp);
            if (array[i] == moved) {
                if (cmp == null)
                    siftUpComparable(i, moved, array);
                else
                    siftUpUsingComparator(i, moved, array, cmp);
            }
        }
        size = n;
    }
566094
public int removeAllMessages(String queueName) {
        try {
            return getQueueControl(queueName).removeMessages(null);
        } catch (Exception e) {
            throw new AsyncException(e);
        }
    }
33415
public void removeQueuePointOutputHandler(SIBUuid8 meUuid)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "removeQueuePointOutputHandler", new Object[] { meUuid });

    synchronized(_queuePointOutputHandlers)
    {
      _queuePointOutputHandlers.remove(meUuid);
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "removeQueuePointOutputHandler");
  }
415779
@Override
	public void removeBySent(boolean sent) {
		for (CommerceNotificationQueueEntry commerceNotificationQueueEntry : findBySent(
				sent, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
			remove(commerceNotificationQueueEntry);
		}
	}
950140
function(element) {
      var readied = this.remove(element);
      if (readied) {
        element.__queue.flushable = true;
        this.addToFlushQueue(readied);
        this.check();
      }
    }