Tabnine Logo
PriorityBuffer.compare
Code IndexAdd Tabnine to your IDE (free)

How to use
compare
method
in
org.apache.commons.collections.buffer.PriorityBuffer

Best Java code snippets using org.apache.commons.collections.buffer.PriorityBuffer.compare (Showing top 20 results out of 315)

origin: commons-collections/commons-collections

/**
 * Percolates element up heap from the position given by the index.
 * <p>
 * Assumes it is a minimum heap.
 *
 * @param index the index of the element to be percolated up
 */
protected void percolateUpMinHeap(final int index) {
  int hole = index;
  Object element = elements[hole];
  while (hole > 1 && compare(element, elements[hole / 2]) < 0) {
    // save element that is being pushed down
    // as the element "bubble" is percolated up
    final int next = hole / 2;
    elements[hole] = elements[next];
    hole = next;
  }
  elements[hole] = element;
}
origin: commons-collections/commons-collections

/**
 * Percolates element up heap from from the position given by the index.
 * <p>
 * Assume it is a maximum heap.
 *
 * @param index the index of the element to be percolated up
 */
protected void percolateUpMaxHeap(final int index) {
  int hole = index;
  Object element = elements[hole];
  while (hole > 1 && compare(element, elements[hole / 2]) > 0) {
    // save element that is being pushed down
    // as the element "bubble" is percolated up
    final int next = hole / 2;
    elements[hole] = elements[next];
    hole = next;
  }
  elements[hole] = element;
}
origin: wildfly/wildfly

/**
 * Percolates element up heap from the position given by the index.
 * <p>
 * Assumes it is a minimum heap.
 *
 * @param index the index of the element to be percolated up
 */
protected void percolateUpMinHeap(final int index) {
  int hole = index;
  Object element = elements[hole];
  while (hole > 1 && compare(element, elements[hole / 2]) < 0) {
    // save element that is being pushed down
    // as the element "bubble" is percolated up
    final int next = hole / 2;
    elements[hole] = elements[next];
    hole = next;
  }
  elements[hole] = element;
}
origin: commons-collections/commons-collections

/**
 * Percolates element down heap from the position given by the index.
 * <p>
 * Assumes it is a minimum heap.
 *
 * @param index the index for the element
 */
protected void percolateDownMinHeap(final int index) {
  final Object element = elements[index];
  int hole = index;
  while ((hole * 2) <= size) {
    int child = hole * 2;
    // if we have a right child and that child can not be percolated
    // up then move onto other child
    if (child != size && compare(elements[child + 1], elements[child]) < 0) {
      child++;
    }
    // if we found resting place of bubble then terminate search
    if (compare(elements[child], element) >= 0) {
      break;
    }
    elements[hole] = elements[child];
    hole = child;
  }
  elements[hole] = element;
}
origin: commons-collections/commons-collections

/**
 * Percolates element down heap from the position given by the index.
 * <p>
 * Assumes it is a maximum heap.
 *
 * @param index the index of the element
 */
protected void percolateDownMaxHeap(final int index) {
  final Object element = elements[index];
  int hole = index;
  while ((hole * 2) <= size) {
    int child = hole * 2;
    // if we have a right child and that child can not be percolated
    // up then move onto other child
    if (child != size && compare(elements[child + 1], elements[child]) > 0) {
      child++;
    }
    // if we found resting place of bubble then terminate search
    if (compare(elements[child], element) <= 0) {
      break;
    }
    elements[hole] = elements[child];
    hole = child;
  }
  elements[hole] = element;
}
origin: wildfly/wildfly

/**
 * Percolates element up heap from from the position given by the index.
 * <p>
 * Assume it is a maximum heap.
 *
 * @param index the index of the element to be percolated up
 */
protected void percolateUpMaxHeap(final int index) {
  int hole = index;
  Object element = elements[hole];
  while (hole > 1 && compare(element, elements[hole / 2]) > 0) {
    // save element that is being pushed down
    // as the element "bubble" is percolated up
    final int next = hole / 2;
    elements[hole] = elements[next];
    hole = next;
  }
  elements[hole] = element;
}
origin: wildfly/wildfly

/**
 * Percolates element down heap from the position given by the index.
 * <p>
 * Assumes it is a maximum heap.
 *
 * @param index the index of the element
 */
protected void percolateDownMaxHeap(final int index) {
  final Object element = elements[index];
  int hole = index;
  while ((hole * 2) <= size) {
    int child = hole * 2;
    // if we have a right child and that child can not be percolated
    // up then move onto other child
    if (child != size && compare(elements[child + 1], elements[child]) > 0) {
      child++;
    }
    // if we found resting place of bubble then terminate search
    if (compare(elements[child], element) <= 0) {
      break;
    }
    elements[hole] = elements[child];
    hole = child;
  }
  elements[hole] = element;
}
origin: wildfly/wildfly

/**
 * Percolates element down heap from the position given by the index.
 * <p>
 * Assumes it is a minimum heap.
 *
 * @param index the index for the element
 */
