Java Code Examples for java.util.Vector.sort()

The following are Jave code examples for showing how to use sort() of the java.util.Vector class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: munche_prog   File: findPlaces.java   View Source Code Vote up 7 votes
/**
 * the program getting two databases of Vector<sameScanWifi>
 * every scan from the second the program will take the most close scans from the first and will revalue the coordinates of the scan with them.
 * @param database 
 * @param manScans
 * @param num_of_points-how many scans from the first to use for revalue
 */
public static void findManPlace(Vector<sameScanWifi> database,Vector<sameScanWifi> manScans,int num_of_points){
	for(sameScanWifi fixingNow : manScans){
		HashMap<sameScanWifi,Double> scansWeight= new HashMap<sameScanWifi,Double>();

		for(sameScanWifi gettingWeight : database){				
			scansWeight.put(gettingWeight, getScanWeight(gettingWeight,fixingNow));
		}
		database.sort(Comparator.comparing(scan -> -scansWeight.get(scan)));
		double lat=0,lon=0,alt=0,weight=0;
		for(sameScanWifi currentScan : database){	
			num_of_points--;
			lat+= scansWeight.get(currentScan)*currentScan.getLatitude();
			lon+= scansWeight.get(currentScan)*currentScan.getLongitude();
			alt+= scansWeight.get(currentScan)*currentScan.getAltitude();
			weight+= scansWeight.get(currentScan);
			if(num_of_points==0) break;
		}
		fixingNow.setAltitude(String.valueOf(alt/weight));
		fixingNow.setLatitude(String.valueOf(lat/weight));
		fixingNow.setLongitude(String.valueOf(lon/weight));
	}
}
 
Example 2
Project: munche_prog   File: findPlaces.java   View Source Code Vote up 6 votes
/**
 * 
 * @param IdenticalMAC vector that every object in it is vector of the same ruter from diffrent scan from the same placr
 * @param num of points to check with
 * @return the real places of the routers in vector of wifiWithCoordinate
 */
public static Vector<wifiWithCoordinate> realPlaces(Vector<Vector<wifiWithCoordinate>> IdenticalMAC,int num){
	Vector<wifiWithCoordinate> realePlace=new Vector<wifiWithCoordinate>();
	for(Vector<wifiWithCoordinate> sameWifi: IdenticalMAC ){
		sameWifi.sort(Comparator.comparing(sample -> -sample.getRSSI()));
		realePlace.add(avgcomp(sameWifi,num));
	}



	return realePlace;
}
 
Example 3
Project: 2017   File: ImageProcessor.java   View Source Code Vote up 5 votes
/**
 * Takes the processed image and writes information on each particle (blob) into
 * the global <reports> array, in order of overall particle area.
 */
public void updateParticalAnalysisReports ()
{
    if (this.camera.gethaveCamera() == true
            && this.currentImage != null)
        {
        final int numParticles = NIVision
                .imaqCountParticles(this.currentImage, 0);

        // Measure particles and sort by particle size
        final Vector<ParticleReport> particles = new Vector<ParticleReport>();

        if (numParticles > 0)
            {

            for (int particleIndex = 0; particleIndex < numParticles; particleIndex++)
                {

                final ParticleReport particle = new ParticleReport();
                particle.PercentAreaToImageArea = NIVision
                        .imaqMeasureParticle(this.currentImage,
                                particleIndex, 0,
                                NIVision.MeasurementType.MT_AREA_BY_IMAGE_AREA);
                particle.area = NIVision.imaqMeasureParticle(
                        this.currentImage,
                        particleIndex, 0,
                        NIVision.MeasurementType.MT_AREA);
                particle.ConvexHullArea = NIVision
                        .imaqMeasureParticle(
                                this.currentImage,
                                particleIndex, 0,
                                NIVision.MeasurementType.MT_CONVEX_HULL_AREA);
                particle.boundingRectTop = (int) NIVision
                        .imaqMeasureParticle(this.currentImage,
                                particleIndex, 0,
                                NIVision.MeasurementType.MT_BOUNDING_RECT_TOP);
                particle.boundingRectLeft = (int) NIVision
                        .imaqMeasureParticle(this.currentImage,
                                particleIndex, 0,
                                NIVision.MeasurementType.MT_BOUNDING_RECT_LEFT);
                particle.boundingRectBottom = (int) NIVision
                        .imaqMeasureParticle(this.currentImage,
                                particleIndex, 0,
                                NIVision.MeasurementType.MT_BOUNDING_RECT_BOTTOM);
                particle.boundingRectRight = (int) NIVision
                        .imaqMeasureParticle(this.currentImage,
                                particleIndex, 0,
                                NIVision.MeasurementType.MT_BOUNDING_RECT_RIGHT);
                particle.boundingRectWidth = (int) NIVision
                        .imaqMeasureParticle(this.currentImage,
                                particleIndex, 0,
                                NIVision.MeasurementType.MT_BOUNDING_RECT_WIDTH);// par.boundingRectRight
                // -
                // par.boundingRectLeft;
                particle.center_mass_x = (int) NIVision
                        .imaqMeasureParticle(this.currentImage,
                                particleIndex, 0,
                                NIVision.MeasurementType.MT_CENTER_OF_MASS_X);
                particle.center_mass_y = (int) NIVision
                        .imaqMeasureParticle(this.currentImage,
                                particleIndex, 0,
                                NIVision.MeasurementType.MT_CENTER_OF_MASS_Y);
                particle.imageWidth = NIVision
                        .imaqGetImageSize(this.currentImage).width;
                particles.add(particle);
                }
            particles.sort(null);

            }
        this.reports = new ParticleReport[particles.size()];
        particles.copyInto(this.reports);
        particles.clear();
        }
}