Example #1
0
//
// Helper/debug function to quickly print out a set of assignments.
// Later if we change how we implement assignment sets, we will have to update
// this function.
//
void DataFlowUtil::print(const Assignments& assignments) {
  cerr << "{ ";
  for (Assignments::const_iterator I = assignments.begin(),
      IE = assignments.end(); I != IE; ++I) {
    cerr << (*I).pointer->getName().data() << " ";
  }
  cerr << "}";
}
Example #2
0
void XMLConverter::setAssignments(Assignments & assignments)
{
    for (Assignments::iterator i = assignments.begin(), e = assignments.end();
            i != e; i++)
    {
        Assignment * assignment = *i;
        RequestOverseer * overseer = getOverseerByRequest(assignment->getRequest());
        overseer->assign(assignment, *networkOverseer);
    }
}
Example #3
0
void DataFlowUtil::setIntersect(Assignments& dest, const Assignments& src) {
  Assignments result;
  for (Assignments::const_iterator i = src.begin(); i != src.end(); ++i) {
    const Assignment& test = *i;
    if (src.count(test) > 0 && dest.count(test) > 0) {
      result.insert(test);
    }
  }
  // rewrite the destination
  dest = result;
}
static QString valueByName(const Assignments& assignments,
                           const QString& name,
                           const QString& defaultValue)
{
    auto it = assignments.find(name);
    if (it == assignments.end())
        return defaultValue;

    if (!it->member.isEmpty())
        return defaultValue;

    return it->value;
}
Example #5
0
//
// Determine if 2 sets contain the same elements.
//
bool DataFlowUtil::setEquals(const Assignments& a, const Assignments& b) {
  // make sure sets are the same length
  if (a.size() != b.size()) {
    return false;
  }

  // ensure they contain the same elements
  for (Assignments::const_iterator i = a.begin(); i != a.end(); ++i) {
    const Assignment& test = *i;
    if (b.count(test) < 1) {
      return false;
    }
  }
  return true;
}
bool ExhaustiveSearcher::makeAttempt() {
    if ( isExhausted() )
        return false;

    Elements cortege = getNextCortege();
    Assignments cache = getAssignmentsCache(cortege);
    Elements assignmentPack = getAssignmentPack(cache);
    Operation::forEach(assignmentPack, Operation::unassign);

    assignmentPack.insert(target);
    if ( performGreedyAssignment(assignmentPack, cortege) ) {
        if ( updatePathes(assignmentPack) )
            return true;
    }

    for(Assignments::iterator i = cache.begin(); i != cache.end(); i++ ) 
        i->second->assign(i->first);

    return false;
}
Example #7
0
void DataFlowUtil::setUnion(Assignments& dest, const Assignments& src) {
  for (Assignments::const_iterator i = src.begin(); i != src.end(); ++i) {
    const Assignment& add = *i;
    dest.insert(add);
  }
}
Example #8
0
//
// The following functions perform basic set operations in O(n*log(m)) time,
// where m and n are the sizes of the sets. For our purposes, this is fast
// enough.
//
// The result of these operations is stored back into the 1st argument.
//
void DataFlowUtil::setSubtract(Assignments& dest, const Assignments& src) {
  for (Assignments::const_iterator i = src.begin(); i != src.end(); ++i) {
    const Assignment& sub = *i;
    dest.erase(sub);
  }
}