Back to index

unity  6.0.0
Functions
unity::internal::impl Namespace Reference

Functions

std::vector< std::string > GetNewbies (std::list< std::string > const &old, std::list< std::string > const &fresh)
void GetSignalAddedInfo (std::list< std::string > const &favs, std::vector< std::string > const &newbies, std::string const &path, std::string &position, bool &before)
std::vector< std::string > GetRemoved (std::list< std::string > const &old, std::list< std::string > const &fresh)
bool NeedToBeReordered (std::list< std::string > const &old, std::list< std::string > const &fresh)

Function Documentation

std::vector< std::string > unity::internal::impl::GetNewbies ( std::list< std::string > const &  old,
std::list< std::string > const &  fresh 
)

Definition at line 32 of file FavoriteStorePrivate.cpp.

{
  auto sorted_old(old);
  auto sorted_fresh(fresh);

  sorted_old.sort();
  sorted_fresh.sort();

  std::vector<std::string> result;
  std::set_difference(sorted_fresh.begin(), sorted_fresh.end(), sorted_old.begin(), sorted_old.end(),
                      std::inserter(result, result.end()));

  return result;
}

Here is the caller graph for this function:

std::vector< std::string > unity::internal::impl::GetRemoved ( std::list< std::string > const &  old,
std::list< std::string > const &  fresh 
)

Definition at line 69 of file FavoriteStorePrivate.cpp.

{
  auto sorted_old(old);
  auto sorted_fresh(fresh);

  sorted_old.sort();
  sorted_fresh.sort();

  std::vector<std::string> result;
  std::set_difference(sorted_old.begin(), sorted_old.end(), sorted_fresh.begin(), sorted_fresh.end(),
                      std::inserter(result, result.end()));

  return result;
}

Here is the caller graph for this function:

void unity::internal::impl::GetSignalAddedInfo ( std::list< std::string > const &  favs,
std::vector< std::string > const &  newbies,
std::string const &  path,
std::string &  position,
bool &  before 
)

Definition at line 47 of file FavoriteStorePrivate.cpp.

{
  auto it = std::find(favs.begin(), favs.end(), path);
  before = (it == favs.begin());
  position = "";

  if (before and favs.size() > 1)
  {
    while (it != favs.end() && std::find(newbies.begin(), newbies.end(), *it) != newbies.end())
      ++it;

    if (it != favs.end())
      position = *it;
  }
  else if (!before)
  {
    position = *(boost::prior(it));
  }

}

Here is the caller graph for this function:

bool unity::internal::impl::NeedToBeReordered ( std::list< std::string > const &  old,
std::list< std::string > const &  fresh 
)

Definition at line 85 of file FavoriteStorePrivate.cpp.

{
  auto sorted_old(old);
  auto sorted_fresh(fresh);

  sorted_old.sort();
  sorted_fresh.sort();

  std::vector<std::string> ignore_old, ignore_fresh;

  std::set_difference(sorted_old.begin(), sorted_old.end(), sorted_fresh.begin(), sorted_fresh.end(),
                      std::inserter(ignore_old, ignore_old.end()));
  std::set_difference(sorted_fresh.begin(), sorted_fresh.end(), sorted_old.begin(), sorted_old.end(),
                      std::inserter(ignore_fresh, ignore_fresh.end()));

  auto it_old = old.begin();
  auto it_fresh = fresh.begin();

  while (it_old != old.end() && it_fresh != fresh.end())
  {

    while (it_old != old.end() && std::find(ignore_old.begin(), ignore_old.end(), *it_old) != ignore_old.end())
      ++it_old;

    while (it_fresh != fresh.end() && std::find(ignore_fresh.begin(), ignore_fresh.end(), *it_fresh) != ignore_fresh.end())
      ++it_fresh;

    if (it_old == old.end() || it_fresh == fresh.end())
      break;

    if (*it_old != *it_fresh)
    {
      return true;
    }

    ++it_old;
    ++it_fresh;
  }

  return false;
}

Here is the caller graph for this function: