Changeset 1498 for trunk


Ignore:
Timestamp:
Aug 27, 2012, 8:34:11 AM (8 years ago)
Author:
Peter Johansson
Message:

latest yat and update make rule to fetch from yat repo

Location:
trunk/yat
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/CommandLine.h

    r1463 r1498  
    22#define _theplu_yat_utility_commandline_
    33
    4 //$Id: CommandLine.h 2458 2011-04-03 15:14:46Z peter $
     4//$Id: CommandLine.h 2808 2012-08-05 23:40:30Z peter $
    55
    66/*
     
    119119       \brief Allow at most \a n free arguments.
    120120
    121        An free argument is an argument not associated with an Option,
     121       A free argument is an argument not associated with an Option,
    122122       allowing commandlines such as \code prog foo bar \endcode
    123123     */
  • trunk/yat/Makefile.am

    r1443 r1498  
    2020# along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2121
    22 MOVE_IF_CHANGE = $(SHELL) $(abs_top_srcdir)/build_support/move-if-change
     22MOVE_IF_CHANGE = $(SHELL) $(abs_top_srcdir)/move-if-change
    2323
    2424AM_CPPFLAGS = $(SVNDIGEST_CPPFLAGS)
     
    7373  (cd Fetchdir && patch -i stl_utility.h.patch || exit 1)
    7474  @for f in $(FETCH_FILES); do \
    75     $(MOVE_IF_CHANGE) -v Fetchdir/$$f $(srcdir)/$$f; \
     75    $(MOVE_IF_CHANGE) Fetchdir/$$f $(srcdir)/$$f; \
    7676  done
  • trunk/yat/SegmentTree.h

    r1463 r1498  
    55
    66/*
    7   Copyright (C) 2010, 2011 Peter Johansson
     7  Copyright (C) 2010, 2011, 2012 Peter Johansson
    88
    99  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    4343   */
    4444  template<class Container, class Compare, class Value2Key>
    45   class SegmentTree 
     45  class SegmentTree
    4646  {
    4747  public:
    48     /// \brief key type
     48    /**
     49       \brief key type is same as \c Container 's \c key_type.
     50
     51       Typically Segment<element_type>.
     52    */
    4953    typedef typename Container::key_type key_type;
    50     /// \brief value type
     54
     55    /**
     56       \brief value type is same as \c Container 's \c value_type.
     57
     58       Typically a Segment<element_type> or pair<const
     59       Segment<element_type>, Data>.
     60    */
    5161    typedef typename Container::value_type value_type;
    52     /// \brief element type
     62
     63    /**
     64       \brief element type is same as \c key_type 's value_type.
     65
     66       If the key held is \c Segment<T>, \c value_type is \c T.
     67    */
    5368    typedef typename key_type::value_type element_type;
    5469
    55     /// \brief key compare
     70    ///  \brief key compare
    5671    typedef typename Container::key_compare key_compare;
    5772    /// \brief value compare
     
    7691
    7792    /**
    78        \brief creates a container with no segments
     93       \brief creates a SegmentTree with no segments
    7994     */
    8095    SegmentTree(void) {}
     
    86101
    87102    /**
    88        \return const iterator to first Segment
     103       \return const iterator pointing to beginning of container
    89104     */
    90105    const_iterator begin(void) const { return container_.begin(); }
    91106
    92107    /**
    93        \return iterator to first Segment
     108       \return iterator pointing to beginning of container
    94109     */
    95110    iterator begin(void) { return container_.begin(); }
    96111
    97112    /**
    98        \brief erases all segments
     113       \brief erases all values
    99114     */
    100115    void clear(void) { container_.clear(); }
    101116
    102117    /**
    103        \return 1 if there is a set that overlaps with \a element
     118       \return 1 if there is a Segment that overlaps with \a element
    104119     */
    105120    size_type count(const element_type& element) const;
     
    111126
    112127    /**
    113        \return end of set
     128       \return a const_iterator pointing to the end of container
    114129     */
    115130    const_iterator end(void) const { return container_.end(); }
    116131
    117132    /**
    118        \return end of set
     133       \return end of container
    119134     */
    120135    iterator end(void) { return container_.end(); }
    121136
    122137    /**
    123        erase segments in range [first, last)
     138       \brief erase values in range [first, last)
    124139
    125140       \since New in yat 0.8
     
    128143
    129144    /**
    130        erase segment pointed to by \a pos
     145       erase value pointed to by \a pos
    131146
    132147       \since New in yat 0.8
     
    135150
    136151    /**
     152       \return iterator pointing to value containing \a element
     153
     154       If no value contains \a element, end() is returned.
     155     */
     156    iterator find(const element_type& element);
     157
     158    /**
     159       \return const iterator pointing to value containing \a element
     160
     161       If no value contains \a element, end() is returned.
     162
    137163       \return an iterator pointing to the Segment that contains \a
    138164       vt. If no Segment contains \a vt, end() is returned.
    139 
    140        \since New in yat 0.8
    141      */
    142     iterator find(const element_type& vt);
    143 
    144     /**
    145        \return an iterator pointing to the Segment that contains \a
    146        vt. If no Segment contains \a vt, end() is returned.
    147165     */
    148166    const_iterator find(const element_type& vt) const;
    149167
    150168    /**
    151        \brief insert value 
    152 
    153        if \a segment does not overlap with any segment in set, insert
     169       \brief insert value
     170
     171       if \a value does not overlap with container, insert
    154172       segment; otherwise do nothing.
    155173
    156        \return a pair where pair.first points to the added \a segment
    157        or if \a segment was not added it points to a Segment in set
    158        that overlaps with \a segment; pair.second is true if \a
    159        segment was added.
    160      */
    161     std::pair<iterator, bool> insert(const value_type& segment);
    162 
    163     /**
    164        \return Comparison functor to compare to segments
    165      */
    166     key_compare key_comp(void) const 
    167     { 
     174       \return a pair where pair.first points to the inserted \a value
     175       or if \a value was not inserted it points to a value in
     176       container that overlaps with \a value; pair.second is true if
     177       \a value was inserted.
     178     */
     179    std::pair<iterator, bool> insert(const value_type& value);
     180
     181    /**
     182       \return Comparison functor to compare two keys (Segment)
     183     */
     184    key_compare key_comp(void) const
     185    {
    168186      return key_compare(compare);
    169187    }
    170188
    171189    /**
    172        \return iterator pointing to first segment that overlaps with
    173        \a element or is greater than \a element.
     190       \brief similar to lower_bound in std::set and std::map
     191
     192       \return iterator pointing to first value whose key overlaps
     193       with \a element or is greater than \a element.
    174194     */
    175195    iterator lower_bound(const element_type& element);
    176196
    177197    /**
    178        \return iterator pointing to first segment that overlaps with
    179        \a element or is greater than \a element.
     198       \brief similar to lower_bound in std::set and std::map
     199
     200       \return const iterator pointing to first value whose key
     201       overlaps with \a element or is greater than \a element.
    180202     */
    181203    const_iterator lower_bound(const element_type& element) const;
    182204
    183205    /**
    184        \return number of segments in set
     206       \return number of values in container
    185207     */
    186208    size_type size(void) const { return container_.size(); }
     
    193215
    194216    /**
    195        \return iterator pointing to first segment that is greater than
    196        \a segment.
     217       \brief similar to upper_bound in std::set and std::map
     218
     219       \return iterator pointing to first value whose key is greater
     220       than \a element.
    197221     */
    198222    const_iterator upper_bound(const element_type& element) const;
    199223
    200224    /**
    201        \return Comparison functor to compare to segments
     225       \return the \c value_compare object used by the class to sort
     226       \c values
    202227     */
    203228    value_compare value_comp(void) const { return key_comp(); }
     
    212237       overlap with \a segment.
    213238     */
    214     std::pair<iterator, iterator> overlap_range(const key_type& segment) 
     239    std::pair<iterator, iterator> overlap_range(const key_type& segment)
    215240    {
    216241      iterator first = container_.lower_bound(segment);
     
    233258
    234259  template<class Container, class Compare, class Value2Key>
    235   typename SegmentTree<Container, Compare, Value2Key>::size_type 
     260  typename SegmentTree<Container, Compare, Value2Key>::size_type
    236261  SegmentTree<Container,Compare,Value2Key>::count(const element_type& element) const
    237262  {
     
    243268
    244269  template<class Container, class Compare, class Value2Key>
    245   typename SegmentTree<Container, Compare, Value2Key>::const_iterator 
     270  typename SegmentTree<Container, Compare, Value2Key>::const_iterator
    246271  SegmentTree<Container, Compare, Value2Key>::find(const element_type& vt) const
    247272  {
     
    256281
    257282  template<class Container, class Compare, class Value2Key>
    258   typename SegmentTree<Container, Compare, Value2Key>::iterator 
     283  typename SegmentTree<Container, Compare, Value2Key>::iterator
    259284  SegmentTree<Container, Compare, Value2Key>::find(const element_type& vt)
    260285  {
     
    268293
    269294  template<typename T, class Compare, class Value2Key>
    270   std::pair<typename SegmentTree<T, Compare, Value2Key>::iterator, bool> 
     295  std::pair<typename SegmentTree<T, Compare, Value2Key>::iterator, bool>
    271296  SegmentTree<T, Compare,Value2Key>::insert(const value_type& segment)
    272297  {
     
    282307    iterator result = container_.lower_bound(segment);
    283308    // result is larger or overlapping with segment (i.e.! result<segment)
    284     YAT_ASSERT(result==end() 
     309    YAT_ASSERT(result==end()
    285310               || !compare(Value2Key()(*result),segment));
    286311    return result;
     
    295320    const_iterator result = container_.lower_bound(segment);
    296321    // result is larger or overlapping with segment (i.e.! result<segment)
    297     YAT_ASSERT(result==end() 
     322    YAT_ASSERT(result==end()
    298323               || !compare(Value2Key()(*result),segment));
    299324    return result;
  • trunk/yat/stl_utility.h

    r1463 r1498  
    11#ifndef _theplu_yat_utility_stl_utility_
    2 #define _theplu_yat_utility_stl_utility_ 
     2#define _theplu_yat_utility_stl_utility_
    33
    44// $Id$
     
    99  Copyright (C) 2006 Jari Häkkinen
    1010  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    11   Copyright (C) 2009, 2010, 2011 Peter Johansson
     11  Copyright (C) 2009, 2010, 2011, 2012 Peter Johansson
    1212
    1313  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    6969
    7070  ///
    71   /// Print out a pair 
     71  /// Print out a pair
    7272  ///
    7373  // This is in namespace std because we have not figured out how to have
    7474  // pair and its operator<< in different namespaces
    75   template <class T1, class T2> 
    76   std::ostream& operator<<(std::ostream& out, const std::pair<T1,T2>& p) 
     75  template <class T1, class T2>
     76  std::ostream& operator<<(std::ostream& out, const std::pair<T1,T2>& p)
    7777  { out << p.first << "\t" << p.second; return out; }
    7878
     
    102102     \brief Adaptor between pointer and pointee interface
    103103
    104      Pointer must have an \c operator*, i.e., \c Pointer can be a
    105      traditional pointer or an \input_iterator. Return type is decided
    106      by <a href=http://www.sgi.com/tech/stl/iterator_traits.html>
    107      std::iterator_traits </a>.
     104     Functor takes a pointer and returns a reference to the instance
     105     pointer is pointing to. Return type is decided by <a
     106     href=http://www.sgi.com/tech/stl/iterator_traits.html>
     107     std::iterator_traits<Pointer>::reference </a>. Pointer must have
     108     an \c operator*, i.e., \c Pointer can be a traditional pointer or
     109     an \input_iterator.
     110
     111     The class is designed to be used with boost::transform_iterator
     112
     113     \code
     114     std::vector<MyClass*> vec;
     115     ...
     116     Dereferencer<MyClass*> dereferencer;
     117     std::set<MyClass> s;
     118     s.insert(boost::make_transform_iterator(vec.begin(), dereferencer),
     119              boost::make_transform_iterator(vec.end(), dereferencer))
     120     \endcode
     121
     122     where elements in vec<MyClass*> are copied in to set<MyClass>.
    108123
    109124     \since New in yat 0.7
    110125   */
    111126  template<typename Pointer>
    112   struct Dereferencer : 
    113     public std::unary_function<Pointer, 
     127  struct Dereferencer :
     128    public std::unary_function<Pointer,
    114129                               typename std::iterator_traits<Pointer>::reference>
    115130  {
     
    117132       \brief constructor
    118133     */
    119     Dereferencer(void) 
     134    Dereferencer(void)
    120135    { BOOST_CONCEPT_ASSERT((TrivialIterator<Pointer>)); }
    121136
     
    142157     - G must be an <a
    143158     href="http://www.sgi.com/tech/stl/AdaptableUnaryFunction.html">
    144      AdaptableUnaryFunction</a> 
     159     AdaptableUnaryFunction</a>
    145160     - H must be an <a
    146161     href="http://www.sgi.com/tech/stl/AdaptableUnaryFunction.html">
    147      AdaptableUnaryFunction</a> 
     162     AdaptableUnaryFunction</a>
    148163     - \c G::result_type is convertible to \c F::first_argument_type
    149164     - \c H::result_type is convertible to \c F::second_argument_type
     
    152167   */
    153168  template<class F, class G, class H>
    154   class compose_f_gx_hy : 
     169  class compose_f_gx_hy :
    155170    public std::binary_function<typename G::argument_type,
    156171                                typename H::argument_type,
     
    162177     */
    163178    compose_f_gx_hy(F f, G g, H h)
    164       : f_(f), g_(g), h_(h) 
     179      : f_(f), g_(g), h_(h)
    165180    {
    166181      BOOST_CONCEPT_ASSERT((boost::Convertible<typename G::result_type
     
    175190     */
    176191    typename F::result_type
    177     operator()(typename G::argument_type x, 
     192    operator()(typename G::argument_type x,
    178193               typename H::argument_type y) const
    179194    {
     
    198213  {
    199214    return compose_f_gx_hy<F,G,H>(f,g,h);
    200   } 
     215  }
    201216
    202217
     
    215230     - G must be an <a
    216231     href="http://www.sgi.com/tech/stl/AdaptableBinaryFunction.html">
    217      AdaptableBinaryFunction</a> 
     232     AdaptableBinaryFunction</a>
    218233     - \c G::result_type is convertible to \c F::argument_type
    219234
     
    223238   */
    224239  template<class F, class G>
    225   class compose_f_gxy : 
     240  class compose_f_gxy :
    226241    public std::binary_function<typename G::first_argument_type,
    227242                                typename G::second_argument_type,
     
    233248     */
    234249    compose_f_gxy(F f, G g)
    235       : f_(f), g_(g) 
     250      : f_(f), g_(g)
    236251    {
    237252      BOOST_CONCEPT_ASSERT((boost::Convertible<typename G::result_type
     
    243258     */
    244259    typename F::result_type
    245     operator()(typename G::first_argument_type x, 
     260    operator()(typename G::first_argument_type x,
    246261               typename G::second_argument_type y) const
    247262    {
     
    267282  {
    268283    return compose_f_gxy<F,G>(f,g);
    269   } 
     284  }
    270285
    271286
     
    283298     - G must be an <a
    284299     href="http://www.sgi.com/tech/stl/AdaptableUnaryFunction.html">
    285      AdaptableUnaryFunction</a> 
     300     AdaptableUnaryFunction</a>
    286301     - \c G::result_type is convertible to \c F::argument_type
    287302
     
    299314     */
    300315    compose_f_gx(F f, G g)
    301       : f_(f), g_(g) 
     316      : f_(f), g_(g)
    302317    {
    303318      BOOST_CONCEPT_ASSERT((boost::Convertible<typename G::result_type
     
    332347  {
    333348    return compose_f_gx<F,G>(f,g);
    334   } 
     349  }
    335350
    336351
     
    412427   */
    413428  template<typename Key, typename InputIterator, typename Comp>
    414   void inverse(InputIterator first, InputIterator last, 
     429  void inverse(InputIterator first, InputIterator last,
    415430               std::multimap<Key, size_t, Comp>& m)
    416431  {
     
    452467     */
    453468    inline bool operator()(T x, T y) const
    454     { 
     469    {
    455470      if (std::isnan(x))
    456471        return false;
     
    466481   */
    467482  template<>
    468   struct less_nan<DataWeight> 
     483  struct less_nan<DataWeight>
    469484    : std::binary_function<DataWeight, DataWeight, bool>
    470485  {
     
    473488     */
    474489    inline bool operator()(const DataWeight& x, const DataWeight& y) const
    475     { 
     490    {
    476491      less_nan<double> compare;
    477492      return compare(x.data(), y.data());
     
    569584                           const std::pair<T1,T2>& y) {
    570585      return ((x.second<y.second) ||
    571               (!(y.second<x.second) && (x.first<y.first))); 
     586              (!(y.second<x.second) && (x.first<y.first)));
    572587    }
    573588  };
     
    581596   */
    582597  template <class Pair>
    583   struct PairFirst 
     598  struct PairFirst
    584599  {
    585600    /**
     
    589604     */
    590605    typedef typename boost::mpl::if_<
    591                   typename boost::is_const<Pair>::type, 
     606                  typename boost::is_const<Pair>::type,
    592607                  typename boost::add_const<typename Pair::first_type>::type&,
    593608                  typename Pair::first_type&>::type result_type;
    594    
     609
    595610    /**
    596611       The argument type is Pair&.
     
    615630   */
    616631  template <class Pair>
    617   struct PairSecond 
     632  struct PairSecond
    618633  {
    619634    /**
     
    623638     */
    624639    typedef typename boost::mpl::if_<
    625                   typename boost::is_const<Pair>::type, 
     640                  typename boost::is_const<Pair>::type,
    626641                  typename boost::add_const<typename Pair::second_type>::type&,
    627642                  typename Pair::second_type&>::type result_type;
    628    
     643
    629644    /**
    630645       The argument type is Pair&.
     
    669684    typedef typename std::iterator_traits<Iter>::reference ref_type;
    670685    typedef typename boost::remove_reference<ref_type>::type val_type;
    671     typedef PairFirst<val_type> PF; 
     686    typedef PairFirst<val_type> PF;
    672687    return boost::transform_iterator<PF, Iter>(i, PF());
    673688  }
     
    700715    typedef typename std::iterator_traits<Iter>::reference ref_type;
    701716    typedef typename boost::remove_reference<ref_type>::type val_type;
    702     typedef PairSecond<val_type> PS; 
     717    typedef PairSecond<val_type> PS;
    703718    return boost::transform_iterator<PS, Iter>(i, PS());
    704719  }
     
    714729     std::vector<MyClass*> vec(18);
    715730     ...
    716      std::sort(vec.begin(), vec.end(), 
     731     std::sort(vec.begin(), vec.end(),
    717732               make_ptr_compare(vec[0], std::greater<MyClass>());
    718733     \endcode
     
    778793    if (iter==m.end()) {
    779794      std::stringstream ss;
    780       ss << "utility::get(const Map&, const Key&): `" 
     795      ss << "utility::get(const Map&, const Key&): `"
    781796         << key << "' not found in map\n";
    782797      throw runtime_error(ss.str());
Note: See TracChangeset for help on using the changeset viewer.