stlab.adobe.com Adobe Systems Incorporated

random_shuffle.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2005-2007 Adobe Systems Incorporated
00003     Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
00004     or a copy at http://stlab.adobe.com/licenses.html)
00005 */
00006 
00007 /*************************************************************************************************/
00008 
00009 #ifndef ADOBE_ALGORITHM_RANDOM_SHUFFLE_HPP
00010 #define ADOBE_ALGORITHM_RANDOM_SHUFFLE_HPP
00011 
00012 #include <adobe/config.hpp>
00013 
00014 #include <boost/range/begin.hpp>
00015 #include <boost/range/end.hpp>
00016 #include <boost/bind.hpp>
00017 
00018 #include <algorithm>
00019 
00020 /*************************************************************************************************/
00021 
00022 namespace adobe {
00023 
00024 /*************************************************************************************************/
00032 /*************************************************************************************************/
00038 template <class RandomAccessRange>
00039 inline void random_shuffle(RandomAccessRange& range)
00040 {
00041     return std::random_shuffle(boost::begin(range), boost::end(range));
00042 }
00043 
00049 template <class RandomAccessIterator, class RandomNumberGenerator>
00050 inline void
00051 random_shuffle(RandomAccessIterator first, RandomAccessIterator last, RandomNumberGenerator& rand)
00052 {
00053     return std::random_shuffle(first, last, boost::bind(rand, _1));
00054 }
00055 
00061 template <class RandomAccessRange, class RandomNumberGenerator>
00062 inline void random_shuffle(RandomAccessRange& range, RandomNumberGenerator& rand)
00063 {
00064     return adobe::random_shuffle(boost::begin(range), boost::end(range), rand);
00065 }
00066 
00067 /*************************************************************************************************/
00068 
00069 } // namespace adobe
00070 
00071 /*************************************************************************************************/
00072 
00073 #endif
00074 
00075 /*************************************************************************************************/

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google