selections.hpp

Go to the documentation of this file.
00001 // -*- mode: c++; indent-tabs-mode: nil; -*-
00002 //
00003 //The Biomolecule Toolkit (BTK) is a C++ library for use in the
00004 //modeling, analysis, and design of biological macromolecules.
00005 //Copyright (C) 2006, Chris Saunders <ctsa@users.sourceforge.net>,
00006 //                    Tim Robertson <kid50@users.sourceforge.net>
00007 //
00008 //This program is free software; you can redistribute it and/or modify
00009 //it under the terms of the GNU Lesser General Public License as published
00010 //by the Free Software Foundation; either version 2.1 of the License, or (at
00011 //your option) any later version.
00012 //
00013 //This program is distributed in the hope that it will be useful,  but
00014 //WITHOUT ANY WARRANTY; without even the implied warranty of
00015 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 //Lesser General Public License for more details.
00017 //
00018 //You should have received a copy of the GNU Lesser General Public License
00019 //along with this program; if not, write to the Free Software Foundation,
00020 //Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00021 
00024 
00025 #ifndef BTK_ALGORITHMS_SELECTIONS_HPP
00026 #define BTK_ALGORITHMS_SELECTIONS_HPP
00027 
00028 namespace BTK {
00029 namespace ALGORITHMS {
00030 
00032 
00033 
00041 template <typename Iterator>
00042 void
00043 select(Iterator begin,
00044        Iterator end,
00045        bool select_value = true)
00046 {
00047   for (Iterator i = begin; i != end; ++i)
00048     i->select(select_value);
00049 }
00050 
00060 template <typename Iterator, typename UnaryPredicate>
00061 void
00062 select_if(Iterator begin,
00063           Iterator end,
00064           UnaryPredicate test,
00065           bool select_value = true)
00066 {
00067   for(Iterator i = begin; i != end; ++i) {
00068     if(test(*i)) i->select(select_value);
00069   }
00070 }
00071 
00073 
00074 } // namespace ALGORITHMS
00075 } // namespace BTK
00076 
00077 #endif

Generated on Sun Jul 15 20:46:27 2007 for BTK Core by  doxygen 1.5.1