I just don't get it. I am trying to find a list node by its value, but there's no function. Further more, I am not even able to delete last inserted nodes, the equivalent to std::list<typename T>::pop (_back and _front). But even those functions don't return the values of the nodes if I wanna 'pop' them.
So I wonder what I should do?
EDIT: Stupid question, program it myself, the source code is available after all ...
irr::core::list<typename T> - who the f*** did program
And since you don't understand it, it must be wrong...TomTim wrote:I just don't get it.
So write one? Or use an existing algorithm from the C++ Standard Library.TomTim wrote:I am trying to find a list node by its value, but there's no function.
Code: Select all
template<class Iterator, class Predicate>
Iterator my_find_if(Iterator beg, Iterator end, Predicate pred)
{
for (/**/; beg != end; ++beg) {
if (pred(*beg))
break;
}
return beg;
}
template <class Iterator, class T>
Iterator my_find(Iterator beg, Iterator end, const T& val)
{
for (/**/; beg != end; ++beg) {
if (*beg == val)
break;
}
return beg;
}
This sounds like a personal problem. The functionality is there, you just have to use it...TomTim wrote:Further more, I am not even able to delete last inserted nodes, the equivalent to std::list<typename T>::pop (_back and _front).
Code: Select all
// assuming my_list is not empty (same as the requirement for std::list<T>::pop_back() and std::list<T>::pop_front())
// same as pop_back()
my_list.erase(my_list.getLast());
// same as pop_front()
my_list.erase(my_list.begin());
The equivalent functions in the C++ Standard Library don't remove and return the element either. They both return void to avoid exception safety problems.TomTim wrote:But even those functions don't return the values of the nodes if I wanna 'pop' them.
Travis