code: public static TIntIntHashMap makeVMIndex(Collection<Instance> instances) {
          TIntIntHashMap index = new TIntIntHashMap();
          int p = 0;
          for (Instance i : instances) {
              Mapping m = i.getModel().getMapping();
              for (Node n : m.getOnlineNodes()) {
                  for (VM v : m.getRunningVMs(n)) {
                      index.put(v.id(), p);
                  }
                  for (VM v : m.getSleepingVMs(n)) {
                      index.put(v.id(), p);
                  }
              }
              for (VM v : m.getReadyVMs()) {
                  index.put(v.id(), p);
              }
              p++;
          }
          return index;
      }
docs: Make an index revealing the position of each VM in a collection
  of disjoint instances
  
  @param instances the collection to browse. Instances are supposed to be disjoint
  @return the index of every VM. Format {@code VM#id() -> position}