Biorithm  1.1
 All Classes Functions Variables Typedefs Friends
graph-global.h
00001 /**************************************************************************
00002  * Copyright (c) 2002-2011 T. M. Murali                                   *
00003  *                                                                        *
00004  * This file is part of Biorithm.                                         *
00005  *                                                                        *
00006  * Biorithm is free software: you can redistribute it and/or modify       *
00007  * it under the terms of the GNU General Public License as published by   *
00008  * the Free Software Foundation, either version 3 of the License, or      *
00009  * (at your option) any later version.                                    *
00010  *                                                                        *
00011  * Biorithm is distributed in the hope that it will be useful,            *
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00014  * GNU General Public License for more details.                           *
00015  *                                                                        *
00016  * You should have received a copy of the GNU General Public License      *
00017  * along with Biorithm.  If not, see <http://www.gnu.org/licenses/>.      *
00018  *                                                                        *
00019  **************************************************************************/
00020 
00028 #ifndef _GRAPH_GLOBAL_H
00029 #define _GRAPH_GLOBAL_H
00030 
00031 #include <iostream>
00032 #include <map>
00033 #include <vector>
00034 #include <set>
00035 
00036 using namespace std;
00037 
00038 // print a vector to an output stream
00039 template < class T >
00040 ostream &operator<<(ostream &ostr, const vector< T > &items)
00041 {
00042 //  copy(items.begin(), items.end(), ostream_iterator< T >(ostr, " "));
00043   typename vector< T >::const_iterator itr;
00044   for (itr = items.begin(); itr != items.end(); itr++)
00045     ostr << *itr << " ";
00046   return(ostr);
00047 }
00048 
00049 
00050 template <class T>
00051 ostream& operator<<(ostream& ostr, set< T > s)
00052 {
00053   typename set< T >::const_iterator itr;
00054   
00055   for (itr = s.begin(); itr != s.end(); itr++)
00056     ostr << *itr << " ";
00057   return(ostr);
00058 }
00059 
00060 template <class T, class U>
00061 ostream& operator<<(ostream& ostr, map< T, U > m)
00062 {
00063   typename map< T, U >::iterator itr;
00064   
00065   for (itr = m.begin(); itr != m.end(); itr++)
00066     ostr << (*itr).first << " (" << (*itr).second << ") ";
00067   return(ostr);
00068 }
00069 
00070 // to keep this typedef consistent with xMotif.
00071 typedef double MyNT;
00072 
00073 // return true if text matches a non-space character. trying this
00074 // function to see if is faster than perl_match(text, "m/\\S/").
00075 inline bool matches_non_space(string text)
00076 {
00077   for (unsigned int i = 0; i < text.length(); i++)
00078     if (!isspace(text[i]))
00079       return(true);
00080   // all characters match whitespace.
00081   return(false);
00082 }
00083 
00084 
00085 
00086 #endif // _GRAPH_GLOBAL_H 
 All Classes Functions Variables Typedefs Friends