Ignore:
Timestamp:
Sep 28, 2012, 1:17:17 AM (10 years ago)
Author:
Peter
Message:

closes #726

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/stl_utility.h

    r2731 r2857  
    432432
    433433  /**
     434     Create a map mapping from values in range [first, last) to the
     435     distance from first.
     436
     437     Post-condition: m[first[i]] == i (for all i that correspond to a
     438     unique element). For non-unique element behaviour is undefined.
     439
     440     Requirement: InputIterator's value type is assignable to Key
     441
     442     \since New in yat 0.10
     443   */
     444  template<typename InputIterator, typename Key, typename Comp>
     445  void inverse(InputIterator first, InputIterator last,
     446               std::map<Key, size_t, Comp >& m)
     447  {
     448    BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator>));
     449    BOOST_CONCEPT_ASSERT((boost::Convertible<typename std::iterator_traits<InputIterator>::value_type, Key>));
     450    m.clear();
     451    for (size_t i=0; first!=last; ++i, ++first)
     452      m[*first] = i;
     453  }
     454
     455  /**
    434456     \brief Functor that behaves like std::less with the exception
    435457     that it treates NaN as a number larger than infinity.
Note: See TracChangeset for help on using the changeset viewer.