protected void percolateDownMinHeap(final int index) {
  final Object element = elements[index];
  int hole = index;
  while ((hole * 2) <= size) {
    int child = hole * 2;
    // if we have a right child and that child can not be percolated
    // up then move onto other child
    if (child != size && compare(elements[child + 1], elements[child]) < 0) {
      child++;
    }
    // if we found resting place of bubble then terminate search
    if (compare(elements[child], element) >= 0) {
      break;
    }
    elements[hole] = elements[child];
    hole = child;
  }
  elements[hole] = element;
}
origin: commons-collections/commons-collections

public void remove() {
  if (lastReturnedIndex == -1) {
    throw new IllegalStateException();
  }
  elements[ lastReturnedIndex ] = elements[ size ];
  elements[ size ] = null;
  size--;  
  if( size != 0 && lastReturnedIndex <= size) {
    int compareToParent = 0;
    if (lastReturnedIndex > 1) {
      compareToParent = compare(elements[lastReturnedIndex], 
        elements[lastReturnedIndex / 2]);  
    }
    if (ascendingOrder) {
      if (lastReturnedIndex > 1 && compareToParent < 0) {
        percolateUpMinHeap(lastReturnedIndex); 
      } else {
        percolateDownMinHeap(lastReturnedIndex);
      }
    } else {  // max heap
      if (lastReturnedIndex > 1 && compareToParent > 0) {
        percolateUpMaxHeap(lastReturnedIndex); 
      } else {
        percolateDownMaxHeap(lastReturnedIndex);
      }
    }          
  }
  index--;
  lastReturnedIndex = -1; 
}
origin: wildfly/wildfly

public void remove() {
  if (lastReturnedIndex == -1) {
    throw new IllegalStateException();
  }
  elements[ lastReturnedIndex ] = elements[ size ];
  elements[ size ] = null;
  size--;  
  if( size != 0 && lastReturnedIndex <= size) {
    int compareToParent = 0;
    if (lastReturnedIndex > 1) {
      compareToParent = compare(elements[lastReturnedIndex], 
        elements[lastReturnedIndex / 2]);  
    }
    if (ascendingOrder) {
      if (lastReturnedIndex > 1 && compareToParent < 0) {
        percolateUpMinHeap(lastReturnedIndex); 
      } else {
        percolateDownMinHeap(lastReturnedIndex);
      }
    } else {  // max heap
      if (lastReturnedIndex > 1 && compareToParent > 0) {
        percolateUpMaxHeap(lastReturnedIndex); 
      } else {
        percolateDownMaxHeap(lastReturnedIndex);
      }
    }          
  }
  index--;
  lastReturnedIndex = -1; 
}
origin: org.jboss.eap/wildfly-client-all

/**
 * Percolates element up heap from the position given by the index.
 * <p>
 * Assumes it is a minimum heap.
 *
 * @param index the index of the element to be percolated up
 */
protected void percolateUpMinHeap(final int index) {
  int hole = index;
  Object element = elements[hole];
  while (hole > 1 && compare(element, elements[hole / 2]) < 0) {
    // save element that is being pushed down
    // as the element "bubble" is percolated up
    final int next = hole / 2;
    elements[hole] = elements[next];
    hole = next;
  }
  elements[hole] = element;
}
origin: com.alibaba.citrus.tool/antx-autoexpand

/**
 * Percolates element up heap from the position given by the index.
 * <p>
 * Assumes it is a minimum heap.
 *
 * @param index the index of the element to be percolated up
 */
protected void percolateUpMinHeap(final int index) {
  int hole = index;
  Object element = elements[hole];
  while (hole > 1 && compare(element, elements[hole / 2]) < 0) {
    // save element that is being pushed down
    // as the element "bubble" is percolated up
    final int next = hole / 2;
    elements[hole] = elements[next];
    hole = next;
  }
  elements[hole] = element;
}
origin: org.apache.openjpa/openjpa-all

/**
 * Percolates element up heap from the position given by the index.
 * <p>
 * Assumes it is a minimum heap.
 *
 * @param index the index of the element to be percolated up
 */
protected void percolateUpMinHeap(final int index) {
  int hole = index;
  Object element = elements[hole];
  while (hole > 1 && compare(element, elements[hole / 2]) < 0) {
    // save element that is being pushed down
    // as the element "bubble" is percolated up
    final int next = hole / 2;
    elements[hole] = elements[next];
    hole = next;
  }
  elements[hole] = element;
}
origin: com.alibaba.citrus.tool/antx-autoexpand

/**
 * Percolates element up heap from from the position given by the index.
 * <p>
 * Assume it is a maximum heap.
 *
 * @param index the index of the element to be percolated up
 */
