// If the state of this set's type is inconsistent with the current type
// mapping, then update the mapping with any missing types and then
// reset all of its BitSet contents with the correct indices
if (needToRemapIndices) {
TIntIntMap typeRemapping = new TIntIntHashMap();
for (Map.Entry<Object,Integer> e : typeIndices.entrySet()) {
Object o = e.getKey();
int oldIndex = e.getValue();
// NOTE: the else {} case above may have added several of our
// types that weren't inconsistent, so this may be an identity
// mapping for some types, which is nice.
typeRemapping.put(oldIndex, index(o));
}
// Remap all the in-edges vertices' types...
for (TIntObjectIterator<BitSet> it = inEdges.iterator(); it.hasNext(); ) {
it.advance();
int v = it.key();
BitSet oldIndices = it.value();
BitSet newIndices = new BitSet();
for (int i = oldIndices.nextSetBit(0); i >= 0;
i = oldIndices.nextSetBit(i+1)) {
newIndices.set(typeRemapping.get(i));
}
it.setValue(newIndices);
}
// Remap all the in-edges vertices' types...
for (TIntObjectIterator<BitSet> it = outEdges.iterator(); it.hasNext(); ) {
it.advance();
int v = it.key();
BitSet oldIndices = it.value();
BitSet newIndices = new BitSet();
for (int i = oldIndices.nextSetBit(0); i >= 0;
i = oldIndices.nextSetBit(i+1)) {
newIndices.set(typeRemapping.get(i));
}
it.setValue(newIndices);
}
}
}