Beispiel #1
0
      //! Get the label for the entity identified by the given numeric id.
      //! The InvalidId exception is thrown if there is no matching entity in the database.
      //! @return entity label.
      const std::string&
      resolve(unsigned int id)
      {
        Concurrency::ScopedMutex l(m_lock);

        EntitiesById::iterator itr = m_by_id.find(id);

        if (itr == m_by_id.end())
          throw InvalidId(id);

        return itr->second->label;
      }
Beispiel #2
0
   UnionFind::IdType UnionFind::getRoot(IdType current)
   {
      if (current >= m_fathers.size())
         throw InvalidId(current);

      std::vector<IdType> path;
      auto root = current;
      for (; root != m_fathers[root]; root = m_fathers[root])
         path.push_back(root);
      
      for (auto i : path)
         m_fathers[i] = root;
      ++(m_weights[root]);
      return root;
   }