Example usage for com.google.common.collect TreeMultiset create

List of usage examples for com.google.common.collect TreeMultiset create

Introduction

In this page you can find the example usage for com.google.common.collect TreeMultiset create.

Prototype

public static <E extends Comparable> TreeMultiset<E> create(Iterable<? extends E> elements) 

Source Link

Document

Creates an empty multiset containing the given initial elements, sorted according to the elements' natural order.

Usage

From source file:org.onebusaway.nyc.vehicle_tracking.impl.simulator.SimulatorTask.java

private boolean processResultRecord(NycTestInferredLocationRecord record) {

    final NycTestInferredLocationRecord rr = _vehicleLocationInferenceService
            .getNycTestInferredLocationRecordForVehicle(record.getVehicleId());

    if (rr == null || rr.getTimestamp() < record.getTimestamp())
        return false;

    rr.setVehicleId(_vehicleId);//from  ww  w.  j  a v a 2  s . com

    if (_fillActualProperties) {
        rr.setActualRunId(rr.getInferredRunId());
        rr.setActualBlockId(rr.getInferredBlockId());
        rr.setActualTripId(rr.getInferredTripId());
        rr.setActualBlockLat(rr.getInferredBlockLat());
        rr.setActualBlockLon(rr.getInferredBlockLon());
        rr.setActualDistanceAlongBlock(rr.getInferredDistanceAlongBlock());
        rr.setActualScheduleTime(rr.getInferredScheduleTime());
        rr.setActualDsc(rr.getInferredDsc());
        rr.setActualPhase(rr.getInferredPhase());
        rr.setActualServiceDate(rr.getInferredServiceDate());
        rr.setActualStatus(rr.getInferredStatus());

        rr.clearInferredValues();
    }

    rr.setAssignedRunId(record.getAssignedRunId());
    rr.setActualIsRunFormal(record.getActualIsRunFormal());
    rr.setActualRunId(record.getActualRunId());
    rr.setActualBlockId(record.getActualBlockId());
    rr.setActualTripId(record.getActualTripId());
    rr.setActualBlockLat(record.getActualBlockLat());
    rr.setActualBlockLon(record.getActualBlockLon());
    rr.setActualDistanceAlongBlock(record.getActualDistanceAlongBlock());
    rr.setActualScheduleTime(record.getActualScheduleTime());
    rr.setActualDsc(record.getActualDsc());
    rr.setActualPhase(record.getActualPhase());
    rr.setActualServiceDate(record.getActualServiceDate());
    rr.setActualStatus(record.getActualStatus());

    synchronized (_results) {
        _results.add(rr);
        rr.setRecordNumber(_results.size() - 1);
    }

    final VehicleLocationDetails details = new VehicleLocationDetails();
    details.setId(_id);
    details.setVehicleId(_vehicleId);
    details.setLastObservation(RecordLibrary.getNycTestInferredLocationRecordAsNycRawLocationRecord(record));

    final Multiset<Particle> weightedParticles = TreeMultiset.create(Ordering.natural());
    weightedParticles.addAll(_vehicleLocationInferenceService.getCurrentParticlesForVehicleId(_vehicleId));
    if (!weightedParticles.isEmpty()) {
        details.setParticles(weightedParticles);
        details.setSampledParticles(weightedParticles);
    }

    if (_details.size() < _maxParticleHistorySize)
        _details.add(details);

    return true;
}

From source file:com.cinchapi.concourse.server.storage.db.Block.java

/**
 * Return the backing store to hold revisions that are placed in this Block.
 * This is only relevant to use when the Block is {@link #mutable} and not
 * yet persisted to disk./* www .  j av a 2s  . com*/
 * <p>
 * If this Block is to be {@link #concurrent} then override this method and
 * return a Concurrent Multiset.
 * </p>
 * 
 * @param comparator
 * @return the backing store
 */
@SuppressWarnings("rawtypes")
protected SortedMultiset<Revision<L, K, V>> createBackingStore(Comparator<Revision> comparator) {
    return TreeMultiset.create(comparator);
}