Integration of contains and contains_node

This commit is contained in:
John Wellbelove 2025-03-02 12:51:17 +00:00
parent 12743be9e2
commit 6124367f28
2 changed files with 22 additions and 28 deletions

View File

@ -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)
{

View File

@ -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;