// (C) Copyright 2008-2009 SDML (www.sdml.info) // // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef SUFFIX_COMPARE_INCLUDED #define SUFFIX_COMPARE_INCLUDED #include #include #include namespace gpld { /** * suffix_compare is a function object that, given the starting index * of two suffices in a string or other iterable container, lexicographically * compares the suffices beginning at each location and returns * true if the first is 'more comparable' than the other. * * @todo 'unsigned int' */ template ::value_type> > class suffix_compare { public: suffix_compare(T const& end); bool operator()(T const& a, T const& b); private: /** This object cannot be default constructed. */ suffix_compare(); /** The end of the range we're comparing. */ T const& _end; /** An instance of the comparison function. */ Comp _comp; }; /** * The constructor takes a beginning and ending iterator. */ template suffix_compare::suffix_compare(T const& end) : _end(end), _comp() { } /** * This function performs a lexicographical comparison between * the suffix starting at 'a' and the suffix starting at 'b,' * and returns true if the suffix starting at 'a' is more * comparable. */ template bool suffix_compare::operator()(T const& a, T const& b) { return std::lexicographical_compare(a, _end, b, _end, _comp); } }; // end of GPLD namespace #endif