mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-26 20:38:45 +08:00
Integration of contains and contains_node
This commit is contained in:
parent
12743be9e2
commit
6124367f28
@ -259,19 +259,16 @@ namespace etl
|
||||
//*************************************************************************
|
||||
bool contains_node(const link_type& search_link) const
|
||||
{
|
||||
const link_type* p_link = start.etl_next;
|
||||
return is_link_in_list(&search_link);
|
||||
}
|
||||
|
||||
while (p_link != ETL_NULLPTR)
|
||||
{
|
||||
if (&search_link == p_link)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
p_link = p_link->link_type::etl_next;
|
||||
}
|
||||
|
||||
return false;
|
||||
//*************************************************************************
|
||||
/// Detects existence of specified node in list.
|
||||
///\param search_link The node to find in list
|
||||
//*************************************************************************
|
||||
bool contains_node(const link_type* search_link) const
|
||||
{
|
||||
return is_link_in_list(search_link);
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -359,10 +356,10 @@ namespace etl
|
||||
/// Tests if the link is in this list.
|
||||
/// Returns the previous link to it, if found, otherwise ETL_NULLPTR.
|
||||
//*************************************************************************
|
||||
link_type* is_link_in_list(const link_type* search_link)
|
||||
link_type* is_link_in_list(const link_type* search_link) const
|
||||
{
|
||||
link_type* p_link = start.etl_next;
|
||||
link_type* p_previous = &start;
|
||||
link_type* p_previous = const_cast<link_type*>(&start);
|
||||
|
||||
while (p_link != ETL_NULLPTR)
|
||||
{
|
||||
|
||||
@ -259,21 +259,18 @@ namespace etl
|
||||
/// Detects existence of specified node in list.
|
||||
///\param search_link The node to find in list
|
||||
//*************************************************************************
|
||||
bool contains_node(link_type& search_link) const
|
||||
bool contains_node(const link_type& search_link) const
|
||||
{
|
||||
link_type* p_link = terminal_link.link_type::etl_next;
|
||||
return is_link_in_list(&search_link);;
|
||||
}
|
||||
|
||||
while (p_link != &terminal_link)
|
||||
{
|
||||
if (&search_link == p_link)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
p_link = p_link->link_type::etl_next;
|
||||
}
|
||||
|
||||
return false;
|
||||
//*************************************************************************
|
||||
/// Detects existence of specified node in list.
|
||||
///\param search_link The node to find in list
|
||||
//*************************************************************************
|
||||
bool contains_node(const link_type* search_link) const
|
||||
{
|
||||
return is_link_in_list(search_link);;
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -425,7 +422,7 @@ namespace etl
|
||||
{
|
||||
link_type* result = ETL_NULLPTR;
|
||||
|
||||
if (contains_node(link))
|
||||
if (is_link_in_list(link))
|
||||
{
|
||||
link_type* p_next = link->etl_next;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user