Java 类edu.wpi.first.wpilibj.util.SortedVector 实例源码

项目:Frc2016FirstStronghold    文件:BinaryImage.java   
/**
 * Gets all the particle analysis reports ordered from largest area to
 * smallest.
 *
 * @param size The number of particles to return
 * @return An array of ParticleReports from largest area to smallest
 */
public ParticleAnalysisReport[] getOrderedParticleAnalysisReports(int size)
    throws NIVisionException {
  if (size > getNumberParticles())
    size = getNumberParticles();
  ParticleSizeReport[] reports = new ParticleSizeReport[size];
  SortedVector sorter = new SortedVector(new SortedVector.Comparator() {
    public int compare(Object object1, Object object2) {
      ParticleSizeReport p1 = (ParticleSizeReport) object1;
      ParticleSizeReport p2 = (ParticleSizeReport) object2;
      if (p1.size < p2.size)
        return -1;
      else if (p1.size > p2.size)
        return 1;
      return 0;
    }
  });
  for (int i = 0; i < getNumberParticles(); i++)
    sorter.addElement(new ParticleSizeReport(i));
  sorter.setSize(size);
  sorter.copyInto(reports);
  ParticleAnalysisReport[] finalReports = new ParticleAnalysisReport[reports.length];
  for (int i = 0; i < finalReports.length; i++)
    finalReports[i] = reports[i].getParticleAnalysisReport();
  return finalReports;
}
项目:wpilibj    文件:BinaryImage.java   
/**
 * Gets all the particle analysis reports ordered from largest area to smallest.
 * @param size The number of particles to return
 * @return An array of ParticleReports from largest area to smallest
 */
public ParticleAnalysisReport[] getOrderedParticleAnalysisReports(int size) throws NIVisionException{
    if (size > getNumberParticles())
        size = getNumberParticles();
    ParticleSizeReport[] reports = new ParticleSizeReport[size];
    SortedVector sorter = new SortedVector(new SortedVector.Comparator() {
        public int compare(Object object1, Object object2) {
            ParticleSizeReport p1 = (ParticleSizeReport)object1;
            ParticleSizeReport p2 = (ParticleSizeReport)object2;
            if (p1.size < p2.size)
                return -1;
            else if (p1.size > p2.size)
                return 1;
            return 0;
        }
    });
    for (int i = 0; i < getNumberParticles(); i++)
        sorter.addElement(new ParticleSizeReport(i));
    sorter.setSize(size);
    sorter.copyInto(reports);
    ParticleAnalysisReport[] finalReports = new ParticleAnalysisReport[reports.length];
    for (int i = 0; i < finalReports.length; i++)
        finalReports[i] = reports[i].getParticleAnalysisReport();
    return finalReports;
}
项目:wpilib-java    文件:BinaryImage.java   
/**
 * Gets all the particle analysis reports ordered from largest area to smallest.
 * @param size The number of particles to return
 * @return An array of ParticleReports from largest area to smallest
 */
public ParticleAnalysisReport[] getOrderedParticleAnalysisReports(int size) throws NIVisionException{
    if (size > getNumberParticles())
        size = getNumberParticles();
    ParticleSizeReport[] reports = new ParticleSizeReport[size];
    SortedVector sorter = new SortedVector(new SortedVector.Comparator() {
        public int compare(Object object1, Object object2) {
            ParticleSizeReport p1 = (ParticleSizeReport)object1;
            ParticleSizeReport p2 = (ParticleSizeReport)object2;
            if (p1.size < p2.size)
                return -1;
            else if (p1.size > p2.size)
                return 1;
            return 0;
        }
    });
    for (int i = 0; i < getNumberParticles(); i++)
        sorter.addElement(new ParticleSizeReport(i));
    sorter.setSize(size);
    sorter.copyInto(reports);
    ParticleAnalysisReport[] finalReports = new ParticleAnalysisReport[reports.length];
    for (int i = 0; i < finalReports.length; i++)
        finalReports[i] = reports[i].getParticleAnalysisReport();
    return finalReports;
}