42 #include <visp3/core/vpConfig.h>
43 #include <visp3/core/vpDebug.h>
44 #include <visp3/core/vpException.h>
48 #ifndef DOXYGEN_SHOULD_SKIP_THIS
54 template <
class type>
class vpListElement
69 vpListElement() : prev(nullptr), next(nullptr), val() { };
70 vpListElement<type> *prev;
71 vpListElement<type> *next;
143 inline void next(
void);
145 inline void front(
void);
146 inline void end(
void);
147 inline bool outside(
void)
const;
149 bool empty(
void)
const;
151 inline type &
value(
void);
152 inline const type &
value(
void)
const;
160 inline void addRight(
const type &el);
161 inline void addLeft(
const type &el);
162 inline void modify(
const type &el);
191 vpListElement<type> *x =
new vpListElement<type>;
192 vpListElement<type> *y =
new vpListElement<type>;
336 template <
class type>
bool vpList<type>::empty(
void)
const {
return ((first->next == last) && (first == last->prev)); }
362 return ((cur->next == first) || (cur->next == last));
376 return ((cur->prev == first) || (cur->prev == last));
391 vpListElement<type> *x =
new vpListElement<type>;
399 std::cout <<
"vpList: outside with addRight " << std::endl;
421 vpListElement<type> *x =
new vpListElement<type>;
430 std::cout <<
"vpList: outside with addLeft " << std::endl;
452 vpListElement<type> *x =
new vpListElement<type>;
460 std::cout <<
"vpList: outside with addRight " << std::endl;
482 vpListElement<type> *x =
new vpListElement<type>;
491 std::cout <<
"vpList: outside with addLeft " << std::endl;
521 if (cur->prev != first) {
522 cur->prev->prev->next = cur;
523 cur->next->prev = cur->prev;
525 vpListElement<type> *nextTmp;
526 vpListElement<type> *prevTmp;
531 cur->next = cur->prev;
532 cur->prev = cur->prev->prev;
535 prevTmp->next = nextTmp;
538 std::cout <<
"vpList: previous element is outside (swapLeft) " << std::endl;
552 if (cur->next != last) {
553 cur->prev->next = cur->next;
554 cur->next->next->prev = cur;
556 vpListElement<type> *nextTmp;
557 vpListElement<type> *prevTmp;
562 cur->next = nextTmp->next;
565 nextTmp->prev = prevTmp;
569 std::cout <<
"vpList: next element is outside (swapRight) " << std::endl;
602 vpListElement<type> *x;
604 cur->prev->next = cur->next;
605 cur->next->prev = cur->prev;
625 vpListElement<type> *e;
630 while (e != l.
last) {
696 std::cout << k <<
" ---> " << value() << std::endl;
700 std::cout << std::endl << std::endl;
Provide simple list management.
void next(void)
position the current element on the next one
void addLeft(const type &el)
add a new element in the list, at the left of the current one
void addRight(const type &el)
add a new element in the list, at the right of the current one
void kill()
Destroy the list.
void swapRight()
Switch the current element with the element on the right.
bool empty(void) const
Test if the list is empty.
void modify(const type &el)
Modify the value of the current element.
vpList()
Basic constructor, initialization, Create an empty list.
void end(void)
Position the current element on the last element of the list.
void front(void)
Position the current element on the first element of the list.
void display()
Print (std::cout) all the element of the list.
bool previousOutside(void) const
Test if the previous element is outside the list (ie if the current element is the firts one)
type & previousValue(void)
return the value of the previous element
void operator+=(vpList< type > &l)
Append two lists.
unsigned int nbElements(void)
return the number of element in the list
vpListElement< type > * cur
the current item in the list
bool nextOutside(void) const
Test if the next element is outside the list (ie if the current element is the last one)
bool outside(void) const
Test if the current element is outside the list (on the virtual element)
void previous(void)
position the current element on the previous one
virtual ~vpList()
vpList destructor
type & value(void)
return the value of the current element
type & nextValue(void)
return the value of the next element
vpList< type > & operator=(const vpList< type > &l)
Copy constructor const.
type & lastValue(void)
return the last element of the list
void swapLeft()
Switch the current element with the element on the left.
void suppress(void)
suppress the current element
vpListElement< type > * first
! number of items in the List
vpListElement< type > * last
the last virtualitem in the list
unsigned int nbElement(void)
return the number of element in the list
type & firstValue(void)
return the first element of the list