}
// repeat while vector of usedResources is not empty
while (!_usedResources.isEmpty()) {
// get the first resource and check the Res pool it belongs to
Res crntResPool = _usedResources.firstElement().getResPool();
// counter how many resources of that res pool are used
int n = 1;
// search the whole vector of usedResources for resources of the
// current
// Res pool
for (int i = 1; i < _usedResources.size(); i++) {
// is the resource of the desired Res pool?
if (_usedResources.elementAt(i).getResPool() == crntResPool) {
n++; // increase the counter
}
} // end for-loop
// make the array to store the resources which will be returned
Resource[] returningRes = new Resource[n];
// counter for the index of the array
int k = 0;
// collect all the resources from the Vector of usedResources
for (int j = 0; j < _usedResources.size(); j++) {
// is the resource of the desired Res pool?
if ((_usedResources.elementAt(j)).getResPool() == crntResPool) {
// put res in array
returningRes[k] = _usedResources.elementAt(j);
k++; // increase counter of array
}
if (k == n) {
break; // stop the for-loop
}
}
// return the array of resources to the Res pool they belong to
crntResPool.takeBack(returningRes);
// remove the returned resources from the vector of usedResources
for (int m = 0; m < n; m++) // go through the array of
// returningResources
{