00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
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
00113
00114 spvecfp& operator=( const spvecfp& i );
00115
00116
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
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
00234 list< entry > l;
00235 ptype p;
00236
00237
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 }
00252
00253 #endif // SPVECFP_H
00254