OKlibrary  0.2.1.6
OrderConstructions.hpp
Go to the documentation of this file.
00001 // Oliver Kullmann, 2.7.2005 (Swansea)
00002 /* Copyright 2005 - 2007, 2009, 2010 Oliver Kullmann
00003 This file is part of the OKlibrary. OKlibrary is free software; you can redistribute
00004 it and/or modify it under the terms of the GNU General Public License as published by
00005 the Free Software Foundation and included in this library; either version 3 of the
00006 License, or any later version. */
00007 
00013 #ifndef ORDERCONSTRUCTIONS_jdjJn6
00014 #define ORDERCONSTRUCTIONS_jdjJn6
00015 
00016 #include <functional>
00017 #include <algorithm>
00018 
00019 #include <boost/functional.hpp>
00020 
00021 namespace OKlib {
00022  namespace Programming {
00023   namespace Utilities {
00024    namespace OrderRelations {
00025 
00037      template <class LessThanRelation>
00038      struct SizeLessThan : std::binary_function<
00039        typename boost::binary_traits<LessThanRelation>::first_argument_type,
00040        typename boost::binary_traits<LessThanRelation>::second_argument_type,
00041        bool> {
00042        bool operator() (const typename boost::binary_traits<LessThanRelation>::first_argument_type& arg1, const typename boost::binary_traits<LessThanRelation>::second_argument_type& arg2) const {
00043          typedef typename boost::binary_traits<LessThanRelation>::first_argument_type first_argument_type;
00044          typedef typename boost::binary_traits<LessThanRelation>::second_argument_type second_argument_type;
00045          typedef typename first_argument_type::size_type first_size_type;
00046          typedef typename second_argument_type::size_type second_size_type;
00047          const first_size_type& size1(arg1.size());
00048          const second_size_type& size2(arg2.size());
00049          return size1 < size2 or (size1 == size2 and LessThanRelation()(arg1, arg2));
00050        }
00051      };
00052 
00064      template <class Container>
00065      struct Colexicographical_comparison : std::binary_function<
00066        const Container&, const Container&, bool> {
00067        bool operator() (const Container& A, const Container& B) const {
00068          return std::lexicographical_compare(A.rbegin(),A.rend(),B.rbegin(),B.rend());
00069        }
00070      };
00071 
00072     }
00073    }
00074   }
00075 }
00076 
00077 #endif