mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-28 13:28:43 +08:00
Optimised compare class construction and usage.
This commit is contained in:
parent
fb7eb70c47
commit
d41856c7ed
@ -101,13 +101,15 @@ namespace etl
|
||||
|
||||
bool operator ()(const value_type& element, key_type key) const
|
||||
{
|
||||
return key_compare()(element.first, key);
|
||||
return comp(element.first, key);
|
||||
}
|
||||
|
||||
bool operator ()(key_type key, const value_type& element) const
|
||||
{
|
||||
return key_compare()(key, element.first);
|
||||
return comp(key, element.first);
|
||||
}
|
||||
|
||||
key_compare comp;
|
||||
};
|
||||
|
||||
public:
|
||||
@ -300,7 +302,7 @@ namespace etl
|
||||
std::pair<iterator, bool> result(i_element, false);
|
||||
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end()) || TKeyCompare()(i_element->first, value.first) || TKeyCompare()(value.first, i_element->first))
|
||||
if ((i_element == end()) || compare(i_element->first, value.first) || compare(value.first, i_element->first))
|
||||
{
|
||||
ETL_ASSERT(!refmap_t::full(), ETL_ERROR(flat_map_full));
|
||||
|
||||
@ -764,6 +766,8 @@ namespace etl
|
||||
|
||||
storage_t& storage;
|
||||
|
||||
TKeyCompare compare;
|
||||
|
||||
/// Internal debugging.
|
||||
ETL_DECLARE_DEBUG_COUNT;
|
||||
|
||||
|
||||
@ -103,13 +103,15 @@ namespace etl
|
||||
|
||||
bool operator ()(const value_type& element, key_type key) const
|
||||
{
|
||||
return key_compare()(element.first, key);
|
||||
return comp(element.first, key);
|
||||
}
|
||||
|
||||
bool operator ()(key_type key, const value_type& element) const
|
||||
{
|
||||
return key_compare()(key, element.first);
|
||||
return comp(key, element.first);
|
||||
}
|
||||
|
||||
key_compare comp;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
@ -232,7 +232,7 @@ namespace etl
|
||||
|
||||
ETL_ASSERT(!full(), ETL_ERROR(flat_multiset_full));
|
||||
|
||||
iterator i_element = std::lower_bound(begin(), end(), value, TKeyCompare());
|
||||
iterator i_element = std::lower_bound(begin(), end(), value, compare);
|
||||
|
||||
value_type* pvalue = storage.allocate<value_type>();
|
||||
::new (pvalue) value_type(value);
|
||||
@ -605,6 +605,8 @@ namespace etl
|
||||
|
||||
storage_t& storage;
|
||||
|
||||
TKeyCompare compare;
|
||||
|
||||
/// Internal debugging.
|
||||
ETL_DECLARE_DEBUG_COUNT;
|
||||
|
||||
|
||||
@ -233,7 +233,7 @@ namespace etl
|
||||
std::pair<iterator, bool> result(i_element, false);
|
||||
|
||||
// Doesn't already exist?
|
||||
if ((i_element == end()) || TKeyCompare()(*i_element, value) || TKeyCompare()(value, *i_element))
|
||||
if ((i_element == end()) || compare(*i_element, value) || compare(value, *i_element))
|
||||
{
|
||||
ETL_ASSERT(!refset_t::full(), ETL_ERROR(flat_set_full));
|
||||
|
||||
@ -671,6 +671,8 @@ namespace etl
|
||||
|
||||
storage_t& storage;
|
||||
|
||||
TKeyCompare compare;
|
||||
|
||||
/// Internal debugging.
|
||||
ETL_DECLARE_DEBUG_COUNT;
|
||||
|
||||
|
||||
@ -481,7 +481,7 @@ namespace etl
|
||||
{
|
||||
bool operator ()(const key_type& key1, const key_type& key2) const
|
||||
{
|
||||
return key_compare()(key1, key2);
|
||||
return compare(key1, key2);
|
||||
}
|
||||
};
|
||||
|
||||
@ -492,7 +492,7 @@ namespace etl
|
||||
{
|
||||
bool operator ()(const value_type& value1, const value_type& value2) const
|
||||
{
|
||||
return key_compare()(value1.first, value2.first);
|
||||
return compare(value1.first, value2.first);
|
||||
}
|
||||
};
|
||||
|
||||
@ -524,15 +524,15 @@ namespace etl
|
||||
//*************************************************************************
|
||||
bool node_comp(const Data_Node& node1, const Data_Node& node2) const
|
||||
{
|
||||
return key_compare()(node1.value.first, node2.value.first);
|
||||
return compare(node1.value.first, node2.value.first);
|
||||
}
|
||||
bool node_comp(const Data_Node& node, key_parameter_t key) const
|
||||
{
|
||||
return key_compare()(node.value.first, key);
|
||||
return compare(node.value.first, key);
|
||||
}
|
||||
bool node_comp(key_parameter_t key, const Data_Node& node) const
|
||||
{
|
||||
return key_compare()(key, node.value.first);
|
||||
return compare(key, node.value.first);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -540,6 +540,8 @@ namespace etl
|
||||
/// The pool of data nodes used in the map.
|
||||
ipool* p_node_pool;
|
||||
|
||||
key_compare compare;
|
||||
|
||||
//*************************************************************************
|
||||
/// Downcast a Node* to a Data_Node*
|
||||
//*************************************************************************
|
||||
|
||||
@ -638,7 +638,7 @@ namespace etl
|
||||
{
|
||||
bool operator ()(const key_type& key1, const key_type& key2) const
|
||||
{
|
||||
return key_compare()(key1, key2);
|
||||
return compare(key1, key2);
|
||||
}
|
||||
};
|
||||
|
||||
@ -649,7 +649,7 @@ namespace etl
|
||||
{
|
||||
bool operator ()(const value_type& value1, const value_type& value2) const
|
||||
{
|
||||
return key_compare()(value1.first, value2.first);
|
||||
return compare(value1.first, value2.first);
|
||||
}
|
||||
};
|
||||
|
||||
@ -676,17 +676,17 @@ namespace etl
|
||||
//*************************************************************************
|
||||
bool node_comp(const Data_Node& node1, const Data_Node& node2) const
|
||||
{
|
||||
return key_compare()(node1.value.first, node2.value.first);
|
||||
return compare(node1.value.first, node2.value.first);
|
||||
}
|
||||
|
||||
bool node_comp(const Data_Node& node, key_parameter_t key) const
|
||||
{
|
||||
return key_compare()(node.value.first, key);
|
||||
return compare(node.value.first, key);
|
||||
}
|
||||
|
||||
bool node_comp(key_parameter_t key, const Data_Node& node) const
|
||||
{
|
||||
return key_compare()(key, node.value.first);
|
||||
return compare(key, node.value.first);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -694,6 +694,8 @@ namespace etl
|
||||
/// The pool of data nodes used in the multimap.
|
||||
ipool* p_node_pool;
|
||||
|
||||
key_compare compare;
|
||||
|
||||
//*************************************************************************
|
||||
/// Downcast a Node* to a Data_Node*
|
||||
//*************************************************************************
|
||||
|
||||
@ -636,7 +636,7 @@ namespace etl
|
||||
{
|
||||
bool operator ()(key_type& key1, key_type& key2) const
|
||||
{
|
||||
return key_compare()(key1, key2);
|
||||
return compare(key1, key2);
|
||||
}
|
||||
};
|
||||
|
||||
@ -647,7 +647,7 @@ namespace etl
|
||||
{
|
||||
bool operator ()(value_type& value1, value_type& value2) const
|
||||
{
|
||||
return value_compare()(value1, value2);
|
||||
return compare(value1, value2);
|
||||
}
|
||||
};
|
||||
|
||||
@ -674,15 +674,15 @@ namespace etl
|
||||
//*************************************************************************
|
||||
bool node_comp(const Data_Node& node1, const Data_Node& node2) const
|
||||
{
|
||||
return key_compare()(node1.value, node2.value);
|
||||
return compare(node1.value, node2.value);
|
||||
}
|
||||
bool node_comp(const Data_Node& node, key_parameter_t key) const
|
||||
{
|
||||
return key_compare()(node.value, key);
|
||||
return compare(node.value, key);
|
||||
}
|
||||
bool node_comp(key_parameter_t key, const Data_Node& node) const
|
||||
{
|
||||
return key_compare()(key, node.value);
|
||||
return compare(key, node.value);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -690,6 +690,8 @@ namespace etl
|
||||
/// The pool of data nodes used in the multiset.
|
||||
ipool* p_node_pool;
|
||||
|
||||
key_compare compare;
|
||||
|
||||
//*************************************************************************
|
||||
/// Downcast a Node* to a Data_Node*
|
||||
//*************************************************************************
|
||||
|
||||
@ -165,7 +165,7 @@ namespace etl
|
||||
// Put element at end
|
||||
container.push_back(value);
|
||||
// Make elements in container into heap
|
||||
std::push_heap(container.begin(), container.end(), TCompare());
|
||||
std::push_heap(container.begin(), container.end(), compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -182,7 +182,7 @@ namespace etl
|
||||
// Put element at end
|
||||
container.emplace_back(value1);
|
||||
// Make elements in container into heap
|
||||
std::push_heap(container.begin(), container.end(), TCompare());
|
||||
std::push_heap(container.begin(), container.end(), compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -199,7 +199,7 @@ namespace etl
|
||||
// Put element at end
|
||||
container.emplace_back(value1, value2);
|
||||
// Make elements in container into heap
|
||||
std::push_heap(container.begin(), container.end(), TCompare());
|
||||
std::push_heap(container.begin(), container.end(), compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -216,7 +216,7 @@ namespace etl
|
||||
// Put element at end
|
||||
container.emplace_back(value1, value2, value3);
|
||||
// Make elements in container into heap
|
||||
std::push_heap(container.begin(), container.end(), TCompare());
|
||||
std::push_heap(container.begin(), container.end(), compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -233,7 +233,7 @@ namespace etl
|
||||
// Put element at end
|
||||
container.emplace_back(value1, value2, value3, value4);
|
||||
// Make elements in container into heap
|
||||
std::push_heap(container.begin(), container.end(), TCompare());
|
||||
std::push_heap(container.begin(), container.end(), compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -256,7 +256,7 @@ namespace etl
|
||||
|
||||
clear();
|
||||
container.assign(first, last);
|
||||
std::make_heap(container.begin(), container.end(), TCompare());
|
||||
std::make_heap(container.begin(), container.end(), compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -266,7 +266,7 @@ namespace etl
|
||||
void pop()
|
||||
{
|
||||
// Move largest element to end
|
||||
std::pop_heap(container.begin(), container.end(), TCompare());
|
||||
std::pop_heap(container.begin(), container.end(), compare);
|
||||
// Actually remove largest element at end
|
||||
container.pop_back();
|
||||
}
|
||||
@ -356,6 +356,8 @@ namespace etl
|
||||
|
||||
/// The container specified at instantiation of the priority_queue
|
||||
TContainer container;
|
||||
|
||||
TCompare compare;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
@ -329,19 +329,21 @@ namespace etl
|
||||
//*********************************************************************
|
||||
/// How to compare elements and keys.
|
||||
//*********************************************************************
|
||||
class compare
|
||||
class Compare
|
||||
{
|
||||
public:
|
||||
|
||||
bool operator ()(const value_type& element, key_type key) const
|
||||
{
|
||||
return key_compare()(element.first, key);
|
||||
return comp(element.first, key);
|
||||
}
|
||||
|
||||
bool operator ()(key_type key, const value_type& element) const
|
||||
{
|
||||
return key_compare()(key, element.first);
|
||||
return comp(key, element.first);
|
||||
}
|
||||
|
||||
key_compare comp;
|
||||
};
|
||||
|
||||
public:
|
||||
@ -690,7 +692,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator lower_bound(key_parameter_t key)
|
||||
{
|
||||
return std::lower_bound(begin(), end(), key, compare());
|
||||
return std::lower_bound(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -700,7 +702,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator lower_bound(key_parameter_t key) const
|
||||
{
|
||||
return std::lower_bound(cbegin(), cend(), key, compare());
|
||||
return std::lower_bound(cbegin(), cend(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -710,7 +712,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator upper_bound(key_parameter_t key)
|
||||
{
|
||||
return std::upper_bound(begin(), end(), key, compare());
|
||||
return std::upper_bound(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -720,7 +722,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator upper_bound(key_parameter_t key) const
|
||||
{
|
||||
return std::upper_bound(begin(), end(), key, compare());
|
||||
return std::upper_bound(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -730,9 +732,9 @@ namespace etl
|
||||
//*********************************************************************
|
||||
std::pair<iterator, iterator> equal_range(key_parameter_t key)
|
||||
{
|
||||
iterator i_lower = std::lower_bound(begin(), end(), key, compare());
|
||||
iterator i_lower = std::lower_bound(begin(), end(), key, compare);
|
||||
|
||||
return std::make_pair(i_lower, std::upper_bound(i_lower, end(), key, compare()));
|
||||
return std::make_pair(i_lower, std::upper_bound(i_lower, end(), key, compare));
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -742,9 +744,9 @@ namespace etl
|
||||
//*********************************************************************
|
||||
std::pair<const_iterator, const_iterator> equal_range(key_parameter_t key) const
|
||||
{
|
||||
const_iterator i_lower = std::lower_bound(cbegin(), cend(), key, compare());
|
||||
const_iterator i_lower = std::lower_bound(cbegin(), cend(), key, compare);
|
||||
|
||||
return std::make_pair(i_lower, std::upper_bound(i_lower, cend(), key, compare()));
|
||||
return std::make_pair(i_lower, std::upper_bound(i_lower, cend(), key, compare));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -855,6 +857,8 @@ namespace etl
|
||||
|
||||
lookup_t& lookup;
|
||||
|
||||
Compare compare;
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
//*************************************************************************
|
||||
|
||||
@ -304,19 +304,21 @@ namespace etl
|
||||
//*********************************************************************
|
||||
/// How to compare elements and keys.
|
||||
//*********************************************************************
|
||||
class compare
|
||||
class Compare
|
||||
{
|
||||
public:
|
||||
|
||||
bool operator ()(const value_type& element, key_type key) const
|
||||
{
|
||||
return key_compare()(element.first, key);
|
||||
return comp(element.first, key);
|
||||
}
|
||||
|
||||
bool operator ()(key_type key, const value_type& element) const
|
||||
{
|
||||
return key_compare()(key, element.first);
|
||||
return comp(key, element.first);
|
||||
}
|
||||
|
||||
key_compare comp;
|
||||
};
|
||||
|
||||
public:
|
||||
@ -612,7 +614,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator lower_bound(key_parameter_t key)
|
||||
{
|
||||
return std::lower_bound(begin(), end(), key, compare());
|
||||
return std::lower_bound(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -622,7 +624,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator lower_bound(key_parameter_t key) const
|
||||
{
|
||||
return std::lower_bound(cbegin(), cend(), key, compare());
|
||||
return std::lower_bound(cbegin(), cend(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -632,7 +634,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator upper_bound(key_parameter_t key)
|
||||
{
|
||||
return std::upper_bound(begin(), end(), key, compare());
|
||||
return std::upper_bound(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -642,7 +644,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator upper_bound(key_parameter_t key) const
|
||||
{
|
||||
return std::upper_bound(begin(), end(), key, compare());
|
||||
return std::upper_bound(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -652,9 +654,9 @@ namespace etl
|
||||
//*********************************************************************
|
||||
std::pair<iterator, iterator> equal_range(key_parameter_t key)
|
||||
{
|
||||
iterator i_lower = std::lower_bound(begin(), end(), key, compare());
|
||||
iterator i_lower = std::lower_bound(begin(), end(), key, compare);
|
||||
|
||||
return std::make_pair(i_lower, std::upper_bound(i_lower, end(), key, compare()));
|
||||
return std::make_pair(i_lower, std::upper_bound(i_lower, end(), key, compare));
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -664,9 +666,9 @@ namespace etl
|
||||
//*********************************************************************
|
||||
std::pair<const_iterator, const_iterator> equal_range(key_parameter_t key) const
|
||||
{
|
||||
const_iterator i_lower = std::lower_bound(cbegin(), cend(), key, compare());
|
||||
const_iterator i_lower = std::lower_bound(cbegin(), cend(), key, compare);
|
||||
|
||||
return std::make_pair(i_lower, std::upper_bound(i_lower, cend(), key, compare()));
|
||||
return std::make_pair(i_lower, std::upper_bound(i_lower, cend(), key, compare));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -768,6 +770,8 @@ namespace etl
|
||||
|
||||
lookup_t& lookup;
|
||||
|
||||
Compare compare;
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
//*************************************************************************
|
||||
|
||||
@ -460,9 +460,9 @@ namespace etl
|
||||
{
|
||||
std::pair<iterator, bool> result(end(), false);
|
||||
|
||||
ETL_ASSERT(!lookup.full(), ETL_ERROR(flat_multiset_full));
|
||||
ETL_ASSERT(!lookup.full(), ETL_ERROR(flat_multiset_full));
|
||||
|
||||
iterator i_element = std::lower_bound(begin(), end(), value, TKeyCompare());
|
||||
iterator i_element = std::lower_bound(begin(), end(), value, compare);
|
||||
|
||||
if (i_element == end())
|
||||
{
|
||||
@ -566,7 +566,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator find(parameter_t key)
|
||||
{
|
||||
iterator itr = std::lower_bound(begin(), end(), key, TKeyCompare());
|
||||
iterator itr = std::lower_bound(begin(), end(), key, compare);
|
||||
|
||||
if (itr != end())
|
||||
{
|
||||
@ -590,7 +590,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator find(parameter_t key) const
|
||||
{
|
||||
const_iterator itr = std::lower_bound(begin(), end(), key, TKeyCompare());
|
||||
const_iterator itr = std::lower_bound(begin(), end(), key, compare);
|
||||
|
||||
if (itr != end())
|
||||
{
|
||||
@ -626,7 +626,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator lower_bound(parameter_t key)
|
||||
{
|
||||
return std::lower_bound(begin(), end(), key, TKeyCompare());
|
||||
return std::lower_bound(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -636,7 +636,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator lower_bound(parameter_t key) const
|
||||
{
|
||||
return std::lower_bound(cbegin(), cend(), key, TKeyCompare());
|
||||
return std::lower_bound(cbegin(), cend(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -646,7 +646,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator upper_bound(parameter_t key)
|
||||
{
|
||||
return std::upper_bound(begin(), end(), key, TKeyCompare());
|
||||
return std::upper_bound(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -656,7 +656,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator upper_bound(parameter_t key) const
|
||||
{
|
||||
return std::upper_bound(cbegin(), cend(), key, TKeyCompare());
|
||||
return std::upper_bound(cbegin(), cend(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -666,7 +666,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
std::pair<iterator, iterator> equal_range(parameter_t key)
|
||||
{
|
||||
return std::equal_range(begin(), end(), key, TKeyCompare());
|
||||
return std::equal_range(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -676,7 +676,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
std::pair<const_iterator, const_iterator> equal_range(parameter_t key) const
|
||||
{
|
||||
return std::equal_range(begin(), end(), key, TKeyCompare());
|
||||
return std::equal_range(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -783,6 +783,8 @@ namespace etl
|
||||
|
||||
lookup_t& lookup;
|
||||
|
||||
TKeyCompare compare;
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
//*************************************************************************
|
||||
|
||||
@ -546,7 +546,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator find(parameter_t key)
|
||||
{
|
||||
iterator itr = std::lower_bound(begin(), end(), key, TKeyCompare());
|
||||
iterator itr = std::lower_bound(begin(), end(), key, compare);
|
||||
|
||||
if (itr != end())
|
||||
{
|
||||
@ -570,7 +570,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator find(parameter_t key) const
|
||||
{
|
||||
const_iterator itr = std::lower_bound(begin(), end(), key, TKeyCompare());
|
||||
const_iterator itr = std::lower_bound(begin(), end(), key, compare);
|
||||
|
||||
if (itr != end())
|
||||
{
|
||||
@ -604,7 +604,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator lower_bound(parameter_t key)
|
||||
{
|
||||
return std::lower_bound(begin(), end(), key, TKeyCompare());
|
||||
return std::lower_bound(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -614,7 +614,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator lower_bound(parameter_t key) const
|
||||
{
|
||||
return std::lower_bound(cbegin(), cend(), key, TKeyCompare());
|
||||
return std::lower_bound(cbegin(), cend(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -624,7 +624,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
iterator upper_bound(parameter_t key)
|
||||
{
|
||||
return std::upper_bound(begin(), end(), key, TKeyCompare());
|
||||
return std::upper_bound(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -634,7 +634,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
const_iterator upper_bound(parameter_t key) const
|
||||
{
|
||||
return std::upper_bound(cbegin(), cend(), key, TKeyCompare());
|
||||
return std::upper_bound(cbegin(), cend(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -644,7 +644,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
std::pair<iterator, iterator> equal_range(parameter_t key)
|
||||
{
|
||||
return std::equal_range(begin(), end(), key, TKeyCompare());
|
||||
return std::equal_range(begin(), end(), key, compare);
|
||||
}
|
||||
|
||||
//*********************************************************************
|
||||
@ -654,7 +654,7 @@ namespace etl
|
||||
//*********************************************************************
|
||||
std::pair<const_iterator, const_iterator> equal_range(parameter_t key) const
|
||||
{
|
||||
return std::upper_bound(cbegin(), cend(), key, TKeyCompare());
|
||||
return std::upper_bound(cbegin(), cend(), key, compare);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -745,7 +745,7 @@ namespace etl
|
||||
result.first = i_element;
|
||||
|
||||
// Existing element?
|
||||
if (TKeyCompare()(value, *i_element) || TKeyCompare()(*i_element, value))
|
||||
if (compare(value, *i_element) || compare(*i_element, value))
|
||||
{
|
||||
// A new one.
|
||||
ETL_ASSERT(!lookup.full(), ETL_ERROR(flat_set_full));
|
||||
@ -765,6 +765,8 @@ namespace etl
|
||||
|
||||
lookup_t& lookup;
|
||||
|
||||
TKeyCompare compare;
|
||||
|
||||
//*************************************************************************
|
||||
/// Destructor.
|
||||
//*************************************************************************
|
||||
|
||||
@ -474,7 +474,7 @@ namespace etl
|
||||
{
|
||||
bool operator ()(key_type& key1, key_type& key2) const
|
||||
{
|
||||
return key_compare()(key1, key2);
|
||||
return compare(key1, key2);
|
||||
}
|
||||
};
|
||||
|
||||
@ -485,7 +485,7 @@ namespace etl
|
||||
{
|
||||
bool operator ()(value_type& value1, value_type& value2) const
|
||||
{
|
||||
return value_compare()(value1, value2);
|
||||
return compare(value1, value2);
|
||||
}
|
||||
};
|
||||
|
||||
@ -512,17 +512,17 @@ namespace etl
|
||||
//*************************************************************************
|
||||
bool node_comp(const Data_Node& node1, const Data_Node& node2) const
|
||||
{
|
||||
return key_compare()(node1.value, node2.value);
|
||||
return compare(node1.value, node2.value);
|
||||
}
|
||||
|
||||
bool node_comp(const Data_Node& node, key_parameter_t key) const
|
||||
{
|
||||
return key_compare()(node.value, key);
|
||||
return compare(node.value, key);
|
||||
}
|
||||
bool node_comp(key_parameter_t key, const Data_Node& node) const
|
||||
|
||||
{
|
||||
return key_compare()(key, node.value);
|
||||
return compare(key, node.value);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -530,6 +530,8 @@ namespace etl
|
||||
/// The pool of data nodes used in the set.
|
||||
etl::ipool* p_node_pool;
|
||||
|
||||
key_compare compare;
|
||||
|
||||
//*************************************************************************
|
||||
/// Downcast a Node* to a Data_Node*
|
||||
//*************************************************************************
|
||||
|
||||
@ -874,18 +874,18 @@ namespace etl
|
||||
/// Calls the supplied reader instance.
|
||||
/// The 'read' function appropriate to the current type is called with the stored value.
|
||||
//***************************************************************************
|
||||
void call(reader& reader)
|
||||
void call(reader& r)
|
||||
{
|
||||
switch (type_id)
|
||||
{
|
||||
case 0: reader.read(static_cast<T1&>(data)); break;
|
||||
case 1: reader.read(static_cast<T2&>(data)); break;
|
||||
case 2: reader.read(static_cast<T3&>(data)); break;
|
||||
case 3: reader.read(static_cast<T4&>(data)); break;
|
||||
case 4: reader.read(static_cast<T5&>(data)); break;
|
||||
case 5: reader.read(static_cast<T6&>(data)); break;
|
||||
case 6: reader.read(static_cast<T7&>(data)); break;
|
||||
case 7: reader.read(static_cast<T8&>(data)); break;
|
||||
case 0: r.read(static_cast<T1&>(data)); break;
|
||||
case 1: r.read(static_cast<T2&>(data)); break;
|
||||
case 2: r.read(static_cast<T3&>(data)); break;
|
||||
case 3: r.read(static_cast<T4&>(data)); break;
|
||||
case 4: r.read(static_cast<T5&>(data)); break;
|
||||
case 5: r.read(static_cast<T6&>(data)); break;
|
||||
case 6: r.read(static_cast<T7&>(data)); break;
|
||||
case 7: r.read(static_cast<T8&>(data)); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user