Go to Overview over all GrAL packages.
Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Container/some-algorithms.h

Go to the documentation of this file.
00001 #ifndef NMWR_CONTAINER_ALGORITHMS_H
00002 #define NMWR_CONTAINER_ALGORITHMS_H
00003 
00004 
00005 // $LICENSE
00006 
00007 
00012 template<class InputIt>
00013 inline
00014 InputIt next(InputIt i)
00015 { ++i; return i;}
00016 
00017 template<class InputIt>
00018 inline
00019 InputIt next(InputIt i, unsigned n)
00020 { 
00021   while(n > 0) {
00022     ++i; 
00023     --n;
00024   }
00025   return i;
00026 }
00027 
00039 template<class InputIt, class OutputIt, class Filter>
00040 inline
00041 OutputIt copy_filter(InputIt b, InputIt e, OutputIt dest, Filter f)
00042 {
00043   while( b != e) {
00044     *dest = f(*b);
00045     ++b; ++dest;
00046   }
00047   return dest;
00048 }
00049 
00059 template<class FwdIt, class P1, class P2>
00060 inline
00061 FwdIt find_if_preference(FwdIt b, FwdIt e, const P1& must_be, const P2& should_be)
00062 {
00063   FwdIt found = e;
00064   while( b != e) {
00065     if(must_be(*b)) {
00066      if(should_be(*b))
00067        return b;
00068      else
00069        found = b;
00070     }
00071     ++b;
00072   }
00073   return found;
00074 }
00075 
00086 template<class M1, class M2>
00087 void mapping_assign(M1& dest, M2 const& src)
00088 {
00089   typedef typename M2::domain_type dom_type;
00090   typedef typename dom_type::const_iterator dom_iter;
00091   dom_iter end = src.domain().end();
00092   for(dom_iter d = src.domain().begin(); d != end; ++d)
00093     dest[*d] = src[*d];
00094 }
00095 
00096 #endif
00097 

Copyright (c) Guntram Berti 1997-2002. See the GrAL Homepage for up-to-date information.

Generated at Tue Feb 26 15:57:14 2002 for Sequence by doxygen 1.2.11-20011104 written by Dimitri van Heesch, © 1997-2000