[complement-svn] SF.net SVN: complement: [1563] trunk/complement/explore/test/virtual_time
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2007-05-18 07:12:36
|
Revision: 1563 http://svn.sourceforge.net/complement/?rev=1563&view=rev Author: complement Date: 2007-05-18 00:12:34 -0700 (Fri, 18 May 2007) Log Message: ----------- development Modified Paths: -------------- trunk/complement/explore/test/virtual_time/vtime.cc trunk/complement/explore/test/virtual_time/vtime.h Modified: trunk/complement/explore/test/virtual_time/vtime.cc =================================================================== --- trunk/complement/explore/test/virtual_time/vtime.cc 2007-05-18 07:12:09 UTC (rev 1562) +++ trunk/complement/explore/test/virtual_time/vtime.cc 2007-05-18 07:12:34 UTC (rev 1563) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/03/07 15:53:23 ptr> +// -*- C++ -*- Time-stamp: <07/05/17 23:30:42 ptr> #include "vtime.h" @@ -58,6 +58,45 @@ } } +vtime_type operator -( const vtime_type& l, const vtime_type& r ) +{ + if ( r.empty() ) { + return l; + } + + vtime_type vt; + vtime_type::const_iterator i = l.begin(); + vtime_type::const_iterator j = r.begin(); + + while ( i != l.end() && j != r.end() ) { + while ( i->first < j->first && i != l.end() ) { + vt.push_back( make_pair( i->first, i->second ) ); + ++i; + } + + while ( i->first == j->first && i != l.end() && j != r.end() ) { + if ( i->second < j->second ) { + throw range_error( "vtime different: right value grater then left" ); + } + vt.push_back( make_pair( i->first, i->second - j->second ) ); + ++i; + ++j; + } + } + + if ( i == l.end() && j != r.end() ) { + throw range_error( "vtime different: right value grater then left" ); + } + + while ( i != l.end() ) { + vt.push_back( make_pair( i->first, i->second ) ); + ++i; + } + + return vt; +} + + void Proc::mess( const stem::Event_base<vtime>& ev ) { } Modified: trunk/complement/explore/test/virtual_time/vtime.h =================================================================== --- trunk/complement/explore/test/virtual_time/vtime.h 2007-05-18 07:12:09 UTC (rev 1562) +++ trunk/complement/explore/test/virtual_time/vtime.h 2007-05-18 07:12:34 UTC (rev 1563) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/03/06 19:23:37 ptr> +// -*- C++ -*- Time-stamp: <07/05/18 00:26:00 ptr> #ifndef __vtime_h #define __vtime_h @@ -19,13 +19,18 @@ typedef std::pair<stem::addr_type, vtime_unit_type> vtime_proc_type; typedef std::list<vtime_proc_type> vtime_type; +inline bool uorder( const vtime_proc_type& l, const vtime_proc_type& r ) +{ + return l.first < r.first; +} + inline bool operator <( const vtime_proc_type& l, const vtime_proc_type& r ) { if ( l.first == r.first ) { return l.second < r.second; } - throw std::invalid_argument( "uncomparable" ); + throw std::invalid_argument( "uncomparable vtime" ); } inline bool operator <=( const vtime_proc_type& l, const vtime_proc_type& r ) @@ -34,7 +39,7 @@ return l.second <= r.second; } - throw std::invalid_argument( "uncomparable" ); + throw std::invalid_argument( "uncomparable vtime" ); } inline bool operator ==( const vtime_proc_type& l, const vtime_proc_type& r ) @@ -43,10 +48,49 @@ return l.second == r.second; } - throw std::invalid_argument( "uncomparable" ); + throw std::invalid_argument( "uncomparable vtime" ); } +#if 0 +bool operator <=( const vtime_type& l, const vtime_type& r ) +{ + if ( l.size() == 0 ) { // 0 always less or equal of anything + return true; + } + + bool result = true; + vtime_type::const_iterator i = l.begin(); + vtime_type::const_iterator j = r.begin(); + + while ( j->first < i->first && j != r.end() ) { + ++j; + } + + if ( j == r.end() ) { // note, that i != l.end() here! + return false; + } + + for ( ; i != l.end() && j != r.end(); ) { + if ( i->second > j->second ) { + } + + if ( i->first < j->first ) { + ++i; + } else if ( i->first == j->first ) { + if ( i->second > j->second ) { + return false; + } + } else { + ++j; + } + } +} +#endif + + +vtime_type operator -( const vtime_type& l, const vtime_type& r ); + struct vtime : public stem::__pack_base { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |