/** * Gets and removes the head of the queue. * * @return the head of the queue or null if the queue is empty. */ public E poll() { if (isEmpty()) { return null; } E result = elements[0]; removeAt(0); return result; }
/** * Removes the specified object from the priority queue. * * @param o * the object to be removed. * @return true if the object was in the priority queue, false if the object * was not in the priority queue. */ @Override @SuppressWarnings("unchecked") public boolean remove(Object o) { if (o == null) { return false; } for (int targetIndex = 0; targetIndex < size; targetIndex++) { if (o.equals(elements[targetIndex])) { removeAt(targetIndex); return true; } } return false; }
/** * Version of remove using reference equality, not equals. * Needed by iterator.remove. * * @param o element to be removed from this queue, if present * @return {@code true} if removed */ boolean removeEq(Object o) { for (int i = 0; i < size; i++) { if (o == queue[i]) { removeAt(i); return true; } } return false; }
/** * Version of remove using reference equality, not equals. * Needed by iterator.remove. * * @param o element to be removed from this queue, if present * @return {@code true} if removed */ boolean removeEq(Object o) { for (int i = 0; i < size; i++) { if (o == queue[i]) { removeAt(i); return true; } } return false; }
/** * Version of remove using reference equality, not equals. * Needed by iterator.remove. * * @param o element to be removed from this queue, if present * @return {@code true} if removed */ boolean removeEq(Object o) { for (int i = 0; i < size; i++) { if (o == queue[i]) { removeAt(i); return true; } } return false; }
/** * Gets and removes the head of the queue. * * @return the head of the queue or null if the queue is empty. */ public E poll() { if (isEmpty()) { return null; } E result = elements[0]; removeAt(0); return result; }
/** * Gets and removes the head of the queue. * * @return the head of the queue or null if the queue is empty. */ public E poll() { if (isEmpty()) { return null; } E result = elements[0]; removeAt(0); return result; }
/** * Gets and removes the head of the queue. * * @return the head of the queue or null if the queue is empty. */ public E poll() { if (isEmpty()) { return null; } E result = elements[0]; removeAt(0); return result; }
/** * Gets and removes the head of the queue. * * @return the head of the queue or null if the queue is empty. */ public E poll() { if (isEmpty()) { return null; } E result = elements[0]; removeAt(0); return result; }
/** * Gets and removes the head of the queue. * * @return the head of the queue or null if the queue is empty. */ public E poll() { if (isEmpty()) { return null; } E result = elements[0]; removeAt(0); return result; }
/** * Gets and removes the head of the queue. * * @return the head of the queue or null if the queue is empty. */ public E poll() { if (isEmpty()) { return null; } E result = elements[0]; removeAt(0); return result; }
/** * Gets and removes the head of the queue. * * @return the head of the queue or null if the queue is empty. */ public E poll() { if (isEmpty()) { return null; } E result = elements[0]; removeAt(0); return result; }
/** * Removes the specified object from the priority queue. * * @param o * the object to be removed. * @return true if the object was in the priority queue, false if the object * was not in the priority queue. */ @Override @SuppressWarnings("unchecked") public boolean remove(Object o) { if (o == null) { return false; } for (int targetIndex = 0; targetIndex < size; targetIndex++) { if (o.equals(elements[targetIndex])) { removeAt(targetIndex); return true; } } return false; }
/** * Removes the specified object from the priority queue. * * @param o * the object to be removed. * @return true if the object was in the priority queue, false if the object * was not in the priority queue. */ @Override @SuppressWarnings("unchecked") public boolean remove(Object o) { if (o == null) { return false; } for (int targetIndex = 0; targetIndex < size; targetIndex++) { if (o.equals(elements[targetIndex])) { removeAt(targetIndex); return true; } } return false; }
/** * Removes the specified object from the priority queue. * * @param o * the object to be removed. * @return true if the object was in the priority queue, false if the object * was not in the priority queue. */ @Override @SuppressWarnings("unchecked") public boolean remove(Object o) { if (o == null) { return false; } for (int targetIndex = 0; targetIndex < size; targetIndex++) { if (o.equals(elements[targetIndex])) { removeAt(targetIndex); return true; } } return false; }
/** * Removes the specified object from the priority queue. * * @param o * the object to be removed. * @return true if the object was in the priority queue, false if the object * was not in the priority queue. */ @Override @SuppressWarnings("unchecked") public boolean remove(Object o) { if (o == null) { return false; } for (int targetIndex = 0; targetIndex < size; targetIndex++) { if (o.equals(elements[targetIndex])) { removeAt(targetIndex); return true; } } return false; }
/** * Removes the specified object from the priority queue. * * @param o * the object to be removed. * @return true if the object was in the priority queue, false if the object * was not in the priority queue. */ @Override @SuppressWarnings("unchecked") public boolean remove(Object o) { if (o == null) { return false; } for (int targetIndex = 0; targetIndex < size; targetIndex++) { if (o.equals(elements[targetIndex])) { removeAt(targetIndex); return true; } } return false; }
/** * Removes a single instance of the specified element from this queue, * if it is present. More formally, removes an element {@code e} such * that {@code o.equals(e)}, if this queue contains one or more such * elements. Returns {@code true} if and only if this queue contained * the specified element (or equivalently, if this queue changed as a * result of the call). * * @param o element to be removed from this queue, if present * @return {@code true} if this queue changed as a result of the call */ public boolean remove(Object o) { int i = indexOf(o); if (i == -1) return false; else { removeAt(i); return true; } }
/** * Removes a single instance of the specified element from this queue, * if it is present. More formally, removes an element {@code e} such * that {@code o.equals(e)}, if this queue contains one or more such * elements. Returns {@code true} if and only if this queue contained * the specified element (or equivalently, if this queue changed as a * result of the call). * * @param o element to be removed from this queue, if present * @return {@code true} if this queue changed as a result of the call */ public boolean remove(Object o) { int i = indexOf(o); if (i == -1) return false; else { removeAt(i); return true; } }
/** * Removes a single instance of the specified element from this queue, * if it is present. More formally, removes an element {@code e} such * that {@code o.equals(e)}, if this queue contains one or more such * elements. Returns {@code true} if and only if this queue contained * the specified element (or equivalently, if this queue changed as a * result of the call). * * @param o element to be removed from this queue, if present * @return {@code true} if this queue changed as a result of the call */ public boolean remove(Object o) { int i = indexOf(o); if (i == -1) return false; else { removeAt(i); return true; } }