20 #define AGX_USE_AGX_LIST_IMPL 1
22 #if AGX_USE_AGX_LIST_IMPL
33 #define AGX_LIST_ITERATOR_TYPEDEFS \
34 typedef std::bidirectional_iterator_tag iterator_category; \
35 typedef T& reference; \
36 typedef const T& const_reference; \
38 typedef const T* const_pointer; \
39 typedef T value_type; \
40 typedef ptrdiff_t difference_type
42 template <
typename T >
61 template<
typename T >
70 template<
typename T >
81 template<
typename ItT,
typename Op >
94 template<
typename ItT >
100 template<
typename ItT >
106 template <
typename T >
181 return m_ptr == i.m_ptr;
185 return m_ptr != i.m_ptr;
250 return m_ptr == i.m_ptr;
254 return m_ptr == i.m_ptr;
258 return m_ptr != i.m_ptr;
262 return m_ptr != i.m_ptr;
349 return m_ptr == i.m_ptr;
353 return m_ptr != i.m_ptr;
425 return m_ptr == i.m_ptr;
429 return m_ptr != i.m_ptr;
480 : m_size( 0 ), m_end( allocate() ), m_front( m_end )
488 : m_size( 0 ), m_end( allocate() ), m_front( m_end )
499 if ( m_front == m_end && m_front !=
nullptr )
500 deallocate( m_front );
511 if (
this == &other )
530 if ( *myIt != *otherIt )
545 for ( ; i != iend; ++i ) {
546 if ( *i == _val )
return i;
560 for ( ; i != iend; ++i ) {
561 if ( *i == _val )
return i;
624 inline bool empty()
const {
return m_size == 0; }
661 node->
m_next = _where.m_ptr;
662 _where.m_ptr->
m_prev = node;
664 if ( node->
m_prev ==
nullptr ) {
679 template<
typename InputIterator >
682 for ( ; _first != _last; ++_first ) {
683 insert( _where, *_first );
742 if ( _where.m_ptr == m_front ) {
743 m_front = m_front->
m_next;
744 m_front->
m_prev =
nullptr;
746 deallocate( _where.m_ptr );
750 agxAssert( m_size > 0 || (m_size == 0 && m_front == m_end) );
760 deallocate( _where.m_ptr );
773 template<
typename Pred >
778 while ( node != m_end ) {
801 template<
typename Pred >
804 if (
this != &other ) {
811 while ( myIt != myEnd && otherIt != otherEnd ) {
812 if ( pred( *otherIt, *myIt ) ) {
814 splice( myIt, other, otherIt, ++otherNext, 1 );
820 if ( otherIt != otherEnd )
821 splice( myEnd, other, otherIt, otherEnd, other.m_size );
841 template<
typename Pred >
850 while ( curr != endIt ) {
853 if ( pred( *prev, *curr ) )
854 curr = ++
erase( curr );
882 if ( node == m_end ) {
885 m_front->
m_prev =
nullptr;
899 std::swap( m_front, other.m_front );
900 std::swap( m_end, other.m_end );
901 std::swap( m_size, other.m_size );
907 template<
typename Pred >
915 my_type binList[ MAXBINS + 1 ];
922 for ( ; bin < maxBin && !binList[ bin ].
empty(); ++bin ) {
923 binList[ bin ].
merge( tmpList, pred );
924 binList[ bin ].
swap( tmpList );
927 if ( bin == MAXBINS )
928 binList[ bin - 1 ].
merge( tmpList, pred );
930 binList[ bin ].
swap( tmpList );
935 for (
size_type bin = 1; bin < maxBin; ++bin )
936 binList[ bin ].
merge( binList[ bin - 1 ], pred );
938 splice(
end(), binList[ maxBin - 1 ], binList[ maxBin - 1 ].
begin(), binList[ maxBin - 1 ].
end(), binList[ maxBin - 1 ].
size() );
954 if (
this != &other ) {
956 other.m_size -= count;
960 if ( first.m_ptr->
m_prev ==
nullptr )
961 other.m_front = last.m_ptr;
967 if ( _where.m_ptr->
m_prev ==
nullptr )
968 m_front = first.m_ptr;
975 first.m_ptr->
m_prev = node;
999 if ( first == other.
begin() && last == other.
end() )
1000 count = other.
size();
1003 splice( _where, other, first, last, count );
1039 template<
typename T >
1040 class List :
public std::list< T > {};
ItT operator()(const ItT &org, Op op) const
bool operator()(const_reference obj) const
EqualPred1(const_reference obj)
bool operator()(const_reference left, const_reference right) const
LessPred1(const_reference obj)
bool operator()(const_reference obj) const
bool operator()(const_reference left, const_reference right) const
bool operator==(const const_iterator &i) const
const_iterator & operator=(const const_iterator &rhs)
const_iterator operator--(int)
const_iterator(node_ptr_type ptr)
AGX_LIST_ITERATOR_TYPEDEFS
const_iterator operator+(const agx::ItOp &inc) const
const_iterator operator-(const agx::ItOp &inc) const
const_pointer operator->() const
const_iterator & operator--()
const_iterator(const const_iterator &rhs)
const_iterator operator++(int)
bool operator!=(const const_iterator &i) const
const_reference operator*() const
const_iterator & operator++()
const_reverse_iterator operator+(const agx::ItOp &inc) const
const_reverse_iterator(const iterator &rhs)
const_reference operator*() const
const_reverse_iterator(node_ptr_type ptr)
bool operator!=(const const_reverse_iterator &i) const
const_reverse_iterator operator++(int)
AGX_LIST_ITERATOR_TYPEDEFS
bool operator==(const const_reverse_iterator &i) const
const_reverse_iterator(const const_reverse_iterator &rhs)
const_reverse_iterator operator--(int)
const_reverse_iterator & operator=(const iterator &rhs)
const_reverse_iterator & operator=(const const_iterator &rhs)
const_pointer operator->() const
const_reverse_iterator operator-(const agx::ItOp &inc) const
const_reverse_iterator & operator=(const const_reverse_iterator &rhs)
const_reverse_iterator & operator++()
const_reverse_iterator(const const_iterator &rhs)
const_reverse_iterator & operator--()
AGX_LIST_ITERATOR_TYPEDEFS
bool operator==(const iterator &i) const
iterator operator+(const agx::ItOp &inc) const
iterator(node_ptr_type ptr)
bool operator==(const const_iterator &i) const
bool operator!=(const const_iterator &i) const
iterator operator-(const agx::ItOp &inc) const
iterator(const iterator &rhs)
pointer operator->() const
reference operator*() const
bool operator!=(const iterator &i) const
iterator & operator=(const iterator &rhs)
reverse_iterator operator++(int)
reference operator*() const
reverse_iterator operator--(int)
pointer operator->() const
AGX_LIST_ITERATOR_TYPEDEFS
reverse_iterator(const iterator &rhs)
bool operator!=(const reverse_iterator &i) const
reverse_iterator & operator++()
reverse_iterator operator+(const agx::ItOp &inc) const
reverse_iterator & operator=(const iterator &rhs)
reverse_iterator(node_ptr_type ptr)
reverse_iterator & operator=(const const_reverse_iterator &rhs)
reverse_iterator operator-(const agx::ItOp &inc) const
reverse_iterator & operator--()
bool operator==(const reverse_iterator &i) const
reverse_iterator(const reverse_iterator &rhs)
const_reference back() const
List & operator=(const my_type &other)
Assignment operator.
const_iterator end() const
void remove(const_reference valArg)
Erase (all) elements matching valArg.
LNode< T > & node_ref_type
iterator erase(const_iterator _where)
Erase element at _where.
void unique()
Erases each element satisfying operator== with previous.
void clear()
Clear this list of all elements.
const_reverse_iterator rbegin() const
iterator insert(const_iterator _where, const_reference c_ref)
Insert an element c_ref before _where.
void reverse()
Reverse sequence.
const_reverse_iterator rend() const
bool operator==(const my_type &other) const
Comparison of lists of same size.
void splice(const_iterator _where, my_type &other)
Splice other [other.begin(), other.end()) at _where.
void merge(my_type &other, Pred pred)
Merge in elements from other, both this and other are ordered by pred.
void insert(const_iterator _where, InputIterator _first, InputIterator _last)
Insert N elements before _where.
reverse_iterator rbegin()
List(const List &other)
Copy constructor.
void push_front(const_reference c_ref)
Add element to the front of this list.
void remove_if(Pred pred)
Erase (all) elements matching pred.
void pop_back()
Remove last element in this list.
List()
Default constructor, size zero and begin() == end().
void sort()
Sorts the content in this list given operator<.
const T & const_reference
void pop_front()
Remove first element in this list.
void splice(const_iterator _where, my_type &other, const_iterator first, const_iterator last)
Splice other [first, last) at _where.
LNode< T > * node_ptr_type
void unique(Pred pred)
Erases each element satisfying pred with previous.
void sort(Pred pred)
Sorts the content in this list given pred.
void splice(const_iterator _where, my_type &other, const_iterator first, const_iterator last, size_type count)
Splice other [first, last) at _where.
void swap(my_type &other)
Swap this with other.
void merge(my_type &other)
Merge in elements from other, both this and other are ordered by operator<.
const_iterator begin() const
const_reference front() const
iterator find(const_reference _val)
Find iterator to FIRST element with value _val.
bool contains(const_reference _val)
Check if a value _val is part of this list (at least one time).
void push_back(const_reference c_ref)
Add element to the back of this list.
const_iterator find(const_reference _val) const
Find iterator to FIRST element with value _val.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
ItT operator-(const ItT &it, const agx::ItOp &inc)
AgXString< T > operator+(const Indentation &indentation, const AgXString< T > &str)
T & operator()(T &val) const
T & operator()(T &val) const