Simple Application Framework  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Saf/Algo/Sort/Default.h
Go to the documentation of this file.
00001 /*
00002     This file is part of Simple Application Framework (Saf) library.
00003     Copyright (C) 2010 - 2012 Ondrej Danek <ondrej.danek@gmail.com>
00004 
00005     This library is free software: you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published 
00007     by the Free Software Foundation, either version 3 of the License, or
00008     (at your option) any later version.
00009 
00010     Saf is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with Simple Application Framework library. If not, 
00017     see <http://www.gnu.org/licenses/>.
00018 */
00019 
00028 #ifndef SAF_ALGO_SORT_DEFAULT_H
00029 #define SAF_ALGO_SORT_DEFAULT_H
00030 
00031 #include "IntroSort.h"
00032 #include "MergeSort.h"
00033 
00034 namespace Saf
00035 {
00036     namespace Algo
00037     {        
00038         namespace Sort
00039         {
00055             template <class RanIter, class Pred>
00056             void Sort(RanIter begin, RanIter end, Pred pred)
00057             {
00058                 IntroSort(begin, end, pred);
00059             }
00060 
00075             template <class RanIter>
00076             void Sort(RanIter begin, RanIter end)
00077             {
00078                 Predicate::Less<typename Type::IteratorTraits<RanIter>::ValType> pred;
00079                 Sort(begin, end, pred);
00080             }
00081 
00097             template <class RanIter, class Pred>
00098             void SortStable(RanIter begin, RanIter end, Pred pred)
00099             {
00100                 MergeSortInPlace(begin, end, pred);
00101             }
00102 
00117             template <class RanIter>
00118             void SortStable(RanIter begin, RanIter end)
00119             {
00120                 Predicate::Less<typename Type::IteratorTraits<RanIter>::ValType> pred;
00121                 SortStable(begin, end, pred);
00122             }
00123         }
00124     }
00125 }
00126 
00127 #endif