spvecgf2.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: spvecgf2.h 6955 2008-04-09 14:16:54Z dmichail $ 
00034 //
00035 
00040 #ifndef SPVECGF2_H
00041 #define SPVECGF2_H
00042 
00043 #include <iostream>
00044 #include <LEP/mcb/config.h>
00045 
00046 #ifdef LEDA_GE_V5
00047 #include <LEDA/system/basic.h>
00048 #include <LEDA/core/list.h>
00049 #include <LEDA/core/d_int_set.h>
00050 #include <LEDA/system/error.h>
00051 #include <LEDA/system/assert.h>
00052 #else
00053 #include <LEDA/basic.h>
00054 #include <LEDA/list.h>
00055 #include <LEDA/d_int_set.h>
00056 #include <LEDA/error.h>
00057 #include <LEDA/assert.h>
00058 #endif
00059 #include <LEP/mcb/edge_num.h>
00060 #include <LEP/mcb/arithm.h>
00061 
00062 namespace mcb
00063 {
00064 
00065 #if defined(LEDA_NAMESPACE)
00066     using leda::list;
00067     using leda::list_item;
00068     using leda::error_handler;
00069     using leda::d_int_set;
00070 #endif
00071 
00072 
00115     class spvecgf2
00116     {
00117         public:
00119 
00120             spvecgf2();
00121 
00123             spvecgf2( const spvecgf2 & a );
00124 
00125             explicit spvecgf2( const int& i );
00126 
00128             ~spvecgf2(  );
00130 
00131 
00133 
00137             spvecgf2& operator=( const spvecgf2& i );
00138 
00140             spvecgf2& operator=( const int& i );
00141 
00146 #if (__LEDA__ >= 500)
00147             spvecgf2& operator=( const d_int_set& i );
00148 #else
00149             spvecgf2& operator=( d_int_set& i );
00150 #endif
00151 
00155             spvecgf2 operator-(  ) const;
00156 
00162             int operator*( const spvecgf2& a ) const;
00163 
00169             spvecgf2 operator+( const spvecgf2& a ) const;
00170 
00175             void add( const spvecgf2& a ); 
00176 
00183             spvecgf2 operator%( const spvecgf2& a ) const;
00184 
00190             d_int_set operator%( const d_int_set& a ) const;
00191 
00197             spvecgf2 intersect( const spvecgf2& a ) const;
00198 
00204             spvecgf2& operator+=( const spvecgf2& a );
00205 
00212             spvecgf2& operator-=( const spvecgf2& a );
00213 
00220             spvecgf2& operator%=( const spvecgf2& a );
00221 
00226             void swap( spvecgf2& a );
00228 
00230 
00233             d_int_set to_d_int_set() const;
00234 
00238             list<int> to_list() const { return l; }
00240 
00242 
00243             void clear( ) { l.clear(); }
00244 
00248             void print( std::ostream & o ) const;
00249 
00258             void append( int index );
00259 
00268             void insert( int index );
00269 
00274             int pop() { return l.pop(); }
00275 
00281             void sort() { l.sort(); }
00282 
00283             // define access stuff, like leda lists
00284 
00288             bool empty() const { return l.empty(); }
00289 
00293             int size(  ) const { return l.size(); }
00295 
00297 
00303             list_item first(  ) const { return l.first(); }
00304 
00311             list_item last(  ) const { return l.last(); }
00312 
00318             list_item succ( list_item it ) const { return l.succ(it); }
00319 
00325             list_item pred( list_item it ) const { return l.pred(it); }
00326 
00332             int index( list_item it ) const { return l.contents(it); }
00333 
00339             int inf( list_item it ) const { return l.contents(it); }
00340 
00341             // allow the LEDA forall() macro to work
00342             typedef list_item item;
00343 
00344             item first_item()       const { return l.first(); }
00345             item last_item()        const { return l.last(); }
00346             item next_item(item it) const { return it ? l.succ(it) : 0; }
00348 
00349         private:
00350 
00351             list < int > l;
00352     };
00353 
00359     std::ostream & operator<<( std::ostream & o, const spvecgf2& v );
00360 
00366     std::istream & operator>>( std::istream & o, spvecgf2& v );
00367 
00368 
00369 }
00370 
00371 // helper swap
00372 namespace std { 
00373     template<>
00374     void swap<mcb::spvecgf2>( mcb::spvecgf2& a, mcb::spvecgf2& b );
00375 }
00376    
00377 
00378 #endif
00379 
00380 /* ex: set ts=4 sw=4 sts=4 et: */
00381 
00382 

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