00001 /* 00002 00003 Copyright (C) 2003-2009 Kevin Thornton, krthornt[]@[]uci.edu 00004 00005 Remove the brackets to email me. 00006 00007 This file is part of libsequence. 00008 00009 libsequence is free software: you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation, either version 3 of the License, or 00012 (at your option) any later version. 00013 00014 libsequence 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 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 long with libsequence. If not, see <http://www.gnu.org/licenses/>. 00021 00022 */ 00023 00024 // Code for the -*- C++ -*- namespace Sequence::PolyTable template members 00025 #ifndef __POLY_TABLE_TCC__ 00026 #define __POLY_TABLE_TCC__ 00027 00028 #include <iterator> 00029 00030 namespace Sequence 00031 { 00032 template<typename numeric_type, 00033 typename string_type> 00034 bool PolyTable::assign( const numeric_type * _positions, 00035 const size_t & _num_positions, 00036 const string_type * _data, 00037 const size_t & _num_individuals ) 00038 { 00039 //The numeric array must be convertible to double 00040 BOOST_STATIC_ASSERT( (boost::is_convertible<numeric_type,double>::value) ); 00041 //The character type must be eithe char * or std::string 00042 BOOST_STATIC_ASSERT( (boost::is_same<string_type,char *>::value || 00043 boost::is_same<string_type,std::string>::value ) ); 00044 00045 positions.resize(_num_positions); 00046 data.resize(_num_individuals); 00047 positions.assign(_positions,_positions+_num_positions); 00048 data.assign(_data,_data+_num_individuals); 00049 non_const_access = true; 00050 for(std::vector<std::string>::const_iterator itr = data.begin() ; 00051 itr < data.end() ; ++itr) 00052 { 00053 if (itr->length() != _num_positions) 00054 { 00055 positions.clear(); 00056 data.clear(); 00057 return false; 00058 } 00059 } 00060 return true; 00061 } 00062 00063 // template<typename iterator> 00064 // bool PolyTable::rear_insert( const iterator beg, 00065 // const iterator end ) 00066 // /*! 00067 // Insert a range of string types (chr * or std::string) 00068 // at the end of a PolyTable object. 00069 // */ 00070 // { 00071 // typedef typename std::iterator_traits<iterator>::value_type vtype; 00072 // BOOST_STATIC_ASSERT( (boost::is_same<vtype,char *>::value || 00073 // boost::is_same<vtype,std::string>::value ) ); 00074 // data.insert(data.end(),beg,end); 00075 // return true; 00076 // } 00077 00078 } 00079 00080 #endif
1.6.1