X-Git-Url: http://plrg.eecs.uci.edu/git/?p=libcds.git;a=blobdiff_plain;f=test%2Fstress%2Fset%2Fset_type.h;h=3d0edd7c5730f08b99fad774106b2b0cea958b57;hp=3d84ff2f6b12885edd5017a21070f914bd558385;hb=1011e89e24d83d53642754691fade33ce8ca5c29;hpb=c625ef0eddef4f5c21cb567b3f57de380f7ec838 diff --git a/test/stress/set/set_type.h b/test/stress/set/set_type.h index 3d84ff2f..3d0edd7c 100644 --- a/test/stress/set/set_type.h +++ b/test/stress/set/set_type.h @@ -5,7 +5,7 @@ Source code repo: http://github.com/khizmax/libcds/ Download: http://sourceforge.net/projects/libcds/files/ - + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -25,7 +25,7 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef CDSUNIT_SET_TYPE_H @@ -47,23 +47,23 @@ namespace set { namespace cc = cds::container; namespace co = cds::opt; - typedef cds::urcu::gc< cds::urcu::general_instant<> > rcu_gpi; - typedef cds::urcu::gc< cds::urcu::general_buffered<> > rcu_gpb; - typedef cds::urcu::gc< cds::urcu::general_threaded<> > rcu_gpt; + typedef cds::urcu::gc< cds::urcu::general_instant_stripped > rcu_gpi; + typedef cds::urcu::gc< cds::urcu::general_buffered_stripped > rcu_gpb; + typedef cds::urcu::gc< cds::urcu::general_threaded_stripped > rcu_gpt; #ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED - typedef cds::urcu::gc< cds::urcu::signal_buffered<> > rcu_shb; - typedef cds::urcu::gc< cds::urcu::signal_threaded<> > rcu_sht; + typedef cds::urcu::gc< cds::urcu::signal_buffered_stripped > rcu_shb; + typedef cds::urcu::gc< cds::urcu::signal_threaded_stripped > rcu_sht; #endif template struct less; template - struct cmp + struct cmp { int operator ()(Key const& k1, Key const& k2) const { - if ( less( k1, k2 ) ) + if ( less( k1, k2 )) return -1; return less( k2, k1 ) ? 1 : 0; } @@ -83,6 +83,17 @@ namespace set { CDSUNIT_INT_COMPARE(unsigned long long); #undef CDSUNIT_INT_COMPARE +#define CDSUNIT_INT_LESS(t) template <> struct less { bool operator()( t k1, t k2 ){ return k1 < k2; } } + CDSUNIT_INT_LESS( char ); + CDSUNIT_INT_LESS( unsigned char ); + CDSUNIT_INT_LESS( int ); + CDSUNIT_INT_LESS( unsigned int ); + CDSUNIT_INT_LESS( long ); + CDSUNIT_INT_LESS( unsigned long ); + CDSUNIT_INT_LESS( long long ); + CDSUNIT_INT_LESS( unsigned long long ); +#undef CDSUNIT_INT_LESS + template <> struct cmp { @@ -100,6 +111,64 @@ namespace set { } }; + template <> + struct less + { + bool operator ()( std::string const& k1, std::string const& k2 ) const + { + return cmp()( k1, k2 ) < 0; + } + bool operator ()( std::string const& k1, char const* k2 ) const + { + return cmp()( k1, k2 ) < 0; + } + bool operator ()( char const* k1, std::string const& k2 ) const + { + return cmp()( k1, k2 ) < 0; + } + }; + + template + struct hash + { + typedef size_t result_type; + typedef T argument_type; + + size_t operator()( T const& k ) const + { + return std::hash()(k.nKey); + } + + size_t operator()( size_t k ) const + { + return std::hash()(k); + } + }; + + template <> + struct hash + { + typedef size_t result_type; + typedef size_t argument_type; + + size_t operator()( size_t k ) const + { + return std::hash()(k); + } + }; + + template <> + struct hash + { + typedef size_t result_type; + typedef std::string argument_type; + + size_t operator()( std::string const& k ) const + { + return std::hash()(k); + } + }; + // forward template struct set_type; @@ -114,7 +183,7 @@ namespace set { key_type key; value_type val; - /*explicit*/ key_val( key_type const& k ): key(k), val() {} + explicit key_val( key_type const& k ): key(k), val() {} key_val( key_type const& k, value_type const& v ): key(k), val(v) {} template @@ -220,9 +289,17 @@ namespace set { // print_stat // ************************************************* + struct empty_stat {}; + static inline cds_test::property_stream& operator <<( cds_test::property_stream& o, empty_stat const& ) + { + return o; + } + template - static inline void print_stat( cds_test::property_stream&, Set const& /*s*/ ) - {} + static inline void print_stat( cds_test::property_stream& o, Set const& s ) + { + o << s.statistics(); + } //*******************************************************