2 This file is a part of libcds - Concurrent Data Structures library
4 (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
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 #include "test_intrusive_set.h"
33 #include <cds/intrusive/cuckoo_set.h>
36 namespace ci = cds::intrusive;
38 class IntrusiveCuckooSet : public cds_test::intrusive_set
41 typedef cds_test::intrusive_set base_class;
43 typedef base_class::hash_int hash1;
45 struct hash2: private hash1
47 typedef hash1 base_class;
49 size_t operator()( int i ) const
51 size_t h = ~(base_class::operator()( i ));
52 return ~h + 0x9e3779b9 + (h << 6) + (h >> 2);
54 template <typename Item>
55 size_t operator()( const Item& i ) const
57 size_t h = ~(base_class::operator()( i ));
58 return ~h + 0x9e3779b9 + (h << 6) + (h >> 2);
65 void operator ()( T * p )
71 template <typename Set>
74 // Precondition: set is empty
75 // Postcondition: set is empty
77 base_class::test_< Set::c_isSorted>( s );
79 ASSERT_TRUE( s.empty() );
80 ASSERT_CONTAINER_SIZE( s, 0 );
82 typedef typename Set::value_type value_type;
84 std::vector< value_type > data;
85 std::vector< size_t> indices;
86 data.reserve( kSize );
87 indices.reserve( kSize );
88 size_t const nSetSize = kSize;
89 for ( size_t key = 0; key < kSize; ++key ) {
90 data.push_back( value_type( static_cast<int>(key) ) );
91 indices.push_back( key );
93 shuffle( indices.begin(), indices.end() );
96 for ( auto& i : data ) {
98 ASSERT_TRUE( s.insert( i ) );
100 ASSERT_FALSE( s.empty() );
101 ASSERT_CONTAINER_SIZE( s, nSetSize );
103 s.clear_and_dispose( disposer2());
105 ASSERT_TRUE( s.empty() );
106 ASSERT_CONTAINER_SIZE( s, 0 );
107 for ( auto& i : data ) {
108 EXPECT_EQ( i.nDisposeCount, 0 );
109 EXPECT_EQ( i.nEraseCount, 1 );
122 //************************************************************
125 TEST_F( IntrusiveCuckooSet, striped_list_basehook_unordered )
127 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 > > item_type;
128 struct set_traits: public ci::cuckoo::traits
130 typedef cds::opt::hash_tuple< hash1, hash2 > hash;
131 typedef base_class::equal_to<item_type> equal_to;
132 typedef mock_disposer disposer;
134 typedef ci::CuckooSet< item_type, set_traits > set_type;
140 TEST_F( IntrusiveCuckooSet, striped_vector_basehook_unordered )
142 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<4>, 0 >> item_type;
143 struct set_traits: public ci::cuckoo::traits
145 typedef ci::cuckoo::base_hook< ci::cuckoo::probeset_type< item_type::probeset_type >> hook;
146 typedef cds::opt::hash_tuple< hash1, hash2 > hash;
147 typedef base_class::equal_to<item_type> equal_to;
148 typedef mock_disposer disposer;
150 typedef ci::CuckooSet< item_type, set_traits > set_type;
156 TEST_F( IntrusiveCuckooSet, striped_list_basehook_ordered_cmp )
158 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type;
160 typedef ci::CuckooSet< item_type
161 ,ci::cuckoo::make_traits<
162 ci::opt::hook< ci::cuckoo::base_hook<
163 ci::cuckoo::probeset_type< item_type::probeset_type >
165 ,ci::opt::hash< std::tuple< hash1, hash2 > >
166 ,ci::opt::compare< cmp<item_type> >
167 ,ci::opt::disposer< mock_disposer >
171 set_type s( 32, 6, 4 );
175 TEST_F( IntrusiveCuckooSet, striped_vector_basehook_ordered_cmp )
177 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<8>, 0 >> item_type;
179 typedef ci::CuckooSet< item_type
180 ,ci::cuckoo::make_traits<
181 ci::opt::hook< ci::cuckoo::base_hook<
182 ci::cuckoo::probeset_type< item_type::probeset_type >
184 ,ci::opt::hash< std::tuple< hash1, hash2 > >
185 ,ci::opt::compare< cmp<item_type> >
186 , ci::opt::disposer< mock_disposer >
190 typename set_type::hash_tuple_type ht;
195 TEST_F( IntrusiveCuckooSet, striped_list_basehook_ordered_less )
197 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type;
199 typedef ci::CuckooSet< item_type
200 ,ci::cuckoo::make_traits<
201 ci::opt::hook< ci::cuckoo::base_hook<
202 ci::cuckoo::probeset_type< item_type::probeset_type >
204 ,ci::opt::hash< std::tuple< hash1, hash2 > >
205 ,ci::opt::less< less<item_type> >
206 , ci::opt::disposer< mock_disposer >
210 typename set_type::hash_tuple_type ht;
211 set_type s( 32, 6, 4, ht );
215 TEST_F( IntrusiveCuckooSet, striped_vector_basehook_ordered_less )
217 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type;
219 typedef ci::CuckooSet< item_type
220 ,ci::cuckoo::make_traits<
221 ci::opt::hook< ci::cuckoo::base_hook<
222 ci::cuckoo::probeset_type< item_type::probeset_type >
224 ,ci::opt::hash< std::tuple< hash1, hash2 > >
225 ,ci::opt::less< less<item_type> >
226 ,ci::opt::disposer< mock_disposer >
230 typename set_type::hash_tuple_type ht;
231 set_type s( std::move( ht ));
235 TEST_F( IntrusiveCuckooSet, striped_list_basehook_ordered_cmpmix )
237 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type;
239 typedef ci::CuckooSet< item_type
240 ,ci::cuckoo::make_traits<
241 ci::opt::hook< ci::cuckoo::base_hook<
242 ci::cuckoo::probeset_type< item_type::probeset_type >
244 ,ci::opt::hash< std::tuple< hash1, hash2 > >
245 ,ci::opt::less< less<item_type> >
246 ,ci::opt::compare< cmp<item_type> >
247 ,ci::opt::disposer< mock_disposer >
251 typename set_type::hash_tuple_type ht;
252 set_type s( 32, 6, 0, std::move( ht ));
256 TEST_F( IntrusiveCuckooSet, striped_vector_basehook_ordered_cmpmix )
258 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type;
260 typedef ci::CuckooSet< item_type
261 ,ci::cuckoo::make_traits<
262 ci::opt::hook< ci::cuckoo::base_hook<
263 ci::cuckoo::probeset_type< item_type::probeset_type >
265 ,ci::opt::hash< std::tuple< hash1, hash2 > >
266 ,ci::opt::less< less<item_type> >
267 ,ci::opt::compare< cmp<item_type> >
268 ,ci::opt::disposer< mock_disposer >
272 typename set_type::hash_tuple_type ht;
273 set_type s( std::move( ht ));
277 TEST_F( IntrusiveCuckooSet, striped_list_basehook_ordered_stat )
279 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type;
281 typedef ci::CuckooSet< item_type
282 ,ci::cuckoo::make_traits<
283 ci::opt::hook< ci::cuckoo::base_hook<
284 ci::cuckoo::probeset_type< item_type::probeset_type >
286 ,ci::opt::hash< std::tuple< hash1, hash2 > >
287 ,ci::opt::less< less<item_type> >
288 ,ci::opt::compare< cmp<item_type> >
289 ,ci::opt::stat< ci::cuckoo::stat >
290 ,ci::opt::disposer< mock_disposer >
298 TEST_F( IntrusiveCuckooSet, striped_vector_basehook_ordered_stat )
300 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type;
302 typedef ci::CuckooSet< item_type
303 ,ci::cuckoo::make_traits<
304 ci::opt::hook< ci::cuckoo::base_hook<
305 ci::cuckoo::probeset_type< item_type::probeset_type >
307 ,ci::opt::hash< std::tuple< hash1, hash2 > >
308 ,ci::opt::less< less<item_type> >
309 ,ci::opt::compare< cmp<item_type> >
310 ,ci::opt::stat< ci::cuckoo::stat >
311 ,ci::opt::disposer< mock_disposer >
319 TEST_F( IntrusiveCuckooSet, striped_list_basehook_unordered_storehash )
321 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 2 >> item_type;
322 struct set_traits: public ci::cuckoo::traits
324 typedef ci::cuckoo::base_hook<
325 ci::cuckoo::probeset_type< item_type::probeset_type >
326 ,ci::cuckoo::store_hash< item_type::hash_array_size >
328 typedef cds::opt::hash_tuple< hash1, hash2 > hash;
329 typedef base_class::equal_to<item_type> equal_to;
330 typedef mock_disposer disposer;
331 typedef ci::cuckoo::stat stat;
333 typedef ci::CuckooSet< item_type, set_traits > set_type;
339 TEST_F( IntrusiveCuckooSet, striped_vector_basehook_unordered_storehash )
341 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<4>, 2 >> item_type;
342 struct set_traits: public ci::cuckoo::traits
344 typedef ci::cuckoo::base_hook<
345 ci::cuckoo::probeset_type< item_type::probeset_type >
346 ,ci::cuckoo::store_hash< item_type::hash_array_size >
348 typedef cds::opt::hash_tuple< hash1, hash2 > hash;
349 typedef base_class::equal_to<item_type> equal_to;
350 typedef mock_disposer disposer;
351 typedef ci::cuckoo::stat stat;
353 typedef ci::CuckooSet< item_type, set_traits > set_type;
359 TEST_F( IntrusiveCuckooSet, striped_list_basehook_ordered_storehash )
361 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 2 >> item_type;
363 typedef ci::CuckooSet< item_type
364 ,ci::cuckoo::make_traits<
365 ci::opt::hook< ci::cuckoo::base_hook<
366 ci::cuckoo::probeset_type< item_type::probeset_type >
367 ,ci::cuckoo::store_hash< item_type::hash_array_size >
369 ,cds::opt::hash< std::tuple< hash1, hash2 > >
370 ,cds::opt::less< less<item_type> >
371 ,cds::opt::compare< cmp<item_type> >
372 ,ci::opt::disposer< mock_disposer >
376 typename set_type::hash_tuple_type ht;
377 set_type s( 32, 6, 0, std::move( ht ));
381 TEST_F( IntrusiveCuckooSet, striped_vector_basehook_ordered_storehash )
383 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 2 >> item_type;
385 typedef ci::CuckooSet< item_type
386 ,ci::cuckoo::make_traits<
387 ci::opt::hook< ci::cuckoo::base_hook<
388 ci::cuckoo::probeset_type< item_type::probeset_type >
389 ,ci::cuckoo::store_hash< item_type::hash_array_size >
391 ,cds::opt::hash< std::tuple< hash1, hash2 > >
392 ,cds::opt::less< less<item_type> >
393 ,cds::opt::compare< cmp<item_type> >
394 ,ci::opt::disposer< mock_disposer >
398 typename set_type::hash_tuple_type ht;
399 set_type s( std::move( ht ));
403 //************************************************************
404 // striped member hook
406 TEST_F( IntrusiveCuckooSet, striped_list_memberhook_unordered )
408 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 > > item_type;
409 struct set_traits: public ci::cuckoo::traits
411 typedef ci::cuckoo::member_hook< offsetof( item_type, hMember )> hook;
412 typedef cds::opt::hash_tuple< hash1, hash2 > hash;
413 typedef base_class::equal_to<item_type> equal_to;
414 typedef mock_disposer disposer;
416 typedef ci::CuckooSet< item_type, set_traits > set_type;
422 TEST_F( IntrusiveCuckooSet, striped_vector_memberhook_unordered )
424 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<4>, 0 >> item_type;
425 struct set_traits: public ci::cuckoo::traits
428 typedef ci::cuckoo::member_hook< offsetof( item_type, hMember ), ci::cuckoo::probeset_type< item_type::member_type::probeset_type >> hook;
429 typedef cds::opt::hash_tuple< hash1, hash2 > hash;
430 typedef base_class::equal_to<item_type> equal_to;
431 typedef mock_disposer disposer;
433 typedef ci::CuckooSet< item_type, set_traits > set_type;
439 TEST_F( IntrusiveCuckooSet, striped_list_memberhook_ordered_cmp )
441 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type;
443 typedef ci::CuckooSet< item_type
444 ,ci::cuckoo::make_traits<
445 ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ),
446 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
448 ,ci::opt::hash< std::tuple< hash1, hash2 > >
449 ,ci::opt::compare< cmp<item_type> >
450 ,ci::opt::disposer< mock_disposer >
454 set_type s( 32, 6, 4 );
458 TEST_F( IntrusiveCuckooSet, striped_vector_memberhook_ordered_cmp )
460 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<8>, 0 >> item_type;
462 typedef ci::CuckooSet< item_type
463 ,ci::cuckoo::make_traits<
464 ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ),
465 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
467 ,ci::opt::hash< std::tuple< hash1, hash2 > >
468 ,ci::opt::compare< cmp<item_type> >
469 , ci::opt::disposer< mock_disposer >
473 typename set_type::hash_tuple_type ht;
478 TEST_F( IntrusiveCuckooSet, striped_list_memberhook_ordered_less )
480 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type;
482 typedef ci::CuckooSet< item_type
483 ,ci::cuckoo::make_traits<
484 ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ),
485 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
487 ,ci::opt::hash< std::tuple< hash1, hash2 > >
488 ,ci::opt::less< less<item_type> >
489 , ci::opt::disposer< mock_disposer >
493 typename set_type::hash_tuple_type ht;
494 set_type s( 32, 6, 4, ht );
498 TEST_F( IntrusiveCuckooSet, striped_vector_memberhook_ordered_less )
500 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type;
502 typedef ci::CuckooSet< item_type
503 ,ci::cuckoo::make_traits<
504 ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ),
505 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
507 ,ci::opt::hash< std::tuple< hash1, hash2 > >
508 ,ci::opt::less< less<item_type> >
509 ,ci::opt::disposer< mock_disposer >
513 typename set_type::hash_tuple_type ht;
514 set_type s( std::move( ht ));
518 TEST_F( IntrusiveCuckooSet, striped_list_memberhook_ordered_cmpmix )
520 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type;
522 typedef ci::CuckooSet< item_type
523 ,ci::cuckoo::make_traits<
524 ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ),
525 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
527 ,ci::opt::hash< std::tuple< hash1, hash2 > >
528 ,ci::opt::less< less<item_type> >
529 ,ci::opt::compare< cmp<item_type> >
530 ,ci::opt::disposer< mock_disposer >
534 typename set_type::hash_tuple_type ht;
535 set_type s( 32, 6, 0, std::move( ht ));
539 TEST_F( IntrusiveCuckooSet, striped_vector_memberhook_ordered_cmpmix )
541 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type;
543 typedef ci::CuckooSet< item_type
544 ,ci::cuckoo::make_traits<
545 ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ),
546 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
548 ,ci::opt::hash< std::tuple< hash1, hash2 > >
549 ,ci::opt::less< less<item_type> >
550 ,ci::opt::compare< cmp<item_type> >
551 ,ci::opt::disposer< mock_disposer >
555 typename set_type::hash_tuple_type ht;
556 set_type s( std::move( ht ));
560 TEST_F( IntrusiveCuckooSet, striped_list_memberhook_ordered_stat )
562 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type;
564 typedef ci::CuckooSet< item_type
565 ,ci::cuckoo::make_traits<
566 ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ),
567 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
569 ,ci::opt::hash< std::tuple< hash1, hash2 > >
570 ,ci::opt::less< less<item_type> >
571 ,ci::opt::compare< cmp<item_type> >
572 ,ci::opt::stat< ci::cuckoo::stat >
573 ,ci::opt::disposer< mock_disposer >
581 TEST_F( IntrusiveCuckooSet, striped_vector_memberhook_ordered_stat )
583 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type;
585 typedef ci::CuckooSet< item_type
586 ,ci::cuckoo::make_traits<
587 ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ),
588 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
590 ,ci::opt::hash< std::tuple< hash1, hash2 > >
591 ,ci::opt::less< less<item_type> >
592 ,ci::opt::compare< cmp<item_type> >
593 ,ci::opt::stat< ci::cuckoo::stat >
594 ,ci::opt::disposer< mock_disposer >
602 TEST_F( IntrusiveCuckooSet, striped_list_memberhook_unordered_storehash )
604 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 2 >> item_type;
605 struct set_traits: public ci::cuckoo::traits
607 typedef ci::cuckoo::member_hook< offsetof( item_type, hMember ),
608 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
609 ,ci::cuckoo::store_hash< item_type::member_type::hash_array_size >
611 typedef cds::opt::hash_tuple< hash1, hash2 > hash;
612 typedef base_class::equal_to<item_type> equal_to;
613 typedef mock_disposer disposer;
614 typedef ci::cuckoo::stat stat;
616 typedef ci::CuckooSet< item_type, set_traits > set_type;
622 TEST_F( IntrusiveCuckooSet, striped_vector_memberhook_unordered_storehash )
624 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<4>, 2 >> item_type;
625 struct set_traits: public ci::cuckoo::traits
627 typedef ci::cuckoo::member_hook< offsetof( item_type, hMember ),
628 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
629 ,ci::cuckoo::store_hash< item_type::member_type::hash_array_size >
631 typedef cds::opt::hash_tuple< hash1, hash2 > hash;
632 typedef base_class::equal_to<item_type> equal_to;
633 typedef mock_disposer disposer;
634 typedef ci::cuckoo::stat stat;
636 typedef ci::CuckooSet< item_type, set_traits > set_type;
642 TEST_F( IntrusiveCuckooSet, striped_list_memberhook_ordered_storehash )
644 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 2 >> item_type;
646 typedef ci::CuckooSet< item_type
647 ,ci::cuckoo::make_traits<
648 ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ),
649 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
650 ,ci::cuckoo::store_hash< item_type::member_type::hash_array_size >
652 ,cds::opt::hash< std::tuple< hash1, hash2 > >
653 ,cds::opt::less< less<item_type> >
654 ,cds::opt::compare< cmp<item_type> >
655 ,ci::opt::disposer< mock_disposer >
659 typename set_type::hash_tuple_type ht;
660 set_type s( 32, 6, 0, std::move( ht ));
664 TEST_F( IntrusiveCuckooSet, striped_vector_memberhook_ordered_storehash )
666 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 2 >> item_type;
668 typedef ci::CuckooSet< item_type
669 ,ci::cuckoo::make_traits<
670 ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ),
671 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
672 ,ci::cuckoo::store_hash< item_type::member_type::hash_array_size >
674 ,cds::opt::hash< std::tuple< hash1, hash2 > >
675 ,cds::opt::less< less<item_type> >
676 ,cds::opt::compare< cmp<item_type> >
677 ,ci::opt::disposer< mock_disposer >
681 typename set_type::hash_tuple_type ht;
682 set_type s( std::move( ht ));
686 //************************************************************
687 // refinable base hook
689 TEST_F( IntrusiveCuckooSet, refinable_list_basehook_unordered )
691 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 > > item_type;
692 struct set_traits: public ci::cuckoo::traits
694 typedef ci::cuckoo::refinable<> mutex_policy;
695 typedef cds::opt::hash_tuple< hash1, hash2 > hash;
696 typedef base_class::equal_to<item_type> equal_to;
697 typedef mock_disposer disposer;
699 typedef ci::CuckooSet< item_type, set_traits > set_type;
705 TEST_F( IntrusiveCuckooSet, refinable_vector_basehook_unordered )
707 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<4>, 0 >> item_type;
708 struct set_traits: public ci::cuckoo::traits
710 typedef ci::cuckoo::refinable<> mutex_policy;
711 typedef ci::cuckoo::base_hook< ci::cuckoo::probeset_type< item_type::probeset_type >> hook;
712 typedef cds::opt::hash_tuple< hash1, hash2 > hash;
713 typedef base_class::equal_to<item_type> equal_to;
714 typedef mock_disposer disposer;
716 typedef ci::CuckooSet< item_type, set_traits > set_type;
722 TEST_F( IntrusiveCuckooSet, refinable_list_basehook_ordered_cmp )
724 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type;
726 typedef ci::CuckooSet< item_type
727 ,ci::cuckoo::make_traits<
728 ci::opt::hook< ci::cuckoo::base_hook<
729 ci::cuckoo::probeset_type< item_type::probeset_type >
731 ,ci::opt::mutex_policy<ci::cuckoo::refinable<>>
732 ,ci::opt::hash< std::tuple< hash1, hash2 > >
733 ,ci::opt::compare< cmp<item_type> >
734 ,ci::opt::disposer< mock_disposer >
738 set_type s( 32, 6, 4 );
742 TEST_F( IntrusiveCuckooSet, refinable_vector_basehook_ordered_cmp )
744 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<8>, 0 >> item_type;
746 typedef ci::CuckooSet< item_type
747 ,ci::cuckoo::make_traits<
748 ci::opt::hook< ci::cuckoo::base_hook<
749 ci::cuckoo::probeset_type< item_type::probeset_type >
751 ,ci::opt::mutex_policy<ci::cuckoo::refinable<>>
752 ,ci::opt::hash< std::tuple< hash1, hash2 > >
753 ,ci::opt::compare< cmp<item_type> >
754 , ci::opt::disposer< mock_disposer >
758 typename set_type::hash_tuple_type ht;
763 TEST_F( IntrusiveCuckooSet, refinable_list_basehook_ordered_less )
765 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type;
767 typedef ci::CuckooSet< item_type
768 ,ci::cuckoo::make_traits<
769 ci::opt::hook< ci::cuckoo::base_hook<
770 ci::cuckoo::probeset_type< item_type::probeset_type >
772 ,ci::opt::mutex_policy<ci::cuckoo::refinable<>>
773 ,ci::opt::hash< std::tuple< hash1, hash2 > >
774 ,ci::opt::less< less<item_type> >
775 ,ci::opt::disposer< mock_disposer >
779 typename set_type::hash_tuple_type ht;
780 set_type s( 32, 6, 4, ht );
784 TEST_F( IntrusiveCuckooSet, refinable_vector_basehook_ordered_less )
786 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type;
788 typedef ci::CuckooSet< item_type
789 ,ci::cuckoo::make_traits<
790 ci::opt::hook< ci::cuckoo::base_hook<
791 ci::cuckoo::probeset_type< item_type::probeset_type >
793 ,ci::opt::mutex_policy<ci::cuckoo::refinable<>>
794 ,ci::opt::hash< std::tuple< hash1, hash2 > >
795 ,ci::opt::less< less<item_type> >
796 ,ci::opt::disposer< mock_disposer >
800 typename set_type::hash_tuple_type ht;
801 set_type s( std::move( ht ));
805 TEST_F( IntrusiveCuckooSet, refinable_list_basehook_ordered_cmpmix )
807 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type;
809 typedef ci::CuckooSet< item_type
810 ,ci::cuckoo::make_traits<
811 ci::opt::hook< ci::cuckoo::base_hook<
812 ci::cuckoo::probeset_type< item_type::probeset_type >
814 ,ci::opt::mutex_policy<ci::cuckoo::refinable<>>
815 ,ci::opt::hash< std::tuple< hash1, hash2 > >
816 ,ci::opt::less< less<item_type> >
817 ,ci::opt::compare< cmp<item_type> >
818 ,ci::opt::disposer< mock_disposer >
822 typename set_type::hash_tuple_type ht;
823 set_type s( 32, 6, 0, std::move( ht ));
827 TEST_F( IntrusiveCuckooSet, refinable_vector_basehook_ordered_cmpmix )
829 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type;
831 typedef ci::CuckooSet< item_type
832 ,ci::cuckoo::make_traits<
833 ci::opt::hook< ci::cuckoo::base_hook<
834 ci::cuckoo::probeset_type< item_type::probeset_type >
836 ,ci::opt::mutex_policy<ci::cuckoo::refinable<>>
837 ,ci::opt::hash< std::tuple< hash1, hash2 > >
838 ,ci::opt::less< less<item_type> >
839 ,ci::opt::compare< cmp<item_type> >
840 ,ci::opt::disposer< mock_disposer >
844 typename set_type::hash_tuple_type ht;
845 set_type s( std::move( ht ));
849 TEST_F( IntrusiveCuckooSet, refinable_list_basehook_ordered_stat )
851 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type;
853 typedef ci::CuckooSet< item_type
854 ,ci::cuckoo::make_traits<
855 ci::opt::hook< ci::cuckoo::base_hook<
856 ci::cuckoo::probeset_type< item_type::probeset_type >
858 ,ci::opt::mutex_policy<ci::cuckoo::refinable<>>
859 ,ci::opt::hash< std::tuple< hash1, hash2 > >
860 ,ci::opt::less< less<item_type> >
861 ,ci::opt::compare< cmp<item_type> >
862 ,ci::opt::stat< ci::cuckoo::stat >
863 ,ci::opt::disposer< mock_disposer >
871 TEST_F( IntrusiveCuckooSet, refinable_vector_basehook_ordered_stat )
873 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type;
875 typedef ci::CuckooSet< item_type
876 ,ci::cuckoo::make_traits<
877 ci::opt::hook< ci::cuckoo::base_hook<
878 ci::cuckoo::probeset_type< item_type::probeset_type >
880 ,ci::opt::mutex_policy<ci::cuckoo::refinable<>>
881 ,ci::opt::hash< std::tuple< hash1, hash2 > >
882 ,ci::opt::less< less<item_type> >
883 ,ci::opt::compare< cmp<item_type> >
884 ,ci::opt::stat< ci::cuckoo::stat >
885 ,ci::opt::disposer< mock_disposer >
893 TEST_F( IntrusiveCuckooSet, refinable_list_basehook_unordered_storehash )
895 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 2 >> item_type;
896 struct set_traits: public ci::cuckoo::traits
898 typedef ci::cuckoo::base_hook<
899 ci::cuckoo::probeset_type< item_type::probeset_type >
900 ,ci::cuckoo::store_hash< item_type::hash_array_size >
902 typedef ci::cuckoo::refinable<> mutex_policy;
903 typedef cds::opt::hash_tuple< hash1, hash2 > hash;
904 typedef base_class::equal_to<item_type> equal_to;
905 typedef mock_disposer disposer;
906 typedef ci::cuckoo::stat stat;
908 typedef ci::CuckooSet< item_type, set_traits > set_type;
914 TEST_F( IntrusiveCuckooSet, refinable_vector_basehook_unordered_storehash )
916 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<4>, 2 >> item_type;
917 struct set_traits: public ci::cuckoo::traits
919 typedef ci::cuckoo::base_hook<
920 ci::cuckoo::probeset_type< item_type::probeset_type >
921 ,ci::cuckoo::store_hash< item_type::hash_array_size >
923 typedef ci::cuckoo::refinable<> mutex_policy;
924 typedef cds::opt::hash_tuple< hash1, hash2 > hash;
925 typedef base_class::equal_to<item_type> equal_to;
926 typedef mock_disposer disposer;
927 typedef ci::cuckoo::stat stat;
929 typedef ci::CuckooSet< item_type, set_traits > set_type;
935 TEST_F( IntrusiveCuckooSet, refinable_list_basehook_ordered_storehash )
937 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::list, 2 >> item_type;
939 typedef ci::CuckooSet< item_type
940 ,ci::cuckoo::make_traits<
941 ci::opt::hook< ci::cuckoo::base_hook<
942 ci::cuckoo::probeset_type< item_type::probeset_type >
943 ,ci::cuckoo::store_hash< item_type::hash_array_size >
945 ,ci::opt::mutex_policy<ci::cuckoo::refinable<>>
946 ,cds::opt::hash< std::tuple< hash1, hash2 > >
947 ,cds::opt::less< less<item_type> >
948 ,cds::opt::compare< cmp<item_type> >
949 ,ci::opt::disposer< mock_disposer >
953 typename set_type::hash_tuple_type ht;
954 set_type s( 32, 6, 0, std::move( ht ));
958 TEST_F( IntrusiveCuckooSet, refinable_vector_basehook_ordered_storehash )
960 typedef base_class::base_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 2 >> item_type;
962 typedef ci::CuckooSet< item_type
963 ,ci::cuckoo::make_traits<
964 ci::opt::hook< ci::cuckoo::base_hook<
965 ci::cuckoo::probeset_type< item_type::probeset_type >
966 ,ci::cuckoo::store_hash< item_type::hash_array_size >
968 ,ci::opt::mutex_policy<ci::cuckoo::refinable<>>
969 ,cds::opt::hash< std::tuple< hash1, hash2 > >
970 ,cds::opt::less< less<item_type> >
971 ,cds::opt::compare< cmp<item_type> >
972 ,ci::opt::disposer< mock_disposer >
976 typename set_type::hash_tuple_type ht;
977 set_type s( std::move( ht ));
981 //************************************************************
982 // refinable member hook
984 TEST_F( IntrusiveCuckooSet, refinable_list_memberhook_unordered )
986 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 > > item_type;
987 struct set_traits: public ci::cuckoo::traits
989 typedef ci::cuckoo::member_hook< offsetof( item_type, hMember )> hook;
990 typedef ci::cuckoo::refinable<> mutex_policy;
991 typedef cds::opt::hash_tuple< hash1, hash2 > hash;
992 typedef base_class::equal_to<item_type> equal_to;
993 typedef mock_disposer disposer;
995 typedef ci::CuckooSet< item_type, set_traits > set_type;
1001 TEST_F( IntrusiveCuckooSet, refinable_vector_memberhook_unordered )
1003 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<4>, 0 >> item_type;
1004 struct set_traits: public ci::cuckoo::traits
1007 typedef ci::cuckoo::member_hook< offsetof( item_type, hMember ), ci::cuckoo::probeset_type< item_type::member_type::probeset_type >> hook;
1008 typedef ci::cuckoo::refinable<> mutex_policy;
1009 typedef cds::opt::hash_tuple< hash1, hash2 > hash;
1010 typedef base_class::equal_to<item_type> equal_to;
1011 typedef mock_disposer disposer;
1013 typedef ci::CuckooSet< item_type, set_traits > set_type;
1015 set_type s( 32, 4 );
1019 TEST_F( IntrusiveCuckooSet, refinable_list_memberhook_ordered_cmp )
1021 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type;
1023 typedef ci::CuckooSet< item_type
1024 ,ci::cuckoo::make_traits<
1025 ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ),
1026 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
1028 ,ci::opt::mutex_policy<ci::cuckoo::refinable<>>
1029 ,ci::opt::hash< std::tuple< hash1, hash2 > >
1030 ,ci::opt::compare< cmp<item_type> >
1031 ,ci::opt::disposer< mock_disposer >
1035 set_type s( 32, 6, 4 );
1039 TEST_F( IntrusiveCuckooSet, refinable_vector_memberhook_ordered_cmp )
1041 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<8>, 0 >> item_type;
1043 typedef ci::CuckooSet< item_type
1044 ,ci::cuckoo::make_traits<
1045 ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ),
1046 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
1048 ,ci::opt::mutex_policy<ci::cuckoo::refinable<>>
1049 ,ci::opt::hash< std::tuple< hash1, hash2 > >
1050 ,ci::opt::compare< cmp<item_type> >
1051 ,ci::opt::disposer< mock_disposer >
1055 typename set_type::hash_tuple_type ht;
1060 TEST_F( IntrusiveCuckooSet, refinable_list_memberhook_ordered_less )
1062 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type;
1064 typedef ci::CuckooSet< item_type
1065 ,ci::cuckoo::make_traits<
1066 ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ),
1067 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
1069 ,ci::opt::mutex_policy<ci::cuckoo::refinable<>>
1070 ,ci::opt::hash< std::tuple< hash1, hash2 > >
1071 ,ci::opt::less< less<item_type> >
1072 ,ci::opt::disposer< mock_disposer >
1076 typename set_type::hash_tuple_type ht;
1077 set_type s( 32, 6, 4, ht );
1081 TEST_F( IntrusiveCuckooSet, refinable_vector_memberhook_ordered_less )
1083 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type;
1085 typedef ci::CuckooSet< item_type
1086 ,ci::cuckoo::make_traits<
1087 ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ),
1088 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
1090 ,ci::opt::mutex_policy<ci::cuckoo::refinable<>>
1091 ,ci::opt::hash< std::tuple< hash1, hash2 > >
1092 ,ci::opt::less< less<item_type> >
1093 ,ci::opt::disposer< mock_disposer >
1097 typename set_type::hash_tuple_type ht;
1098 set_type s( std::move( ht ));
1102 TEST_F( IntrusiveCuckooSet, refinable_list_memberhook_ordered_cmpmix )
1104 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type;
1106 typedef ci::CuckooSet< item_type
1107 ,ci::cuckoo::make_traits<
1108 ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ),
1109 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
1111 ,ci::opt::mutex_policy<ci::cuckoo::refinable<>>
1112 ,ci::opt::hash< std::tuple< hash1, hash2 > >
1113 ,ci::opt::less< less<item_type> >
1114 ,ci::opt::compare< cmp<item_type> >
1115 ,ci::opt::disposer< mock_disposer >
1119 typename set_type::hash_tuple_type ht;
1120 set_type s( 32, 6, 0, std::move( ht ));
1124 TEST_F( IntrusiveCuckooSet, refinable_vector_memberhook_ordered_cmpmix )
1126 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type;
1128 typedef ci::CuckooSet< item_type
1129 ,ci::cuckoo::make_traits<
1130 ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ),
1131 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
1133 ,ci::opt::mutex_policy<ci::cuckoo::refinable<>>
1134 ,ci::opt::hash< std::tuple< hash1, hash2 > >
1135 ,ci::opt::less< less<item_type> >
1136 ,ci::opt::compare< cmp<item_type> >
1137 ,ci::opt::disposer< mock_disposer >
1141 typename set_type::hash_tuple_type ht;
1142 set_type s( std::move( ht ));
1146 TEST_F( IntrusiveCuckooSet, refinable_list_memberhook_ordered_stat )
1148 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 0 >> item_type;
1150 typedef ci::CuckooSet< item_type
1151 ,ci::cuckoo::make_traits<
1152 ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ),
1153 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
1155 ,ci::opt::mutex_policy<ci::cuckoo::refinable<>>
1156 ,ci::opt::hash< std::tuple< hash1, hash2 > >
1157 ,ci::opt::less< less<item_type> >
1158 ,ci::opt::compare< cmp<item_type> >
1159 ,ci::opt::stat< ci::cuckoo::stat >
1160 ,ci::opt::disposer< mock_disposer >
1168 TEST_F( IntrusiveCuckooSet, refinable_vector_memberhook_ordered_stat )
1170 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 0 >> item_type;
1172 typedef ci::CuckooSet< item_type
1173 ,ci::cuckoo::make_traits<
1174 ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ),
1175 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
1177 ,ci::opt::mutex_policy<ci::cuckoo::refinable<>>
1178 ,ci::opt::hash< std::tuple< hash1, hash2 > >
1179 ,ci::opt::less< less<item_type> >
1180 ,ci::opt::compare< cmp<item_type> >
1181 ,ci::opt::stat< ci::cuckoo::stat >
1182 ,ci::opt::disposer< mock_disposer >
1190 TEST_F( IntrusiveCuckooSet, refinable_list_memberhook_unordered_storehash )
1192 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 2 >> item_type;
1193 struct set_traits: public ci::cuckoo::traits
1195 typedef ci::cuckoo::member_hook< offsetof( item_type, hMember ),
1196 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
1197 ,ci::cuckoo::store_hash< item_type::member_type::hash_array_size >
1199 typedef ci::cuckoo::refinable<> mutex_policy;
1200 typedef cds::opt::hash_tuple< hash1, hash2 > hash;
1201 typedef base_class::equal_to<item_type> equal_to;
1202 typedef mock_disposer disposer;
1203 typedef ci::cuckoo::stat stat;
1205 typedef ci::CuckooSet< item_type, set_traits > set_type;
1211 TEST_F( IntrusiveCuckooSet, refinable_vector_memberhook_unordered_storehash )
1213 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<4>, 2 >> item_type;
1214 struct set_traits: public ci::cuckoo::traits
1216 typedef ci::cuckoo::member_hook< offsetof( item_type, hMember ),
1217 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
1218 ,ci::cuckoo::store_hash< item_type::member_type::hash_array_size >
1220 typedef ci::cuckoo::refinable<> mutex_policy;
1221 typedef cds::opt::hash_tuple< hash1, hash2 > hash;
1222 typedef base_class::equal_to<item_type> equal_to;
1223 typedef mock_disposer disposer;
1224 typedef ci::cuckoo::stat stat;
1226 typedef ci::CuckooSet< item_type, set_traits > set_type;
1228 set_type s( 32, 4 );
1232 TEST_F( IntrusiveCuckooSet, refinable_list_memberhook_ordered_storehash )
1234 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::list, 2 >> item_type;
1236 typedef ci::CuckooSet< item_type
1237 ,ci::cuckoo::make_traits<
1238 ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ),
1239 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
1240 ,ci::cuckoo::store_hash< item_type::member_type::hash_array_size >
1242 ,ci::opt::mutex_policy<ci::cuckoo::refinable<>>
1243 ,cds::opt::hash< std::tuple< hash1, hash2 > >
1244 ,cds::opt::less< less<item_type> >
1245 ,cds::opt::compare< cmp<item_type> >
1246 ,ci::opt::disposer< mock_disposer >
1250 typename set_type::hash_tuple_type ht;
1251 set_type s( 32, 6, 0, std::move( ht ));
1255 TEST_F( IntrusiveCuckooSet, refinable_vector_memberhook_ordered_storehash )
1257 typedef base_class::member_int_item< ci::cuckoo::node< ci::cuckoo::vector<6>, 2 >> item_type;
1259 typedef ci::CuckooSet< item_type
1260 ,ci::cuckoo::make_traits<
1261 ci::opt::hook< ci::cuckoo::member_hook< offsetof( item_type, hMember ),
1262 ci::cuckoo::probeset_type< item_type::member_type::probeset_type >
1263 ,ci::cuckoo::store_hash< item_type::member_type::hash_array_size >
1265 ,ci::opt::mutex_policy<ci::cuckoo::refinable<>>
1266 ,cds::opt::hash< std::tuple< hash1, hash2 > >
1267 ,cds::opt::less< less<item_type> >
1268 ,cds::opt::compare< cmp<item_type> >
1269 ,ci::opt::disposer< mock_disposer >
1273 typename set_type::hash_tuple_type ht;
1274 set_type s( std::move( ht ));