Browse Source

include: vlc_list.hpp: add insertion/removal functions

Add some methods to replace their C counterpart when using a vlc_list,
so that elements can be added and removed. Those methods are only
supported on a vlc::list<T> wrapper, but they are not supported neither
on the vlc::const_list<T> wrapper (which is expected) nor on the
vlc::list::reverse_list wrapper from ::as_reverse() function, because it
would complexify the design.

The current workaround that was chosen is that vlc::list<T> is able to
use iterators from the reversed list, and can be swapped with the
reverse list object where needed.

The limitation will be lifted with C++20 and concepts.

Co-authored-by: Alexandre Janniaux <ajanni@videolabs.io>
pull/162/head
Pierre Lamot 2 years ago
committed by Steve Lhomme
parent
commit
dd459dba0b
  1. 23
      include/vlc_list.hpp

23
include/vlc_list.hpp

@ -339,6 +339,11 @@ public:
{
return a._list != b._list;
}
bool empty() const
{
return vlc_list_is_empty(_list);
}
};
/**
@ -396,6 +401,24 @@ public:
NodeType, vlc_list, iterator, const_iterator
>(l, node_ptr) {};
template <typename IteratorType>
IteratorType erase(IteratorType it)
{
vlc_list_remove(&((*it).*(this->_node_ptr)));
return it;
}
void push_front(NodeType &item)
{
struct vlc_list *node = &(item.*(this->_node_ptr));
vlc_list_prepend(node, &this->_list);
}
void push_back(NodeType &item)
{
struct vlc_list *node = &(item.*(this->_node_ptr));
vlc_list_append(node, &this->_list);
}
};
/**

Loading…
Cancel
Save