List of usage examples for org.apache.commons.lang3.mutable MutableInt compareTo
@Override public int compareTo(final MutableInt other)
From source file:org.nextreamlabs.simplex.model.component.SmartVariable.java
/** * Assign the next available id//from ww w . j av a 2 s. c o m * @param augmented The id to be assigned is for an augmented variable or not * @return The assigned id */ private static MutableInt assignId(Boolean augmented) { // { Preconditions assert (augmented != null) : "The augmented argument cannot be null"; // } MutableInt id = new MutableInt(0); if (!idsRegister.isEmpty()) { // Handle possible conflicts if (augmented) { // The id to be assigned is augmented // ==> Find the max id already assigned and set the id to be assigned as the maximum // already assigned for (MutableInt assignedId : idsRegister.keySet()) { if (assignedId.compareTo(id) == 1) { id.setValue(assignedId.intValue()); } } // The id to be assigned is the successive to those already assigned id.add(1); } else { // The id to be assigned isn't augmented // ==> Shift the assigned augmented ids to create a hole for the non-augmented id to be // assigned for (MutableInt assignedId : idsRegister.keySet()) { if (idsRegister.get(assignedId)) { // The current assignedId is augmented => increment it assignedId.add(1); } else { // The current assignedId isn't augmented => update the id to be assigned if (assignedId.compareTo(id) == 1) { id.setValue(assignedId.intValue()); } } // The id to be assigned is the successive to those non-augmented but already assigned id.add(1); } } } idsRegister.put(id, augmented); return id; }