/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see .
*/
#ifndef TRINITYCORE_LIST_UTILS_H
#define TRINITYCORE_LIST_UTILS_H
#include
#include
namespace Trinity::Containers::Lists
{
template>
inline typename std::list::iterator RemoveUnique(std::list& list, std::type_identity_t const& value)
{
auto itr = std::find(list.begin(), list.end(), value);
if (itr != list.end())
return list.erase(itr);
return list.end();
}
template>
inline typename std::forward_list::iterator RemoveUnique(std::forward_list& list, std::type_identity_t const& value)
{
auto itr = list.before_begin();
auto toErase = std::next(itr);
while (toErase != list.end())
{
if (*toErase == value)
return list.erase_after(itr);
itr = toErase++;
}
return list.end();
}
}
#endif // TRINITYCORE_LIST_UTILS_H