protected void percolateUpMaxHeap(final int index) {
  int hole = index;
  Object element = elements[hole];
  while (hole > 1 && compare(element, elements[hole / 2]) > 0) {
    // save element that is being pushed down
    // as the element "bubble" is percolated up
    final int next = hole / 2;
    elements[hole] = elements[next];
    hole = next;
  }
  elements[hole] = element;
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-collections

/**
 * Percolates element up heap from the position given by the index.
 * <p>
 * Assumes it is a minimum heap.
 *
 * @param index the index of the element to be percolated up
 */
protected void percolateUpMinHeap(final int index) {
  int hole = index;
  Object element = elements[hole];
  while (hole > 1 && compare(element, elements[hole / 2]) < 0) {
    // save element that is being pushed down
    // as the element "bubble" is percolated up
    final int next = hole / 2;
    elements[hole] = elements[next];
    hole = next;
  }
  elements[hole] = element;
}
origin: org.apache.directory.api/api-ldap-client-all

/**
 * Percolates element up heap from from the position given by the index.
 * <p>
 * Assume it is a maximum heap.
 *
 * @param index the index of the element to be percolated up
 */
protected void percolateUpMaxHeap(final int index) {
  int hole = index;
  Object element = elements[hole];
  while (hole > 1 && compare(element, elements[hole / 2]) > 0) {
    // save element that is being pushed down
    // as the element "bubble" is percolated up
    final int next = hole / 2;
    elements[hole] = elements[next];
    hole = next;
  }
  elements[hole] = element;
}
origin: org.apache.openjpa/openjpa-all

/**
 * Percolates element up heap from from the position given by the index.
 * <p>
 * Assume it is a maximum heap.
 *
 * @param index the index of the element to be percolated up
 */
protected void percolateUpMaxHeap(final int index) {
  int hole = index;
  Object element = elements[hole];
  while (hole > 1 && compare(element, elements[hole / 2]) > 0) {
    // save element that is being pushed down
    // as the element "bubble" is percolated up
    final int next = hole / 2;
    elements[hole] = elements[next];
    hole = next;
  }
  elements[hole] = element;
}
origin: org.jboss.eap/wildfly-client-all

/**
 * Percolates element up heap from from the position given by the index.
 * <p>
 * Assume it is a maximum heap.
 *
 * @param index the index of the element to be percolated up
 */
protected void percolateUpMaxHeap(final int index) {
  int hole = index;
  Object element = elements[hole];
  while (hole > 1 && compare(element, elements[hole / 2]) > 0) {
    // save element that is being pushed down
    // as the element "bubble" is percolated up
    final int next = hole / 2;
    elements[hole] = elements[next];
    hole = next;
  }
  elements[hole] = element;
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-collections

/**
 * Percolates element up heap from from the position given by the index.
 * <p>
 * Assume it is a maximum heap.
 *
 * @param index the index of the element to be percolated up
 */
protected void percolateUpMaxHeap(final int index) {
  int hole = index;
  Object element = elements[hole];
  while (hole > 1 && compare(element, elements[hole / 2]) > 0) {
    // save element that is being pushed down
    // as the element "bubble" is percolated up
    final int next = hole / 2;
    elements[hole] = elements[next];
    hole = next;
  }
  elements[hole] = element;
}
origin: org.apache.directory.api/api-ldap-client-all

/**
 * Percolates element up heap from the position given by the index.
 * <p>
 * Assumes it is a minimum heap.
 *
 * @param index the index of the element to be percolated up
 */
protected void percolateUpMinHeap(final int index) {
  int hole = index;
  Object element = elements[hole];
  while (hole > 1 && compare(element, elements[hole / 2]) < 0) {
    // save element that is being pushed down
    // as the element "bubble" is percolated up
    final int next = hole / 2;
    elements[hole] = elements[next];
    hole = next;
  }
  elements[hole] = element;
}
org.apache.commons.collections.bufferPriorityBuffercompare

Javadoc

Compares two objects using the comparator if specified, or the natural order otherwise.

Popular methods of PriorityBuffer

  • get
    Gets the next element to be removed without actually removing it (peek).
  • isEmpty
  • grow
    Increases the size of the heap to support additional elements
  • isAtCapacity
    Tests if the buffer is at capacity.
  • percolateDownMaxHeap
    Percolates element down heap from the position given by the index. Assumes it is a maximum heap.
  • percolateDownMinHeap
    Percolates element down heap from the position given by the index. Assumes it is a minimum heap.
  • percolateUpMaxHeap
    Percolates a new element up heap from the bottom. Assume it is a maximum heap.
  • percolateUpMinHeap
    Percolates a new element up heap from the bottom. Assumes it is a minimum heap.
  • <init>
    Constructs a new empty buffer specifying the sort order and comparator.
  • add
    Adds an element to the buffer. The element added will be sorted according to the comparator in use.
  • remove
  • size
    Returns the number of elements in this buffer.
  • remove,
  • size,
  • contains,
  • iterator

Popular in Java

  • Creating JSON documents from java classes using gson
  • getSystemService (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getSharedPreferences (Context)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • Path (java.nio.file)
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • JButton (javax.swing)
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now