42#include <visp3/core/vpConfig.h>
43#include <visp3/core/vpDebug.h>
44#include <visp3/core/vpException.h>
48#ifndef DOXYGEN_SHOULD_SKIP_THIS
54template <
class type>
class vpListElement
69 vpListElement() : prev(NULL), next(NULL), 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>;
337template <
class type>
bool vpList<type>::empty(
void)
const {
return ((first->next == last) && (first == last->prev)); }
363 return ((cur->next == first) || (cur->next == last));
377 return ((cur->prev == first) || (cur->prev == last));
392 vpListElement<type> *x =
new vpListElement<type>;
399 std::cout <<
"vpList: outside with addRight " << std::endl;
421 vpListElement<type> *x =
new vpListElement<type>;
429 std::cout <<
"vpList: outside with addLeft " << std::endl;
451 vpListElement<type> *x =
new vpListElement<type>;
458 std::cout <<
"vpList: outside with addRight " << std::endl;
480 vpListElement<type> *x =
new vpListElement<type>;
488 std::cout <<
"vpList: outside with addLeft " << std::endl;
518 if (cur->prev != first) {
519 cur->prev->prev->next = cur;
520 cur->next->prev = cur->prev;
522 vpListElement<type> *nextTmp;
523 vpListElement<type> *prevTmp;
528 cur->next = cur->prev;
529 cur->prev = cur->prev->prev;
532 prevTmp->next = nextTmp;
534 std::cout <<
"vpList: previous element is outside (swapLeft) " << std::endl;
548 if (cur->next != last) {
549 cur->prev->next = cur->next;
550 cur->next->next->prev = cur;
552 vpListElement<type> *nextTmp;
553 vpListElement<type> *prevTmp;
558 cur->next = nextTmp->next;
561 nextTmp->prev = prevTmp;
564 std::cout <<
"vpList: next element is outside (swapRight) " << std::endl;
597 vpListElement<type> *x;
599 cur->prev->next = cur->next;
600 cur->next->prev = cur->prev;
619 vpListElement<type> *e;
624 while (e != l.
last) {
690 std::cout << k <<
" ---> " << value() << std::endl;
694 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