spvecfp.h

Go to the documentation of this file.
00001 
00002 //
00003 // This program can be freely used in an academic environment
00004 // ONLY for research purposes, subject to the following restrictions:
00005 //
00006 // 1. The origin of this software must not be misrepresented; you must not
00007 //    claim that you wrote the original software. If you use this software
00008 //    an acknowledgment in the product documentation is required.
00009 // 2. Altered source versions must be plainly marked as such, and must not be
00010 //    misrepresented as being the original software.
00011 // 3. This notice may not be removed or altered from any source distribution.
00012 //
00013 // Any other use is strictly prohibited by the author, without an explicit 
00014 // permission.
00015 //
00016 // Note that this program uses the LEDA library, which is NOT free. For more 
00017 // details visit Algorithmic Solutions at http://www.algorithmic-solutions.com/
00018 // There is also a free version of LEDA 6.0 or newer.
00019 //
00020 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
00021 // ! Any commercial use of this software is strictly !
00022 // ! prohibited without explicit permission by the   !
00023 // ! author.                                         !
00024 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
00025 //
00026 // This software is distributed in the hope that it will be useful,
00027 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00028 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00029 //
00030 // Copyright (C) 2004-2008 - Dimitris Michail <dmixdim@googlemail.com>
00031 // Copyright (C) 2004-2008 - Dimitris Michail <michail@mpi-inf.mpg.de>
00032 //
00033 // $Id: spvecfp.h 6773 2008-02-19 18:20:57Z dmichail $ 
00034 //
00035 
00040 #ifndef SPVECFP_H
00041 #define SPVECFP_H
00042 
00043 #include <LEP/mcb/config.h>
00044 #include <iostream>
00045 
00046 #ifdef LEDA_GE_V5
00047 #include <LEDA/core/array.h>
00048 #include <LEDA/core/list.h>
00049 #include <LEDA/core/tuple.h>
00050 #include <LEDA/system/error.h>
00051 #include <LEDA/system/assert.h>
00052 #else
00053 #include <LEDA/array.h>
00054 #include <LEDA/list.h>
00055 #include <LEDA/tuple.h>
00056 #include <LEDA/error.h>
00057 #include <LEDA/assert.h>
00058 #endif
00059 
00060 #include <LEP/mcb/edge_num.h>
00061 #include <LEP/mcb/arithm.h>
00062 
00063 namespace mcb { 
00064 
00065 #if defined(LEDA_NAMESPACE)
00066     using leda::list;
00067     using leda::list_item;
00068     using leda::error_handler;
00069     using leda::two_tuple;
00070     using leda::three_tuple;
00071     using leda::array;
00072 #endif
00073 
00074     
00090     class spvecfp { 
00091         
00092         public:
00093 
00095         spvecfp();
00099         spvecfp( const ptype& p );
00100         
00102         spvecfp( const spvecfp& a );
00103 
00105         ~spvecfp();
00106 
00110         void reset( const ptype& p );
00111 
00112         // assign a vector to the current vector
00113         // cast between types, retain the current's vector type
00114         spvecfp& operator=( const spvecfp& i );
00115 
00116         // assign current vector to e_i
00117         spvecfp& operator=( const indextype& i );
00118 
00122         spvecfp operator-() const;
00123 
00128         ptype operator*( const spvecfp& a ) const;
00129 
00134         spvecfp operator+( const spvecfp& a ) const;
00135 
00140         spvecfp operator*( const ptype& a );
00141 
00146         spvecfp& operator+=( const spvecfp& a );
00147 
00152         spvecfp& operator-=( const spvecfp& a );
00153 
00157         void print( std::ostream& o ) const;
00158 
00168         void append( indextype index, const ptype& value );
00169 
00174         void sort();
00175 
00176         // define access stuff, like leda lists
00177 
00181         bool empty() const;
00182 
00184         void clear();
00185 
00189         indextype size() const;
00190 
00194         ptype pvalue() const;
00195 
00200         list_item first() const;
00201         
00206         list_item last() const;
00207 
00212         list_item succ( list_item it ) const;
00213 
00218         list_item pred( list_item it ) const;
00219 
00223         indextype index( list_item it ) const;
00224 
00228         ptype inf( list_item it ) const;
00229 
00230         private:
00231 
00232         typedef two_tuple<indextype,ptype> entry;
00233         // list of tuples (tuple = < index, value >)
00234         list< entry > l;
00235         ptype p;
00236 
00237         // compare two entries of a spvecfp
00238         static inline int compare( const entry& a, const entry& b ) {
00239             return leda::compare( a.first(), b.first() );
00240         }
00241     };
00242 
00248     std::ostream& operator<<( std::ostream& o, const spvecfp& v );
00249 
00250 
00251 } // end of mcb namespace
00252 
00253 #endif // SPVECFP_H
00254 

Generated on Tue Apr 22 13:40:09 2008 for mcb LEDA Extension Package by  doxygen 1.4.6