From 862501942f4ff26a41064ec7511144212aaff8f0 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 22 Jan 2016 17:00:47 +0000 Subject: [PATCH 1/7] Minor changes to unordered_map. Added default to list link class. --- intrusive_forward_list_link.h | 2 +- iunordered_map.h | 58 ++++++++++++++++++----------------- unordered_map.h | 24 +++++++++------ 3 files changed, 45 insertions(+), 39 deletions(-) diff --git a/intrusive_forward_list_link.h b/intrusive_forward_list_link.h index 8d020450..171ac00e 100644 --- a/intrusive_forward_list_link.h +++ b/intrusive_forward_list_link.h @@ -39,7 +39,7 @@ namespace etl //*************************************************************************** /// The link element in the intrusive_forward_list. //*************************************************************************** - template + template struct intrusive_forward_list_link { intrusive_forward_list_link* ifll_next; diff --git a/iunordered_map.h b/iunordered_map.h index 4c94baa7..4bad1eff 100644 --- a/iunordered_map.h +++ b/iunordered_map.h @@ -44,7 +44,7 @@ SOFTWARE. #include "ipool.h" #include "ivector.h" #include "error_handler.h" -#include "basic_intrusive_forward_list.h" +#include "intrusive_forward_list.h" #include "exception.h" #include "error_handler.h" @@ -103,7 +103,7 @@ namespace etl public: unordered_map_iterator(string_type file_name, numeric_type line_number) - : unordered_map_exception("unordered_map:iterator", file_name, line_number) + : unordered_map_exception(ETL_ERROR_TEXT("unordered_map:iterator", ETL_FILE"C"), file_name, line_number) { } }; @@ -133,8 +133,10 @@ namespace etl typedef typename parameter_type::type key_value_parameter_t; + typedef etl::intrusive_forward_list_link<> link_t; // Default link. + // The nodes that store the elements. - struct node_t : public etl::basic_intrusive_forward_list_node + struct node_t : public link_t { node_t(const value_type& key_value_pair) : key_value_pair(key_value_pair) @@ -146,9 +148,9 @@ namespace etl private: - typedef etl::basic_intrusive_forward_list bucket_t; - typedef etl::ipool pool_t; - typedef etl::ivector bucket_list_t; + typedef etl::intrusive_forward_list bucket_t; + typedef etl::ipool pool_t; + typedef etl::ivector bucket_list_t; typedef typename bucket_list_t::iterator bucket_list_iterator; @@ -234,37 +236,37 @@ namespace etl //********************************* std::pair operator *() { - return inode.ref_cast().key_value_pair; + return inode->key_value_pair; } //********************************* const_reference operator *() const { - return inode.ref_cast().key_value_pair; + return inode->key_value_pair; } //********************************* pointer operator &() { - return &(inode.ref_cast().key_value_pair); + return &(inode->key_value_pair); } //********************************* const_pointer operator &() const { - return &(inode.ref_cast().key_value_pair); + return &(inode->key_value_pair); } //********************************* pointer operator ->() { - return &(inode.ref_cast().key_value_pair); + return &(inode->key_value_pair); } //********************************* const_pointer operator ->() const { - return &(inode.ref_cast().key_value_pair); + return &(inode->key_value_pair); } //********************************* @@ -404,19 +406,19 @@ namespace etl //********************************* const_reference operator *() const { - return inode.ref_cast().key_value_pair; + return inode->key_value_pair; } //********************************* const_pointer operator &() const { - return &(inode.ref_cast().key_value_pair); + return &(inode->key_value_pair); } //********************************* const_pointer operator ->() const { - return &(inode.ref_cast().key_value_pair); + return &(inode->key_value_pair); } //********************************* @@ -635,10 +637,10 @@ namespace etl while (inode != ibucket->end()) { // Equal keys? - if (key_equal_function(key, inode.ref_cast().key_value_pair.first)) + if (key_equal_function(key, inode->key_value_pair.first)) { // Found a match. - return inode.ref_cast().key_value_pair.second; + return inode->key_value_pair.second; } else { @@ -651,7 +653,7 @@ namespace etl node_t& node = *pnodepool->allocate(node_t(value_type(key, T()))); ibucket->insert_after(ibucket->before_begin(), node); - return ibucket->begin().ref_cast().key_value_pair.second; + return ibucket->begin()->key_value_pair.second; } //********************************************************************* @@ -672,10 +674,10 @@ namespace etl while (inode != ibucket->end()) { // Equal keys? - if (key_equal_function(key, inode.ref_cast().key_value_pair.first)) + if (key_equal_function(key, inode->key_value_pair.first)) { // Found a match. - return inode.ref_cast().key_value_pair.second; + return inode->key_value_pair.second; } else { @@ -707,10 +709,10 @@ namespace etl while (inode != ibucket->end()) { // Equal keys? - if (key_equal_function(key, inode.ref_cast().key_value_pair.first)) + if (key_equal_function(key, inode->key_value_pair.first)) { // Found a match. - return inode.ref_cast().key_value_pair.second; + return inode->key_value_pair.second; } else { @@ -792,7 +794,7 @@ namespace etl while (inode != bucket.end()) { // Do we already have this key? - if (inode.ref_cast().key_value_pair.first == key) + if (inode->key_value_pair.first == key) { break; } @@ -861,7 +863,7 @@ namespace etl local_iterator iprevious = bucket.before_begin(); local_iterator icurrent = bucket.begin(); - while ((icurrent != bucket.end()) && (icurrent.ref_cast().key_value_pair.first != key)) + while ((icurrent != bucket.end()) && (icurrent->key_value_pair.first != key)) { ++iprevious; ++icurrent; @@ -891,7 +893,7 @@ namespace etl local_iterator iprevious = bucket.before_begin(); // Find the node we're interested in. - while (iprevious->bifln_next != &*icurrent) + while (iprevious->ifll_next != &*icurrent) { ++iprevious; } @@ -920,7 +922,7 @@ namespace etl local_iterator iend; // Find the first node we're interested in. - while (iprevious->bifln_next != &*ifirst) + while (iprevious->ifll_next != &*ifirst) { ++iprevious; } @@ -999,7 +1001,7 @@ namespace etl while (inode != iend) { // Do we have this one? - if (key_equal_function(key, inode.ref_cast().key_value_pair.first)) + if (key_equal_function(key, inode->key_value_pair.first)) { return iterator(pbuckets->end(), ibucket, inode); } @@ -1033,7 +1035,7 @@ namespace etl while (inode != iend) { // Do we have this one? - if (key_equal_function(key, inode.ref_cast().key_value_pair.first)) + if (key_equal_function(key, inode->key_value_pair.first)) { return iterator(pbuckets->end(), ibucket, inode); } diff --git a/unordered_map.h b/unordered_map.h index 9dc5f283..e4c1f1ea 100644 --- a/unordered_map.h +++ b/unordered_map.h @@ -39,7 +39,7 @@ SOFTWARE. #include "container.h" #include "pool.h" #include "vector.h" -#include "basic_intrusive_forward_list.h" +#include "intrusive_forward_list.h" #include "hash.h" //***************************************************************************** @@ -56,6 +56,10 @@ namespace etl template , typename TKeyEqual = std::equal_to > class unordered_map : public iunordered_map { + private: + + typedef iunordered_map base; + public: static const size_t MAX_SIZE = MAX_SIZE_; @@ -64,18 +68,18 @@ namespace etl /// Default constructor. //************************************************************************* unordered_map() - : iunordered_map(node_pool, buckets) + : base(node_pool, buckets) { - iunordered_map::initialise(); + base::initialise(); } //************************************************************************* /// Copy constructor. //************************************************************************* unordered_map(const unordered_map& other) - : iunordered_map(node_pool, buckets) + : base(node_pool, buckets) { - iunordered_map::assign(other.cbegin(), other.cend()); + base::assign(other.cbegin(), other.cend()); } //************************************************************************* @@ -86,9 +90,9 @@ namespace etl //************************************************************************* template unordered_map(TIterator first, TIterator last) - : iunordered_map(node_pool, buckets) + : base(node_pool, buckets) { - iunordered_map::assign(first, last); + base::assign(first, last); } //************************************************************************* @@ -99,7 +103,7 @@ namespace etl // Skip if doing self assignment if (this != &rhs) { - iunordered_map::assign(rhs.cbegin(), rhs.cend()); + base::assign(rhs.cbegin(), rhs.cend()); } return *this; @@ -108,10 +112,10 @@ namespace etl private: /// The pool of nodes used for the unordered_map. - etl::pool::node_t, MAX_SIZE> node_pool; + etl::pool node_pool; /// The buckets of node lists. - etl::vector buckets; + etl::vector, MAX_SIZE> buckets; }; } From 3342303ce610c9b92a8b17561b7f127b291d084e Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 22 Jan 2016 17:01:32 +0000 Subject: [PATCH 2/7] Added intrusive forward list & tests --- test/codeblocks/ETL.cbp | 3 + test/codeblocks/ETL.depend | 304 +++++++++++-------- test/codeblocks/ETL.layout | 597 ++++++++++++++++--------------------- 3 files changed, 436 insertions(+), 468 deletions(-) diff --git a/test/codeblocks/ETL.cbp b/test/codeblocks/ETL.cbp index acd558bb..46a5bab7 100644 --- a/test/codeblocks/ETL.cbp +++ b/test/codeblocks/ETL.cbp @@ -172,6 +172,8 @@ + + @@ -251,6 +253,7 @@ + diff --git a/test/codeblocks/ETL.depend b/test/codeblocks/ETL.depend index 99e3912f..1288b643 100644 --- a/test/codeblocks/ETL.depend +++ b/test/codeblocks/ETL.depend @@ -2829,40 +2829,40 @@ "DeferredTestReporter.h" -1449838910 source:d:\users\john\documents\programming\github\etl\crc16.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\crc16.cpp -1449838910 source:d:\users\john\documents\programming\github\etl\crc16_ccitt.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\crc16_ccitt.cpp -1449838910 source:d:\users\john\documents\programming\github\etl\crc16_kermit.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\crc16_kermit.cpp -1449838910 source:d:\users\john\documents\programming\github\etl\crc32.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\crc32.cpp -1449838910 source:d:\users\john\documents\programming\github\etl\crc64_ecma.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\crc64_ecma.cpp -1449838910 source:d:\users\john\documents\programming\github\etl\crc8_ccitt.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\crc8_ccitt.cpp -1449838910 source:d:\users\john\documents\programming\github\etl\error_handler.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\error_handler.cpp "error_handler.h" "nullptr.h" -1449838910 d:\users\john\documents\programming\github\etl\error_handler.h +1452796556 d:\users\john\documents\programming\github\etl\error_handler.h "exception.h" "function.h" -1449838910 d:\users\john\documents\programming\github\etl\exception.h +1450265856 d:\users\john\documents\programming\github\etl\exception.h -1449838910 d:\users\john\documents\programming\github\etl\function.h +1452203243 d:\users\john\documents\programming\github\etl\function.h -1449838910 d:\users\john\documents\programming\github\etl\nullptr.h +1450265856 d:\users\john\documents\programming\github\etl\nullptr.h -1449834672 source:d:\users\john\documents\programming\github\etl\test\main.cpp +1450264056 source:d:\users\john\documents\programming\github\etl\test\main.cpp 1414845610 d:\users\john\documents\programming\github\unittest-cpp\unittest++\unittest++.h @@ -2898,7 +2898,7 @@ "CurrentTest.h" "ReportAssertImpl.h" -1424726109 source:d:\users\john\documents\programming\github\etl\test\test_algorithm.cpp +1452338450 source:d:\users\john\documents\programming\github\etl\test\test_algorithm.cpp "../algorithm.h" "../container.h" @@ -2907,7 +2907,7 @@ -1449838910 d:\users\john\documents\programming\github\etl\algorithm.h +1452796851 d:\users\john\documents\programming\github\etl\algorithm.h @@ -2915,15 +2915,15 @@ "type_traits.h" -1449856479 d:\users\john\documents\programming\github\etl\type_traits.h +1452796556 d:\users\john\documents\programming\github\etl\type_traits.h "nullptr.h" -1449838910 d:\users\john\documents\programming\github\etl\container.h +1450265856 d:\users\john\documents\programming\github\etl\container.h -1427740329 source:d:\users\john\documents\programming\github\etl\test\test_alignment.cpp +1452796556 source:d:\users\john\documents\programming\github\etl\test\test_alignment.cpp "../alignment.h" "../type_traits.h" @@ -2932,14 +2932,14 @@ -1449838910 d:\users\john\documents\programming\github\etl\alignment.h +1450265856 d:\users\john\documents\programming\github\etl\alignment.h "type_traits.h" "static_assert.h" -1449838910 d:\users\john\documents\programming\github\etl\static_assert.h +1450265856 d:\users\john\documents\programming\github\etl\static_assert.h -1428227985 source:d:\users\john\documents\programming\github\etl\test\test_array.cpp +1452338450 source:d:\users\john\documents\programming\github\etl\test\test_array.cpp "../array.h" @@ -2947,7 +2947,7 @@ "../integral_limits.h" -1449838910 d:\users\john\documents\programming\github\etl\array.h +1450265856 d:\users\john\documents\programming\github\etl\array.h @@ -2958,15 +2958,15 @@ "static_assert.h" "error_handler.h" -1449838910 d:\users\john\documents\programming\github\etl\parameter_type.h +1450265856 d:\users\john\documents\programming\github\etl\parameter_type.h "type_traits.h" -1449838910 d:\users\john\documents\programming\github\etl\integral_limits.h +1450265856 d:\users\john\documents\programming\github\etl\integral_limits.h "type_traits.h" -1449853390 source:d:\users\john\documents\programming\github\etl\test\test_binary.cpp +1452796556 source:d:\users\john\documents\programming\github\etl\test\test_binary.cpp @@ -2975,7 +2975,7 @@ "../fnv_1.h" "../integral_limits.h" -1449842605 d:\users\john\documents\programming\github\etl\binary.h +1450265856 d:\users\john\documents\programming\github\etl\binary.h "type_traits.h" "integral_limits.h" "static_assert.h" @@ -2983,7 +2983,7 @@ "power.h" "smallest.h" -1449838910 d:\users\john\documents\programming\github\etl\bitset.h +1452796556 d:\users\john\documents\programming\github\etl\bitset.h @@ -2995,45 +2995,48 @@ "ibitset.h" "error_handler.h" -1449838910 d:\users\john\documents\programming\github\etl\smallest.h +1450265856 d:\users\john\documents\programming\github\etl\smallest.h "integral_limits.h" -1449838910 d:\users\john\documents\programming\github\etl\log.h +1450265856 d:\users\john\documents\programming\github\etl\log.h -1449846756 d:\users\john\documents\programming\github\etl\ibitset.h +1452878867 d:\users\john\documents\programming\github\etl\ibitset.h + "exception.h" "integral_limits.h" "binary.h" + "algorithm.h" -1449838910 d:\users\john\documents\programming\github\etl\fnv_1.h +1450265856 d:\users\john\documents\programming\github\etl\fnv_1.h "static_assert.h" "type_traits.h" "ihash.h" -1449838910 d:\users\john\documents\programming\github\etl\endian.h +1450265856 d:\users\john\documents\programming\github\etl\endian.h "enum_type.h" -1449838910 d:\users\john\documents\programming\github\etl\enum_type.h +1452796851 d:\users\john\documents\programming\github\etl\enum_type.h -1449838910 d:\users\john\documents\programming\github\etl\ihash.h +1450265856 d:\users\john\documents\programming\github\etl\ihash.h "exception.h" + "error_handler.h" -1449756680 source:d:\users\john\documents\programming\github\etl\test\test_bitset.cpp +1452796556 source:d:\users\john\documents\programming\github\etl\test\test_bitset.cpp "../bitset.h" -1443462794 source:d:\users\john\documents\programming\github\etl\test\test_bloom_filter.cpp +1452796556 source:d:\users\john\documents\programming\github\etl\test\test_bloom_filter.cpp @@ -3043,7 +3046,7 @@ "../crc16_ccitt.h" "../crc32.h" -1449838910 d:\users\john\documents\programming\github\etl\bloom_filter.h +1450265856 d:\users\john\documents\programming\github\etl\bloom_filter.h "parameter_type.h" "bitset.h" "type_traits.h" @@ -3051,26 +3054,26 @@ "log.h" "power.h" -1449838910 d:\users\john\documents\programming\github\etl\power.h +1450265856 d:\users\john\documents\programming\github\etl\power.h "log.h" -1449838910 d:\users\john\documents\programming\github\etl\crc16.h +1450265856 d:\users\john\documents\programming\github\etl\crc16.h "static_assert.h" "type_traits.h" -1449838910 d:\users\john\documents\programming\github\etl\crc16_ccitt.h +1450265856 d:\users\john\documents\programming\github\etl\crc16_ccitt.h "static_assert.h" "type_traits.h" -1449838910 d:\users\john\documents\programming\github\etl\crc32.h +1450265856 d:\users\john\documents\programming\github\etl\crc32.h "static_assert.h" -1443462794 source:d:\users\john\documents\programming\github\etl\test\test_checksum.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_checksum.cpp @@ -3079,18 +3082,18 @@ "../checksum.h" "../endian.h" -1449838910 d:\users\john\documents\programming\github\etl\checksum.h +1450265856 d:\users\john\documents\programming\github\etl\checksum.h "static_assert.h" "type_traits.h" "ihash.h" -1424726109 source:d:\users\john\documents\programming\github\etl\test\test_container.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_container.cpp "../container.h" -1443462794 source:d:\users\john\documents\programming\github\etl\test\test_crc.cpp +1452796556 source:d:\users\john\documents\programming\github\etl\test\test_crc.cpp @@ -3103,32 +3106,32 @@ "../crc32.h" "../crc64_ecma.h" -1449838910 d:\users\john\documents\programming\github\etl\crc8_ccitt.h +1450265856 d:\users\john\documents\programming\github\etl\crc8_ccitt.h "static_assert.h" "type_traits.h" -1449838910 d:\users\john\documents\programming\github\etl\crc16_kermit.h +1450265856 d:\users\john\documents\programming\github\etl\crc16_kermit.h "static_assert.h" "type_traits.h" -1449838910 d:\users\john\documents\programming\github\etl\crc64_ecma.h +1450265856 d:\users\john\documents\programming\github\etl\crc64_ecma.h "static_assert.h" "type_traits.h" -1424726109 source:d:\users\john\documents\programming\github\etl\test\test_cyclic_value.cpp +1452796556 source:d:\users\john\documents\programming\github\etl\test\test_cyclic_value.cpp "../cyclic_value.h" -1449838910 d:\users\john\documents\programming\github\etl\cyclic_value.h +1452794793 d:\users\john\documents\programming\github\etl\cyclic_value.h "static_assert.h" "exception.h" -1449675194 source:d:\users\john\documents\programming\github\etl\test\test_deque.cpp +1452878867 source:d:\users\john\documents\programming\github\etl\test\test_deque.cpp "ExtraCheckMacros.h" "../deque.h" @@ -3149,7 +3152,7 @@ -1449838910 d:\users\john\documents\programming\github\etl\deque.h +1452796556 d:\users\john\documents\programming\github\etl\deque.h @@ -3159,7 +3162,7 @@ "alignment.h" "array.h" -1449838910 d:\users\john\documents\programming\github\etl\ideque.h +1453406068 d:\users\john\documents\programming\github\etl\ideque.h "algorithm.h" @@ -3172,30 +3175,33 @@ "exception.h" -1443462794 d:\users\john\documents\programming\github\etl\test\data.h +1450265856 d:\users\john\documents\programming\github\etl\test\data.h -1424726109 source:d:\users\john\documents\programming\github\etl\test\test_endian.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_endian.cpp "../endian.h" -1424726109 source:d:\users\john\documents\programming\github\etl\test\test_enum_type.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_enum_type.cpp "../enum_type.h" -1424726109 source:d:\users\john\documents\programming\github\etl\test\test_error_handler.cpp +1453406068 source:d:\users\john\documents\programming\github\etl\test\test_error_handler.cpp + + + "../error_handler.h" "../exception.h" -1424726109 source:d:\users\john\documents\programming\github\etl\test\test_exception.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_exception.cpp "../exception.h" -1443462794 source:d:\users\john\documents\programming\github\etl\test\test_flat_map.cpp +1452796556 source:d:\users\john\documents\programming\github\etl\test\test_flat_map.cpp @@ -3207,14 +3213,14 @@ "data.h" "../flat_map.h" -1449838910 d:\users\john\documents\programming\github\etl\flat_map.h +1452796556 d:\users\john\documents\programming\github\etl\flat_map.h "iflat_map.h" "vector.h" -1449838910 d:\users\john\documents\programming\github\etl\iflat_map.h +1452796556 d:\users\john\documents\programming\github\etl\iflat_map.h @@ -3232,7 +3238,7 @@ "ivector.h" "error_handler.h" -1449848575 d:\users\john\documents\programming\github\etl\ivector.h +1452796556 d:\users\john\documents\programming\github\etl\ivector.h @@ -3248,7 +3254,7 @@ "exception.h" "error_handler.h" -1449838910 d:\users\john\documents\programming\github\etl\vector.h +1452796556 d:\users\john\documents\programming\github\etl\vector.h @@ -3257,7 +3263,7 @@ "alignment.h" "array.h" -1440787191 source:d:\users\john\documents\programming\github\etl\test\test_flat_set.cpp +1452796556 source:d:\users\john\documents\programming\github\etl\test\test_flat_set.cpp @@ -3269,14 +3275,14 @@ "data.h" "../flat_set.h" -1449838910 d:\users\john\documents\programming\github\etl\flat_set.h +1452796556 d:\users\john\documents\programming\github\etl\flat_set.h "iflat_set.h" "vector.h" -1449838910 d:\users\john\documents\programming\github\etl\iflat_set.h +1452796556 d:\users\john\documents\programming\github\etl\iflat_set.h @@ -3294,7 +3300,7 @@ "ivector.h" "error_handler.h" -1443462794 source:d:\users\john\documents\programming\github\etl\test\test_fnv_1.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_fnv_1.cpp @@ -3302,7 +3308,7 @@ "../fnv_1.h" -1444492600 source:d:\users\john\documents\programming\github\etl\test\test_forward_list.cpp +1453063876 source:d:\users\john\documents\programming\github\etl\test\test_forward_list.cpp "ExtraCheckMacros.h" "data.h" @@ -3313,20 +3319,20 @@ -1449838910 d:\users\john\documents\programming\github\etl\forward_list.h +1452796556 d:\users\john\documents\programming\github\etl\forward_list.h "pool.h" "iforward_list.h" "container.h" -1449838910 d:\users\john\documents\programming\github\etl\pool.h +1452796556 d:\users\john\documents\programming\github\etl\pool.h "alignment.h" "array.h" "bitset.h" "ipool.h" -1449838910 d:\users\john\documents\programming\github\etl\ipool.h +1452796556 d:\users\john\documents\programming\github\etl\ipool.h "private/pool_base.h" "nullptr.h" @@ -3338,7 +3344,7 @@ "exception.h" "error_handler.h" -1449847744 d:\users\john\documents\programming\github\etl\iforward_list.h +1453063980 d:\users\john\documents\programming\github\etl\iforward_list.h @@ -3353,20 +3359,20 @@ "exception.h" -1424726109 source:d:\users\john\documents\programming\github\etl\test\test_function.cpp +1451003290 source:d:\users\john\documents\programming\github\etl\test\test_function.cpp "../function.h" -1424726109 source:d:\users\john\documents\programming\github\etl\test\test_functional.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_functional.cpp "../functional.h" -1449838910 d:\users\john\documents\programming\github\etl\functional.h +1450265856 d:\users\john\documents\programming\github\etl\functional.h -1424726109 source:d:\users\john\documents\programming\github\etl\test\test_hash.cpp +1452796556 source:d:\users\john\documents\programming\github\etl\test\test_hash.cpp @@ -3374,46 +3380,46 @@ "../hash.h" -1449838910 d:\users\john\documents\programming\github\etl\hash.h +1450265856 d:\users\john\documents\programming\github\etl\hash.h "fnv_1.h" "type_traits.h" -1424726109 source:d:\users\john\documents\programming\github\etl\test\test_instance_count.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_instance_count.cpp "../instance_count.h" -1449838910 d:\users\john\documents\programming\github\etl\instance_count.h +1450265856 d:\users\john\documents\programming\github\etl\instance_count.h -1424726109 source:d:\users\john\documents\programming\github\etl\test\test_integral_limits.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_integral_limits.cpp "../integral_limits.h" -1449844166 source:d:\users\john\documents\programming\github\etl\test\test_io_port.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_io_port.cpp "../io_port.h" -1449838910 d:\users\john\documents\programming\github\etl\io_port.h +1450265856 d:\users\john\documents\programming\github\etl\io_port.h "nullptr.h" "parameter_type.h" -1424726109 source:d:\users\john\documents\programming\github\etl\test\test_largest.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_largest.cpp "../largest.h" -1449838910 d:\users\john\documents\programming\github\etl\largest.h +1450265856 d:\users\john\documents\programming\github\etl\largest.h "type_traits.h" -1424726109 source:d:\users\john\documents\programming\github\etl\test\test_list.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_list.cpp "ExtraCheckMacros.h" "../list.h" @@ -3423,13 +3429,13 @@ -1449838910 d:\users\john\documents\programming\github\etl\list.h +1452337456 d:\users\john\documents\programming\github\etl\list.h "ilist.h" "container.h" "pool.h" -1449847976 d:\users\john\documents\programming\github\etl\ilist.h +1452333625 d:\users\john\documents\programming\github\etl\ilist.h @@ -3444,43 +3450,43 @@ "exception.h" -1443462794 source:d:\users\john\documents\programming\github\etl\test\test_maths.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_maths.cpp "../log.h" "../power.h" "../fibonacci.h" "../factorial.h" -1449838910 d:\users\john\documents\programming\github\etl\fibonacci.h +1450265856 d:\users\john\documents\programming\github\etl\fibonacci.h -1449838910 d:\users\john\documents\programming\github\etl\factorial.h +1450265856 d:\users\john\documents\programming\github\etl\factorial.h -1424726109 source:d:\users\john\documents\programming\github\etl\test\test_numeric.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_numeric.cpp "../numeric.h" -1449838910 d:\users\john\documents\programming\github\etl\numeric.h +1450265856 d:\users\john\documents\programming\github\etl\numeric.h -1424726109 source:d:\users\john\documents\programming\github\etl\test\test_observer.cpp +1450468191 source:d:\users\john\documents\programming\github\etl\test\test_observer.cpp "../observer.h" -1449838910 d:\users\john\documents\programming\github\etl\observer.h +1450959449 d:\users\john\documents\programming\github\etl\observer.h "vector.h" "exception.h" "error_handler.h" -1424726109 source:d:\users\john\documents\programming\github\etl\test\test_queue.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_queue.cpp "../queue.h" -1449838910 d:\users\john\documents\programming\github\etl\queue.h +1450265856 d:\users\john\documents\programming\github\etl\queue.h "iqueue.h" @@ -3488,7 +3494,7 @@ "alignment.h" "array.h" -1449838910 d:\users\john\documents\programming\github\etl\iqueue.h +1452203243 d:\users\john\documents\programming\github\etl\iqueue.h "private/queue_base.h" "type_traits.h" @@ -3499,18 +3505,18 @@ "exception.h" -1424726109 source:d:\users\john\documents\programming\github\etl\test\test_smallest.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_smallest.cpp "../smallest.h" -1424726109 source:d:\users\john\documents\programming\github\etl\test\test_stack.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_stack.cpp "data.h" "../stack.h" -1449838910 d:\users\john\documents\programming\github\etl\stack.h +1450265856 d:\users\john\documents\programming\github\etl\stack.h @@ -3519,7 +3525,7 @@ "alignment.h" "array.h" -1449838910 d:\users\john\documents\programming\github\etl\istack.h +1452203243 d:\users\john\documents\programming\github\etl\istack.h "private/stack_base.h" "type_traits.h" @@ -3530,67 +3536,71 @@ "exception.h" -1449848286 source:d:\users\john\documents\programming\github\etl\test\test_vector.cpp +1452338102 source:d:\users\john\documents\programming\github\etl\test\test_vector.cpp "../vector.h" -1424726109 source:d:\users\john\documents\programming\github\etl\test\test_visitor.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_visitor.cpp "../visitor.h" -1449838910 d:\users\john\documents\programming\github\etl\visitor.h +1450265856 d:\users\john\documents\programming\github\etl\visitor.h -1449838740 source:d:\users\john\documents\programming\github\etl\test\test_fixed_iterator.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_fixed_iterator.cpp "../fixed_iterator.h" -1449839077 d:\users\john\documents\programming\github\etl\fixed_iterator.h +1450265856 d:\users\john\documents\programming\github\etl\fixed_iterator.h 1414845610 source:d:\users\john\documents\programming\github\unittest-cpp\unittest++\win32\timehelpers.cpp "TimeHelpers.h" -1449844020 d:\users\john\documents\programming\github\etl\private\deque_base.h +1450265856 d:\users\john\documents\programming\github\etl\private\deque_base.h "../exception.h" + "../error_handler.h" -1449844216 d:\users\john\documents\programming\github\etl\private\flat_map_base.h +1450265856 d:\users\john\documents\programming\github\etl\private\flat_map_base.h "../exception.h" "../ivector.h" - "error_handler.h" + "../error_handler.h" -1449844020 d:\users\john\documents\programming\github\etl\private\vector_base.h +1450959449 d:\users\john\documents\programming\github\etl\private\vector_base.h "../exception.h" - "error_handler.h" + "../error_handler.h" -1449844237 d:\users\john\documents\programming\github\etl\private\flat_set_base.h +1450265856 d:\users\john\documents\programming\github\etl\private\flat_set_base.h "../exception.h" "../ivector.h" - "error_handler.h" + "../error_handler.h" -1449844020 d:\users\john\documents\programming\github\etl\private\pool_base.h +1452796556 d:\users\john\documents\programming\github\etl\private\pool_base.h "../exception.h" - "error_handler.h" + "../error_handler.h" + "../error_handler.h" -1449844020 d:\users\john\documents\programming\github\etl\private\forward_list_base.h +1450959449 d:\users\john\documents\programming\github\etl\private\forward_list_base.h "../exception.h" + "../error_handler.h" -1449844020 d:\users\john\documents\programming\github\etl\private\list_base.h +1450959449 d:\users\john\documents\programming\github\etl\private\list_base.h "../exception.h" + "../error_handler.h" -1435083222 source:d:\users\john\documents\programming\github\etl\test\test_map.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_map.cpp @@ -3601,7 +3611,7 @@ "../map.h" -1449838910 d:\users\john\documents\programming\github\etl\map.h +1452337350 d:\users\john\documents\programming\github\etl\map.h @@ -3609,7 +3619,7 @@ "container.h" "pool.h" -1449844974 d:\users\john\documents\programming\github\etl\imap.h +1452333665 d:\users\john\documents\programming\github\etl\imap.h @@ -3620,11 +3630,12 @@ "parameter_type.h" "pool.h" -1449845229 d:\users\john\documents\programming\github\etl\private\map_base.h +1450265856 d:\users\john\documents\programming\github\etl\private\map_base.h "../exception.h" + "../error_handler.h" -1443462794 source:d:\users\john\documents\programming\github\etl\test\test_optional.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_optional.cpp @@ -3632,12 +3643,13 @@ "../vector.h" "data.h" -1449838910 d:\users\john\documents\programming\github\etl\optional.h +1452796556 d:\users\john\documents\programming\github\etl\optional.h "alignment.h" "type_traits.h" "exception.h" + "error_handler.h" -1449848575 source:d:\users\john\documents\programming\github\etl\test\test_pool.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_pool.cpp "ExtraCheckMacros.h" "data.h" @@ -3645,11 +3657,12 @@ "../pool.h" -1449844020 d:\users\john\documents\programming\github\etl\private\queue_base.h +1450265856 d:\users\john\documents\programming\github\etl\private\queue_base.h "../exception.h" + "../error_handler.h" -1443462794 source:d:\users\john\documents\programming\github\etl\test\test_set.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_set.cpp @@ -3660,7 +3673,7 @@ "../set.h" -1449838910 d:\users\john\documents\programming\github\etl\set.h +1452337350 d:\users\john\documents\programming\github\etl\set.h @@ -3668,7 +3681,7 @@ "container.h" "pool.h" -1449838910 d:\users\john\documents\programming\github\etl\iset.h +1452333782 d:\users\john\documents\programming\github\etl\iset.h @@ -3679,20 +3692,22 @@ "parameter_type.h" "pool.h" -1449845257 d:\users\john\documents\programming\github\etl\private\set_base.h +1450265856 d:\users\john\documents\programming\github\etl\private\set_base.h "../exception.h" + "../error_handler.h" -1449844020 d:\users\john\documents\programming\github\etl\private\stack_base.h +1450959449 d:\users\john\documents\programming\github\etl\private\stack_base.h "../exception.h" + "../error_handler.h" -1449845425 source:d:\users\john\documents\programming\github\etl\test\test_type_traits.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_type_traits.cpp "../type_traits.h" -1449852797 source:d:\users\john\documents\programming\github\etl\test\test_variant.cpp +1450265856 source:d:\users\john\documents\programming\github\etl\test\test_variant.cpp "ExtraCheckMacros.h" "../variant.h" @@ -3700,7 +3715,7 @@ -1449848793 d:\users\john\documents\programming\github\etl\variant.h +1450265856 d:\users\john\documents\programming\github\etl\variant.h "array.h" "largest.h" @@ -4769,3 +4784,28 @@ 1452516033 /home/jwellbelove/Programming/etl/visitor.h +1453405766 source:d:\users\john\documents\programming\github\etl\test\test_intrusive_forward_list.cpp + + "ExtraCheckMacros.h" + "data.h" + "../intrusive_forward_list.h" + + + + + + + +1453405528 d:\users\john\documents\programming\github\etl\intrusive_forward_list.h + + + + + "nullptr.h" + "type_traits.h" + "intrusive_forward_list_link.h" + +1453324561 d:\users\john\documents\programming\github\etl\intrusive_forward_list_link.h + "error_handler.h" + "array.h" + diff --git a/test/codeblocks/ETL.layout b/test/codeblocks/ETL.layout index 89345761..8a4a301d 100644 --- a/test/codeblocks/ETL.layout +++ b/test/codeblocks/ETL.layout @@ -1,389 +1,314 @@ - - + + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From a0b93c46fa5fc993a3c36aa8405587961653e4b9 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 23 Jan 2016 12:07:40 +0000 Subject: [PATCH 3/7] Added intrusive link definitions. forward_link, bidirectional_link, tree_link --- intrusive_links.h | 122 +++++++++++++++++++++++++++++++ test/test_intrusive_links.cpp | 133 ++++++++++++++++++++++++++++++++++ 2 files changed, 255 insertions(+) create mode 100644 intrusive_links.h create mode 100644 test/test_intrusive_links.cpp diff --git a/intrusive_links.h b/intrusive_links.h new file mode 100644 index 00000000..e3101277 --- /dev/null +++ b/intrusive_links.h @@ -0,0 +1,122 @@ +///\file + +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +http://www.etlcpp.com + +Copyright(c) 2016 jwellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#ifndef __ETL_INTRUSIVE_LINKS__ +#define __ETL_INTRUSIVE_LINKS__ + +#include "nullptr.h" + +namespace etl +{ + namespace link_option + { + enum + { + NO_AUTO_UNLINK = false, + AUTO_UNLINK = true + }; + }; + + //*************************************************************************** + /// A forward link. + //*************************************************************************** + template + struct forward_link + { + enum + { + ID = ID_ + }; + + forward_link* etl_next; + }; + + //*************************************************************************** + /// A bidirectional link. + //*************************************************************************** + template + struct bidirectional_link + { + enum + { + ID = ID_, + }; + + bidirectional_link* etl_previous; + bidirectional_link* etl_next; + }; + + // Specialisation for auto unlinked option. + // When this link is destroyed it will automatically unlink itself. + template + struct bidirectional_link + { + enum + { + ID = ID_ + }; + + ~bidirectional_link() + { + // Connect the previous link with the next. + if (etl_previous != nullptr) + { + etl_previous->etl_next = etl_next; + } + + // Connect the next link with the previous. + if (etl_next != nullptr) + { + etl_next->etl_previous = etl_previous; + } + } + + bidirectional_link* etl_previous; + bidirectional_link* etl_next; + }; + + //*************************************************************************** + /// A tree link. + //*************************************************************************** + template + struct tree_link + { + enum + { + ID = ID_ + }; + + tree_link* etl_parent; + tree_link* etl_left; + tree_link* etl_right; + }; +} + +#endif diff --git a/test/test_intrusive_links.cpp b/test/test_intrusive_links.cpp new file mode 100644 index 00000000..1b7cc0c9 --- /dev/null +++ b/test/test_intrusive_links.cpp @@ -0,0 +1,133 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +http://www.etlcpp.com + +Copyright(c) 2016 jwellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#include +#include "ExtraCheckMacros.h" + +#include "data.h" + +#include "../intrusive_links.h" + +namespace +{ + //******************************************************* + typedef etl::bidirectional_link<0, etl::link_option::AUTO_UNLINK> FirstLink; + typedef etl::bidirectional_link<1> SecondLink; + + struct Data : public FirstLink, public SecondLink + { + Data(int value) + : value(value) + { + } + + int value; + }; + + //******************************************************* + bool operator ==(const Data& lhs, const Data& rhs) + { + return lhs.value == rhs.value; + } + + bool operator !=(const Data& lhs, const Data& rhs) + { + return !(lhs == rhs); + } + + //******************************************************* + template + void join(TLink* lhs, TLink* rhs) + { + if ((lhs == nullptr) && (rhs != nullptr)) + { + rhs->etl_previous = nullptr; + } + else if ((lhs != nullptr) && (rhs == nullptr)) + { + lhs->etl_next = nullptr; + } + else if ((lhs != nullptr) && (rhs != nullptr)) + { + lhs->etl_next = rhs; + rhs->etl_previous = lhs; + } + } + + SUITE(test_forward_list) + { + //************************************************************************* + TEST(test_bidirectional_link) + { + // FirstLink is auto-unlink, SecondLink is not. + + Data* data0 = new Data(0); + Data* data1 = new Data(1); + Data* data2 = new Data(2); + Data* data3 = new Data(3); + + join(nullptr, data0); + join(data0, data1); + join(data1, data2); + join(data2, data3); + join(data3, nullptr); + + join(nullptr, data0); + join(data0, data1); + join(data1, data2); + join(data2, data3); + join(data3, nullptr); + + delete data1; + CHECK(data0->FirstLink::etl_next == data2); + CHECK(data2->FirstLink::etl_previous == data0); + + CHECK(data0->SecondLink::etl_next != data2); + CHECK(data0->SecondLink::etl_next != nullptr); + CHECK(data2->SecondLink::etl_previous != data0); + CHECK(data2->SecondLink::etl_previous != nullptr); + + delete data0; + CHECK(data2->FirstLink::etl_next == data3); + CHECK(data2->FirstLink::etl_previous == nullptr); + CHECK(data3->FirstLink::etl_previous == data2); + + CHECK(data2->SecondLink::etl_next == data3); + CHECK(data3->SecondLink::etl_previous != nullptr); + + delete data3; + CHECK(data2->FirstLink::etl_next == nullptr); + CHECK(data2->FirstLink::etl_previous == nullptr); + + CHECK(data2->SecondLink::etl_next != nullptr); + CHECK(data2->SecondLink::etl_previous != nullptr); + + delete data2; + } + }; +} From 4ce799c97acbab1086110c877e4c73be53e81a37 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 23 Jan 2016 12:08:00 +0000 Subject: [PATCH 4/7] Deleted unecessary file. --- intrusive_forward_list_node.h | 49 ----------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 intrusive_forward_list_node.h diff --git a/intrusive_forward_list_node.h b/intrusive_forward_list_node.h deleted file mode 100644 index 1d8d8ae7..00000000 --- a/intrusive_forward_list_node.h +++ /dev/null @@ -1,49 +0,0 @@ -///\file - -/****************************************************************************** -The MIT License(MIT) - -Embedded Template Library. -https://github.com/ETLCPP/etl -http://www.etlcpp.com - -Copyright(c) 2015 jwellbelove - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files(the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and / or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions : - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -******************************************************************************/ - -#ifndef __ETL_INTRUSIVE_FORWARD_LIST_NODE__ -#define __ETL_INTRUSIVE_FORWARD_LIST_NODE__ - -#include "error_handler.h" -#include "array.h" - -namespace etl -{ - //*************************************************************************** - /// The node element in the intrusive_forward_list. - //*************************************************************************** - template - struct intrusive_forward_list_node - { - intrusive_list_tag* ifln_next; - }; -} - -#endif From 44b3598f14c9eef05e429bf2e05e022df933c430 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 23 Jan 2016 12:08:27 +0000 Subject: [PATCH 5/7] Modified to use new intrusive link type. --- iunordered_map.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iunordered_map.h b/iunordered_map.h index 4bad1eff..09d0496f 100644 --- a/iunordered_map.h +++ b/iunordered_map.h @@ -133,7 +133,7 @@ namespace etl typedef typename parameter_type::type key_value_parameter_t; - typedef etl::intrusive_forward_list_link<> link_t; // Default link. + typedef etl::forward_link<> link_t; // Default link. // The nodes that store the elements. struct node_t : public link_t @@ -893,7 +893,7 @@ namespace etl local_iterator iprevious = bucket.before_begin(); // Find the node we're interested in. - while (iprevious->ifll_next != &*icurrent) + while (iprevious->etl_next != &*icurrent) { ++iprevious; } @@ -922,7 +922,7 @@ namespace etl local_iterator iend; // Find the first node we're interested in. - while (iprevious->ifll_next != &*ifirst) + while (iprevious->etl_next != &*ifirst) { ++iprevious; } From a3c61df399423fd7754165118b51246417ca26c0 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 23 Jan 2016 12:08:50 +0000 Subject: [PATCH 6/7] Modified to use new intrusive link type. --- intrusive_forward_list.h | 67 +++++++++++++++------------- test/test_intrusive_forward_list.cpp | 4 +- 2 files changed, 39 insertions(+), 32 deletions(-) diff --git a/intrusive_forward_list.h b/intrusive_forward_list.h index 75f1a000..a66a451e 100644 --- a/intrusive_forward_list.h +++ b/intrusive_forward_list.h @@ -42,7 +42,12 @@ SOFTWARE. #include "nullptr.h" #include "type_traits.h" -#include "intrusive_forward_list_link.h" +#include "exception.h" +#include "error_handler.h" +#include "intrusive_links.h" + +#undef ETL_FILE +#define ETL_FILE "20" namespace etl { @@ -107,7 +112,7 @@ namespace etl ///\ingroup intrusive_forward_list ///\note TLink must be a base of TValue. //*************************************************************************** - template > + template > class intrusive_forward_list { public: @@ -151,16 +156,16 @@ namespace etl iterator& operator ++() { - // Read the appropriate 'ifll_next'. - p_value = static_cast(p_value->link_type::ifll_next); + // Read the appropriate 'etl_next'. + p_value = static_cast(p_value->link_type::etl_next); return *this; } iterator operator ++(int) { iterator temp(*this); - // Read the appropriate 'ifll_next'. - p_value = static_cast(p_value->link_type::ifll_next); + // Read the appropriate 'etl_next'. + p_value = static_cast(p_value->link_type::etl_next); return temp; } @@ -246,16 +251,16 @@ namespace etl const_iterator& operator ++() { - // Read the appropriate 'ifll_next'. - p_value = static_cast(p_value->link_type::ifll_next); + // Read the appropriate 'etl_next'. + p_value = static_cast(p_value->link_type::etl_next); return *this; } const_iterator operator ++(int) { const_iterator temp(*this); - // Read the appropriate 'ifll_next'. - p_value = static_cast(p_value->link_type::ifll_next); + // Read the appropriate 'etl_next'. + p_value = static_cast(p_value->link_type::etl_next); return temp; } @@ -458,16 +463,16 @@ namespace etl return; } - link_type* first = nullptr; // To keep first link - link_type* second = start_link.ifll_next; // To keep second link - link_type* track = start_link.ifll_next; // Track the list + link_type* first = nullptr; // To keep first link + link_type* second = start_link.etl_next; // To keep second link + link_type* track = start_link.etl_next; // Track the list while (track != NULL) { - track = track->ifll_next; // Track point to next link; - second->ifll_next = first; // Second link point to first - first = second; // Move first link to next - second = track; // Move second link to next + track = track->etl_next; // Track point to next link; + second->etl_next = first; // Second link point to first + first = second; // Move first link to next + second = track; // Move second link to next } join(&start_link, first); @@ -518,7 +523,7 @@ namespace etl { link_type* p_first = first.p_value; link_type* p_last = last.p_value; - link_type* p_next = p_first->ifll_next; + link_type* p_next = p_first->etl_next; // Join the ends. join(p_first, p_last); @@ -531,8 +536,8 @@ namespace etl // One less. --current_size; - p_next = p_first->ifll_next; // Remember the next link. - p_first = p_next; // Move to the next link. + p_next = p_first->etl_next; // Remember the next link. + p_first = p_next; // Move to the next link. } if (p_next == nullptr) @@ -558,7 +563,7 @@ namespace etl } link_type* last = &get_head(); - link_type* current = last->ifll_next; + link_type* current = last->etl_next; while (current != nullptr) { @@ -573,7 +578,7 @@ namespace etl last = current; } - current = last->ifll_next; + current = last->etl_next; } } @@ -684,7 +689,7 @@ namespace etl i_tail = i_link; } - i_tail.p_value->link_type::ifll_next = nullptr; + i_tail.p_value->link_type::etl_next = nullptr; } // Now left has stepped `list_size' places along, and right has too. @@ -774,7 +779,7 @@ namespace etl //************************************************************************* void join(link_type* left, link_type* right) { - left->ifll_next = right; + left->etl_next = right; } //************************************************************************* @@ -791,7 +796,7 @@ namespace etl void insert_link_after(link_type& position, link_type& link) { // Connect to the intrusive_forward_list. - join(&link, position.ifll_next); + join(&link, position.etl_next); join(&position, &link); ++current_size; } @@ -802,12 +807,12 @@ namespace etl void remove_link_after(link_type& link) { // The link to erase. - link_type* p_link = link.ifll_next; + link_type* p_link = link.etl_next; if (p_link != nullptr) { // Disconnect the link from the intrusive_forward_list. - join(&link, p_link->ifll_next); + join(&link, p_link->etl_next); --current_size; } } @@ -817,7 +822,7 @@ namespace etl //************************************************************************* link_type& get_head() { - return *start_link.ifll_next; + return *start_link.etl_next; } //************************************************************************* @@ -825,7 +830,7 @@ namespace etl //************************************************************************* const link_type& get_head() const { - return *start_link.ifll_next; + return *start_link.etl_next; } //************************************************************************* @@ -833,7 +838,7 @@ namespace etl //************************************************************************* void initialise() { - start_link.ifll_next = nullptr; + start_link.etl_next = nullptr; current_size = 0; } @@ -847,4 +852,6 @@ namespace etl #define min(a,b) (((a) < (b)) ? (a) : (b)) #endif +#undef ETL_FILE + #endif diff --git a/test/test_intrusive_forward_list.cpp b/test/test_intrusive_forward_list.cpp index 68518ffb..847ac82b 100644 --- a/test/test_intrusive_forward_list.cpp +++ b/test/test_intrusive_forward_list.cpp @@ -45,8 +45,8 @@ typedef TestDataNDC ItemNDC; namespace { - typedef etl::intrusive_forward_list_link<0> FirstLink; - typedef etl::intrusive_forward_list_link<1> SecondLink; + typedef etl::forward_link<0> FirstLink; + typedef etl::forward_link<1> SecondLink; //*************************************************************************** class ItemDCNode : public FirstLink, public SecondLink From 7e214ffbee5a4be3028ae499429c3d21fcd7bf87 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 23 Jan 2016 12:09:52 +0000 Subject: [PATCH 7/7] Added new intrusive link types. --- test/vs2015/etl.vcxproj | 3 ++- test/vs2015/etl.vcxproj.filters | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test/vs2015/etl.vcxproj b/test/vs2015/etl.vcxproj index 05227085..20ca6e02 100644 --- a/test/vs2015/etl.vcxproj +++ b/test/vs2015/etl.vcxproj @@ -205,7 +205,7 @@ - + @@ -337,6 +337,7 @@ + diff --git a/test/vs2015/etl.vcxproj.filters b/test/vs2015/etl.vcxproj.filters index d1fd4d1b..072f9405 100644 --- a/test/vs2015/etl.vcxproj.filters +++ b/test/vs2015/etl.vcxproj.filters @@ -390,9 +390,6 @@ ETL\Containers - - ETL\Containers - ETL\Private @@ -465,6 +462,9 @@ ETL\Containers + + ETL\Containers + @@ -710,6 +710,9 @@ Source Files + + Source Files +