Claw 1.7.0
max_vector.tpp
Go to the documentation of this file.
00001 /*
00002   CLAW - a C++ Library Absolutely Wonderful
00003 
00004   CLAW is a free library without any particular aim but being useful to 
00005   anyone.
00006 
00007   Copyright (C) 2005-2011 Julien Jorge
00008 
00009   This library is free software; you can redistribute it and/or
00010   modify it under the terms of the GNU Lesser General Public
00011   License as published by the Free Software Foundation; either
00012   version 2.1 of the License, or (at your option) any later version.
00013 
00014   This library is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017   Lesser General Public License for more details.
00018 
00019   You should have received a copy of the GNU Lesser General Public
00020   License along with this library; if not, write to the Free Software
00021   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023   contact: julien.jorge@gamned.org
00024 */
00031 /*---------------------------------------------------------------------------*/
00035 template<typename E, typename Comp, typename Container>
00036 claw::max_vector<E, Comp, Container>::max_vector()
00037 { 
00038 
00039 } // max_vector::max_vector()
00040 
00041 /*---------------------------------------------------------------------------*/
00046 template <typename E, typename Comp, typename Container>
00047 claw::max_vector<E, Comp, Container>::max_vector(const value_type& e)
00048 { 
00049   add(e);
00050 } // max_vector::max_vector()
00051 
00052 /*---------------------------------------------------------------------------*/
00057 template <typename E, typename Comp, typename Container>
00058 void claw::max_vector<E, Comp, Container>::add(const value_type& e)
00059 {
00060   if (m_values.empty())
00061     *std::inserter(m_values, m_values.end()) = e;
00062   else
00063     {
00064       comparator_type comp;
00065       if ( comp(m_values.front(), e) )
00066   {
00067     m_values.clear();
00068     *std::inserter(m_values, m_values.end()) = e;
00069   }
00070       else if ( !comp(e, m_values.front()) )
00071   *std::inserter(m_values, m_values.end()) = e;
00072     }
00073 } // max_vector::add()
00074 
00075 /*---------------------------------------------------------------------------*/
00079 template <typename E, typename Comp, typename Container>
00080 const typename claw::max_vector<E, Comp, Container>::container_type&
00081 claw::max_vector<E, Comp, Container>::get_v() const 
00082 { 
00083   return m_values; 
00084 } // max_vector::get_v()