code: public int getThisTaskIndex() {
          List<Integer> tasks = new ArrayList<>(getComponentTasks(getThisComponentId()));
          Collections.sort(tasks);
          for (int i = 0; i < tasks.size(); i++) {
              if (tasks.get(i) == getThisTaskId()) {
                  return i;
              }
          }
          throw new RuntimeException("Fatal: could not find this task id in this component");
      }
docs: Gets the index of this task id in getComponentTasks(getThisComponentId()).
  An example use case for this method is determining which task accesses which
  resource in a distributed resource to ensure an even distribution.