[complement-svn] SF.net SVN: complement: [1573] trunk/complement/explore/test/virtual_time
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2007-05-29 16:50:33
|
Revision: 1573 http://svn.sourceforge.net/complement/?rev=1573&view=rev Author: complement Date: 2007-05-29 09:50:29 -0700 (Tue, 29 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-28 17:45:58 UTC (rev 1572) +++ trunk/complement/explore/test/virtual_time/vtime.cc 2007-05-29 16:50:29 UTC (rev 1573) @@ -331,7 +331,7 @@ return vt; } -vtime& vtime::operator += ( const vtime_proc_type& t ) +vtime& vtime::operator +=( const vtime_proc_type& t ) { vtime_type::iterator i = vt.begin(); @@ -419,60 +419,28 @@ for ( ; gr != ge; ++gr ) { // over all groups if ( gr->first == mgrp ) { -#if 0 - comp( vt, mgrp, ev.src() ); - comp( vt, mgrp, ev.src() ); - - for ( gvtime_type::const_iterator my_gi = vt.begin(); my_gi != vt.end(); ++my_gi ) { - if ( my_gi->first == mgrp ) { - vtime_type vt_tmp = my_gi->second.vt + gr->second.vt; - for (vtime_type::const_iterator i = vt_tmp.begin(); i != vt_tmp.end(); ++i ) { - if ( i->first == ev.src() ) { - vtime_type::const_iterator j = my_gi->second.vt.begin(); - for ( ; j != my_gi->second.vt.end(); ++j ) { - if ( i->first == j->first ) { - if ( i->second != j->second + 1) { - return false; - } - break; - } + if ( comp( lvt, mgrp, ev.src() ) + 1 != comp( ev.value().gvt.gvt, mgrp, ev.src() ) ) { + return false; + } + for ( gvtime_type::const_iterator i = lvt.begin(); i != lvt.end(); ++i ) { + if ( mgrp == i->first ) { + for ( vtime_type::const_iterator j = ) { + } + } + } + } else { + for ( gvtime_type::const_iterator i = lvt.begin(); i != lvt.end(); ++i ) { + if ( gr->first == i->first ) { + vtime vt_tmp = i->second + gr->second; + for ( gvtime_type::const_iterator j = vt.begin(); j != vt.end(); ++j ) { + if ( i->first == j->first ) { + if ( !(vt_tmp <= j->second) ) { + return false; } - if ( j == my_gi->second.vt.end() ) { - if ( i->second != 1 ) { - return false; - } - } - } else { - if ( ) { - } } } - vtime_type vt_null; - vt_null += make_pair( ev.src(), 1 ); } } - // vtime_group_type vt_tmp = vt + *gr; - // vtime_type vt_tmp = last_vt[ev.value().grp] + gr->second.vt; -#endif - -#if 0 - vtime_type::const_iterator i = vt_tmp.begin(); - if ( vt[mgrp].empty() ) { - vtime vt_null; - vt_null += make_pair( ev.src(), 1 ); - cerr << vt_tmp << vt_null.vt; - return vt_tmp == vt_null.vt; - } else { - vtime_type::const_iterator j = vt[mgrp].begin(); - } -#endif - } else { -#if 0 - vtime_type vt_tmp = last_vt[mgrp] + gr->second.vt; - if ( !(vt_tmp <= vt[mgrp] )) { - return false; - } -#endif } } Modified: trunk/complement/explore/test/virtual_time/vtime.h =================================================================== --- trunk/complement/explore/test/virtual_time/vtime.h 2007-05-28 17:45:58 UTC (rev 1572) +++ trunk/complement/explore/test/virtual_time/vtime.h 2007-05-29 16:50:29 UTC (rev 1573) @@ -6,6 +6,7 @@ #include <algorithm> #include <list> #include <vector> +#include <hash_map> #include <iterator> #include <istream> @@ -20,41 +21,11 @@ typedef stem::addr_type oid_type; typedef unsigned vtime_unit_type; typedef uint32_t group_type; -typedef std::pair<oid_type, vtime_unit_type> vtime_proc_type; -typedef std::list<vtime_proc_type> vtime_type; +typedef std::hash_map<oid_type, vtime_unit_type> vtime_type; -inline bool uorder( const vtime_proc_type& l, const vtime_proc_type& r ) -{ - return l.first < r.first; -} +// typedef std::pair<oid_type, vtime_unit_type> vtime_proc_type; +// typedef std::list<vtime_proc_type> vtime_type; -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 vtime" ); -} - -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 vtime" ); -} - -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 vtime" ); -} - bool operator <=( const vtime_type& l, const vtime_type& r ); vtime_type operator -( const vtime_type& l, const vtime_type& r ); vtime_type operator +( const vtime_type& l, const vtime_type& r ); @@ -113,8 +84,9 @@ vtime_type vt; }; -typedef std::pair<group_type, vtime> vtime_group_type; -typedef std::list<vtime_group_type> gvtime_type; +// typedef std::pair<group_type, vtime> vtime_group_type; +// typedef std::list<vtime_group_type> gvtime_type; +typedef std::hash_map<group_type, vtime_type> gvtime_type; vtime_unit_type comp( const gvtime_type&, group_type, oid_type ); gvtime_type& operator +=( gvtime_type&, const vtime_group_type& ); @@ -188,6 +160,7 @@ }; // vtime_type vt[n_groups]; + gvtime_type lvt; gvtime_type vt; // vtime_type last_vt[n_groups]; // gvtime_type last_vt; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |