mirror of
https://github.com/ETLCPP/etl.git
synced 2026-07-01 06:48:44 +08:00
Merge remote-tracking branch 'origin/development'
This commit is contained in:
parent
7b8f8b08f7
commit
9302a2a2b7
@ -474,26 +474,18 @@ namespace etl
|
||||
typedef const value_type* const_pointer;
|
||||
typedef size_t size_type;
|
||||
|
||||
//*************************************************************************
|
||||
/// How to compare two key elements.
|
||||
//*************************************************************************
|
||||
struct key_comp
|
||||
class value_compare
|
||||
{
|
||||
bool operator ()(const key_type& key1, const key_type& key2) const
|
||||
{
|
||||
return compare(key1, key2);
|
||||
}
|
||||
};
|
||||
public:
|
||||
|
||||
//*************************************************************************
|
||||
/// How to compare two value elements.
|
||||
//*************************************************************************
|
||||
struct value_comp
|
||||
{
|
||||
bool operator ()(const value_type& value1, const value_type& value2) const
|
||||
bool operator()(const value_type& lhs, const value_type& rhs) const
|
||||
{
|
||||
return compare(value1.first, value2.first);
|
||||
return (kcompare(lhs.first, rhs.first));
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
key_compare kcompare;
|
||||
};
|
||||
|
||||
protected:
|
||||
@ -524,15 +516,15 @@ namespace etl
|
||||
//*************************************************************************
|
||||
bool node_comp(const Data_Node& node1, const Data_Node& node2) const
|
||||
{
|
||||
return compare(node1.value.first, node2.value.first);
|
||||
return kcompare(node1.value.first, node2.value.first);
|
||||
}
|
||||
bool node_comp(const Data_Node& node, key_parameter_t key) const
|
||||
{
|
||||
return compare(node.value.first, key);
|
||||
return kcompare(node.value.first, key);
|
||||
}
|
||||
bool node_comp(key_parameter_t key, const Data_Node& node) const
|
||||
{
|
||||
return compare(key, node.value.first);
|
||||
return kcompare(key, node.value.first);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -540,7 +532,8 @@ namespace etl
|
||||
/// The pool of data nodes used in the map.
|
||||
ipool* p_node_pool;
|
||||
|
||||
key_compare compare;
|
||||
key_compare kcompare;
|
||||
value_compare vcompare;
|
||||
|
||||
//*************************************************************************
|
||||
/// Downcast a Node* to a Data_Node*
|
||||
@ -1236,6 +1229,22 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// How to compare two key elements.
|
||||
//*************************************************************************
|
||||
key_compare key_comp() const
|
||||
{
|
||||
return kcompare;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// How to compare two value elements.
|
||||
//*************************************************************************
|
||||
value_compare value_comp() const
|
||||
{
|
||||
return vcompare;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -631,26 +631,18 @@ namespace etl
|
||||
typedef const value_type* const_pointer;
|
||||
typedef size_t size_type;
|
||||
|
||||
//*************************************************************************
|
||||
/// How to compare two key elements.
|
||||
//*************************************************************************
|
||||
struct key_comp
|
||||
class value_compare
|
||||
{
|
||||
bool operator ()(const key_type& key1, const key_type& key2) const
|
||||
{
|
||||
return compare(key1, key2);
|
||||
}
|
||||
};
|
||||
public:
|
||||
|
||||
//*************************************************************************
|
||||
/// How to compare two value elements.
|
||||
//*************************************************************************
|
||||
struct value_comp
|
||||
{
|
||||
bool operator ()(const value_type& value1, const value_type& value2) const
|
||||
bool operator()(const value_type& lhs, const value_type& rhs) const
|
||||
{
|
||||
return compare(value1.first, value2.first);
|
||||
return (kcompare(lhs.first, rhs.first));
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
key_compare kcompare;
|
||||
};
|
||||
|
||||
protected:
|
||||
@ -676,17 +668,17 @@ namespace etl
|
||||
//*************************************************************************
|
||||
bool node_comp(const Data_Node& node1, const Data_Node& node2) const
|
||||
{
|
||||
return compare(node1.value.first, node2.value.first);
|
||||
return kcompare(node1.value.first, node2.value.first);
|
||||
}
|
||||
|
||||
bool node_comp(const Data_Node& node, key_parameter_t key) const
|
||||
{
|
||||
return compare(node.value.first, key);
|
||||
return kcompare(node.value.first, key);
|
||||
}
|
||||
|
||||
bool node_comp(key_parameter_t key, const Data_Node& node) const
|
||||
{
|
||||
return compare(key, node.value.first);
|
||||
return kcompare(key, node.value.first);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -694,7 +686,8 @@ namespace etl
|
||||
/// The pool of data nodes used in the multimap.
|
||||
ipool* p_node_pool;
|
||||
|
||||
key_compare compare;
|
||||
key_compare kcompare;
|
||||
value_compare vcompare;
|
||||
|
||||
//*************************************************************************
|
||||
/// Downcast a Node* to a Data_Node*
|
||||
@ -1330,6 +1323,22 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// How to compare two key elements.
|
||||
//*************************************************************************
|
||||
key_compare key_comp() const
|
||||
{
|
||||
return kcompare;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// How to compare two value elements.
|
||||
//*************************************************************************
|
||||
value_compare value_comp() const
|
||||
{
|
||||
return vcompare;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -629,28 +629,6 @@ namespace etl
|
||||
typedef value_type* const_pointer;
|
||||
typedef size_t size_type;
|
||||
|
||||
//*************************************************************************
|
||||
/// How to compare two key elements.
|
||||
//*************************************************************************
|
||||
struct key_comp
|
||||
{
|
||||
bool operator ()(key_type& key1, key_type& key2) const
|
||||
{
|
||||
return compare(key1, key2);
|
||||
}
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// How to compare two value elements.
|
||||
//*************************************************************************
|
||||
struct value_comp
|
||||
{
|
||||
bool operator ()(value_type& value1, value_type& value2) const
|
||||
{
|
||||
return compare(value1, value2);
|
||||
}
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
//*************************************************************************
|
||||
@ -1311,6 +1289,22 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// How to compare two key elements.
|
||||
//*************************************************************************
|
||||
key_compare key_comp() const
|
||||
{
|
||||
return compare;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// How to compare two value elements.
|
||||
//*************************************************************************
|
||||
value_compare value_comp() const
|
||||
{
|
||||
return compare;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -467,28 +467,6 @@ namespace etl
|
||||
typedef value_type* const_pointer;
|
||||
typedef size_t size_type;
|
||||
|
||||
//*************************************************************************
|
||||
/// How to compare two key elements.
|
||||
//*************************************************************************
|
||||
struct key_comp
|
||||
{
|
||||
bool operator ()(key_type& key1, key_type& key2) const
|
||||
{
|
||||
return compare(key1, key2);
|
||||
}
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// How to compare two value elements.
|
||||
//*************************************************************************
|
||||
struct value_comp
|
||||
{
|
||||
bool operator ()(value_type& value1, value_type& value2) const
|
||||
{
|
||||
return compare(value1, value2);
|
||||
}
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
//*************************************************************************
|
||||
@ -1159,6 +1137,22 @@ namespace etl
|
||||
return const_iterator(*this, find_upper_node(root_node, key));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// How to compare two key elements.
|
||||
//*************************************************************************
|
||||
key_compare key_comp() const
|
||||
{
|
||||
return compare;
|
||||
};
|
||||
|
||||
//*************************************************************************
|
||||
/// How to compare two value elements.
|
||||
//*************************************************************************
|
||||
value_compare value_comp() const
|
||||
{
|
||||
return compare;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -1055,5 +1055,42 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_key_compare)
|
||||
{
|
||||
const Data data(initial_data.begin(), initial_data.end());
|
||||
|
||||
Data::key_compare compare = data.key_comp();
|
||||
|
||||
Data::key_type a("A");
|
||||
Data::key_type b("B");
|
||||
|
||||
#ifdef TEST_GREATER_THAN
|
||||
CHECK(!compare(a, b));
|
||||
CHECK(compare(b, a));
|
||||
#else
|
||||
CHECK(compare(a, b));
|
||||
CHECK(!compare(b, a));
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_value_compare)
|
||||
{
|
||||
const Data data(initial_data.begin(), initial_data.end());
|
||||
|
||||
Data::value_compare compare = data.value_comp();
|
||||
|
||||
Data::value_type a(std::string("A"), 0);
|
||||
Data::value_type b(std::string("B"), 1);
|
||||
|
||||
#ifdef TEST_GREATER_THAN
|
||||
CHECK(!compare(a, b));
|
||||
CHECK(compare(b, a));
|
||||
#else
|
||||
CHECK(compare(a, b));
|
||||
CHECK(!compare(b, a));
|
||||
#endif
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1010,5 +1010,42 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_key_compare)
|
||||
{
|
||||
const Data data(initial_data.begin(), initial_data.end());
|
||||
|
||||
Data::key_compare compare = data.key_comp();
|
||||
|
||||
Data::key_type a("A");
|
||||
Data::key_type b("B");
|
||||
|
||||
#ifdef TEST_GREATER_THAN
|
||||
CHECK(!compare(a, b));
|
||||
CHECK(compare(b, a));
|
||||
#else
|
||||
CHECK(compare(a, b));
|
||||
CHECK(!compare(b, a));
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_value_compare)
|
||||
{
|
||||
const Data data(initial_data.begin(), initial_data.end());
|
||||
|
||||
Data::value_compare compare = data.value_comp();
|
||||
|
||||
Data::value_type a(std::string("A"), 0);
|
||||
Data::value_type b(std::string("B"), 1);
|
||||
|
||||
#ifdef TEST_GREATER_THAN
|
||||
CHECK(!compare(a, b));
|
||||
CHECK(compare(b, a));
|
||||
#else
|
||||
CHECK(compare(a, b));
|
||||
CHECK(!compare(b, a));
|
||||
#endif
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -968,5 +968,42 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_key_compare)
|
||||
{
|
||||
const Data data(initial_data.begin(), initial_data.end());
|
||||
|
||||
Data::key_compare compare = data.key_comp();
|
||||
|
||||
Data::key_type a(1);
|
||||
Data::key_type b(2);
|
||||
|
||||
#ifdef TEST_GREATER_THAN
|
||||
CHECK(!compare(a, b));
|
||||
CHECK(compare(b, a));
|
||||
#else
|
||||
CHECK(compare(a, b));
|
||||
CHECK(!compare(b, a));
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_value_compare)
|
||||
{
|
||||
const Data data(initial_data.begin(), initial_data.end());
|
||||
|
||||
Data::value_compare compare = data.value_comp();
|
||||
|
||||
Data::value_type a(1);
|
||||
Data::value_type b(2);
|
||||
|
||||
#ifdef TEST_GREATER_THAN
|
||||
CHECK(!compare(a, b));
|
||||
CHECK(compare(b, a));
|
||||
#else
|
||||
CHECK(compare(a, b));
|
||||
CHECK(!compare(b, a));
|
||||
#endif
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -945,5 +945,42 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_key_compare)
|
||||
{
|
||||
const Data data(initial_data.begin(), initial_data.end());
|
||||
|
||||
Data::key_compare compare = data.key_comp();
|
||||
|
||||
Data::key_type a(1);
|
||||
Data::key_type b(2);
|
||||
|
||||
#ifdef TEST_GREATER_THAN
|
||||
CHECK(!compare(a, b));
|
||||
CHECK(compare(b, a));
|
||||
#else
|
||||
CHECK(compare(a, b));
|
||||
CHECK(!compare(b, a));
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_value_compare)
|
||||
{
|
||||
const Data data(initial_data.begin(), initial_data.end());
|
||||
|
||||
Data::value_compare compare = data.value_comp();
|
||||
|
||||
Data::value_type a(1);
|
||||
Data::value_type b(2);
|
||||
|
||||
#ifdef TEST_GREATER_THAN
|
||||
CHECK(!compare(a, b));
|
||||
CHECK(compare(b, a));
|
||||
#else
|
||||
CHECK(compare(a, b));
|
||||
CHECK(!compare(b, a));
|
||||
#endif
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user