2 This file is a part of libcds - Concurrent Data Structures library
4 (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
6 Source code repo: http://github.com/khizmax/libcds/
7 Download: http://sourceforge.net/projects/libcds/files/
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are met:
12 * Redistributions of source code must retain the above copyright notice, this
13 list of conditions and the following disclaimer.
15 * Redistributions in binary form must reproduce the above copyright notice,
16 this list of conditions and the following disclaimer in the documentation
17 and/or other materials provided with the distribution.
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef CDSUNIT_SET_TEST_SET_DATA_H
32 #define CDSUNIT_SET_TEST_SET_DATA_H
34 #include <cds_test/check_size.h>
35 #include <cds_test/fixture.h>
37 #include <cds/opt/hash.h>
39 // forward declaration
40 namespace cds { namespace container {}}
43 namespace co = cds::opt;
45 class container_set_data : public fixture
48 static size_t const kSize = 1000;
52 unsigned int nFindCount;
53 unsigned int nUpdateNewCount;
54 unsigned int nUpdateCount;
55 mutable unsigned int nEraseCount;
64 memset( this, 0, sizeof( *this ));
71 explicit other_item( int k )
81 struct int_item: public stat
92 explicit int_item( int k )
98 explicit int_item( Q const& src )
103 int_item( int_item const& src )
106 , strVal( src.strVal )
109 int_item( int_item&& src )
112 , strVal( std::move( src.strVal ))
115 int_item( int k, std::string&& s )
118 , strVal( std::move( s ))
121 explicit int_item( other_item const& s )
123 , nVal( s.key() * 2 )
133 size_t operator()( int i ) const
135 return co::v::hash<int>()(i);
137 template <typename Item>
138 size_t operator()( const Item& i ) const
140 return (*this)(i.key());
144 struct simple_item_counter {
147 simple_item_counter()
166 operator size_t() const
175 bool operator ()( int_item const& v1, int_item const& v2 ) const
177 return v1.key() < v2.key();
180 template <typename Q>
181 bool operator ()( int_item const& v1, const Q& v2 ) const
183 return v1.key() < v2;
186 template <typename Q>
187 bool operator ()( const Q& v1, int_item const& v2 ) const
189 return v1 < v2.key();
194 int operator ()( int_item const& v1, int_item const& v2 ) const
196 if ( v1.key() < v2.key())
198 return v1.key() > v2.key() ? 1 : 0;
201 template <typename T>
202 int operator ()( T const& v1, int v2 ) const
206 return v1.key() > v2 ? 1 : 0;
209 template <typename T>
210 int operator ()( int v1, T const& v2 ) const
214 return v1 > v2.key() ? 1 : 0;
219 template <typename Q, typename T>
220 bool operator()( Q const& lhs, T const& rhs ) const
222 return lhs.key() < rhs.key();
227 } // namespace cds_test
229 #endif // CDSUNIT_SET_TEST_SET_DATA_H