Пример #1
0
/**
 * Determine if the contents of the other presenter are different from this one.
 * @param other
 * @return
 */
bool ConcretePeaksPresenter::contentsDifferent(
    const PeaksPresenter *other) const {
  const SetPeaksWorkspaces otherWorkspaces = other->presentedWorkspaces();

  // Look for this workspace in the others workspace list.
  auto iterator = otherWorkspaces.find(this->m_peaksWS);

  const bool different = (iterator == otherWorkspaces.end());
  return different;
}
Пример #2
0
/**
 * @brief Determine wheter the workspace contents is different with another
 * presenter.
 * @param other
 * @return
 */
bool CompositePeaksPresenter::contentsDifferent(
    PeaksPresenter const *const other) const {
  /*
   What we are doing here is looking through all workspaces associated with the
   incoming presenter
   and seeing if ANY of the exising subjects of this composite is already
   presenting one of these workspaces.
   ONLY if there is no intesection between the two sets will we allow addition.
   */
  const SetPeaksWorkspaces otherWorkspaces = other->presentedWorkspaces();
  const SetPeaksWorkspaces existingWorkspaces = this->presentedWorkspaces();

  SetPeaksWorkspaces difference;
  std::set_difference(existingWorkspaces.begin(), existingWorkspaces.end(),
                      otherWorkspaces.begin(), otherWorkspaces.end(),
                      std::inserter(difference, difference.end()));

  // Is the candidate set the same as the difference set (i.e. no intesection)
  // and also non-zero in size
  const bool different = (difference.size() == existingWorkspaces.size());
  return different;
}