Пример #1
0
void reindex(
  const IterablePairs& pairs,
  Hash_Map<PairValueType, PairValueType> & _reindexForward,
  Hash_Map<PairValueType, PairValueType> & _reindexBackward)
{
  typedef std::pair<PairValueType,PairValueType> PairT;
  // get an unique set of Ids
  std::set<size_t> _uniqueId;
  for(typename IterablePairs::const_iterator iter = pairs.begin();
        iter != pairs.end(); ++iter)
  {
    _uniqueId.insert(iter->first);
    _uniqueId.insert(iter->second);
  }

  // Build the Forward and Backward mapping
  for(typename IterablePairs::const_iterator iter = pairs.begin();
        iter != pairs.end(); ++iter)
  {
    if (_reindexForward.find(iter->first) == _reindexForward.end())
    {
      const size_t dist = std::distance(_uniqueId.begin(), _uniqueId.find(iter->first));
      _reindexForward[iter->first] = dist;
      _reindexBackward[dist] = iter->first;
    }
    if (_reindexForward.find(iter->second) == _reindexForward.end())
    {
      const size_t dist = std::distance(_uniqueId.begin(), _uniqueId.find(iter->second));
      _reindexForward[iter->second] = dist;
      _reindexBackward[dist] = iter->second;
    }
  }
}
Пример #2
0
int Hash_Map_Example::run (void)
{
  ACE_TRACE ("Hash_Map_Example::run");

  for (int i = 0; i < 100; i++)
    {
      map_.bind (i, DataElement (i));
    }

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Map has\n")));
  for (int j = 0; j < 100; j++)
    {
      DataElement d;
      map_.find (j, d);
      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%d:"), d.getData ()));
    }
  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));

  // Use the forward iterator.
  this->iterate_forward ();

  // Use the reverse iterator.
  this->iterate_reverse ();

  // Remove all the elements from the map.
  this->remove_all ();

  // Iterate through the map again.
  this->iterate_forward ();

  return 0;
}
Пример #3
0
void reindex
(
  const IterablePairs& pairs,
  Hash_Map<PairValueType, PairValueType> & reindex_forward,
  Hash_Map<PairValueType, PairValueType> & reindex_backward
)
{
  // get a unique set of Ids
  std::set<size_t> unique_id;
  for (typename IterablePairs::const_iterator iter = pairs.begin();
        iter != pairs.end(); ++iter)
  {
    unique_id.insert(iter->first);
    unique_id.insert(iter->second);
  }

  // Build the Forward and Backward mapping
  for (typename IterablePairs::const_iterator iter = pairs.begin();
        iter != pairs.end(); ++iter)
  {
    if (reindex_forward.find(iter->first) == reindex_forward.end())
    {
      const size_t dist = std::distance(unique_id.begin(), unique_id.find(iter->first));
      reindex_forward[iter->first] = dist;
      reindex_backward[dist] = iter->first;
    }
    if (reindex_forward.find(iter->second) == reindex_forward.end())
    {
      const size_t dist = std::distance(unique_id.begin(), unique_id.find(iter->second));
      reindex_forward[iter->second] = dist;
      reindex_backward[dist] = iter->second;
    }
  }
}
Пример #4
0
  /// Return the PointFeatures belonging to the View, if the view does not exist
  ///  it returns an empty PointFeature array.
  const features::PointFeatures & getFeatures(const IndexT & id_view) const
  {
    // Have an empty feature set in order to deal with non existing view_id
    static const features::PointFeatures emptyFeats = features::PointFeatures();

    Hash_Map<IndexT, features::PointFeatures>::const_iterator it = feats_per_view.find(id_view);
    if (it != feats_per_view.end())
      return it->second;
    else
      return emptyFeats;
  }
Пример #5
0
void Hash_Map_Example::iterate_reverse (void)
{
  ACE_TRACE ("Hash_Map_Example::iterate_reverse");

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Reverse Iteration\n")));
  for (Hash_Map<KeyType, DataElement>::reverse_iterator iter = map_.rbegin ();
       iter != map_.rend (); iter++)
    {
      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%d:"), (*iter).int_id_.getData ()));
    }
  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
}
Пример #6
0
void Hash_Map_Example::iterate_forward (void)
{
  ACE_TRACE ("Hash_Map_Example::iterate_forward");

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Forward Iteration\n")));
  for (Hash_Map<KeyType, DataElement>::iterator iter = map_.begin ();
       iter != map_.end (); iter++)
    {
      ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%d:"), (*iter).int_id_.getData ()));
    }
  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
}
Пример #7
0
void Hash_Map_Example::remove_all (void)
{
  ACE_TRACE ("Hash_Map_Example::remove_all");
  map_.unbind_all ();
}