You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@mesos.apache.org by "Alexander Rukletsov (JIRA)" <ji...@apache.org> on 2015/12/03 22:32:11 UTC

[jira] [Created] (MESOS-4063) Add a filter abstraction to stour

Alexander Rukletsov created MESOS-4063:
------------------------------------------

             Summary: Add a filter abstraction to stour
                 Key: MESOS-4063
                 URL: https://issues.apache.org/jira/browse/MESOS-4063
             Project: Mesos
          Issue Type: Wish
          Components: stout
            Reporter: Alexander Rukletsov
            Priority: Minor


Consider a simple snippet which filters agents that satisfy a certain condition:
{code}
  foreach (const SlaveID& slaveId, slaveIds_) {
    if (isWhitelisted(slaveId) && slaves[slaveId].activated) {
      slaveIds.push_back(slaveId);
    }
  }
{code}

or using modern C++:
{code}
  std::copy_if(
      slaveIds_.begin(),
      slaveIds_.end(),
      std::back_inserter(slaveIds),
      [this](const SlaveID& slaveId) {
        return (isWhitelisted(slaveId) && slaves[slaveId].activated);
      });
{code}

Both approaches are not concise and do not clearly explain what the intention is. It would be great to write something like this instead:
{code}
std::vector<SlaveID> slaveIDs = stout::filter(
    slaveIDs_,
    [this](const SlaveID& slaveId) {
      return (isWhitelisted(slaveId) && slaves[slaveId].activated);
    });
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)