42 #include <visp3/core/vpConfig.h>
43 #include <visp3/core/vpDebug.h>
44 #include <visp3/core/vpException.h>
49 #ifndef DOXYGEN_SHOULD_SKIP_THIS
54 template <
class type>
class vpListElement
70 vpListElement() : prev(nullptr), next(nullptr), val() { };
71 vpListElement<type> *prev;
72 vpListElement<type> *next;
144 inline void next(
void);
146 inline void front(
void);
147 inline void end(
void);
148 inline bool outside(
void)
const;
150 bool empty(
void)
const;
152 inline type &
value(
void);
153 inline const type &
value(
void)
const;
161 inline void addRight(
const type &el);
162 inline void addLeft(
const type &el);
163 inline void modify(
const type &el);
192 vpListElement<type> *x =
new vpListElement<type>;
193 vpListElement<type> *y =
new vpListElement<type>;
337 template <
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>;
400 std::cout <<
"vpList: outside with addRight " << std::endl;
423 vpListElement<type> *x =
new vpListElement<type>;
432 std::cout <<
"vpList: outside with addLeft " << std::endl;
455 vpListElement<type> *x =
new vpListElement<type>;
463 std::cout <<
"vpList: outside with addRight " << std::endl;
486 vpListElement<type> *x =
new vpListElement<type>;
495 std::cout <<
"vpList: outside with addLeft " << std::endl;
526 if (cur->prev != first) {
527 cur->prev->prev->next = cur;
528 cur->next->prev = cur->prev;
530 vpListElement<type> *nextTmp;
531 vpListElement<type> *prevTmp;
536 cur->next = cur->prev;
537 cur->prev = cur->prev->prev;
540 prevTmp->next = nextTmp;
543 std::cout <<
"vpList: previous element is outside (swapLeft) " << std::endl;
557 if (cur->next != last) {
558 cur->prev->next = cur->next;
559 cur->next->next->prev = cur;
561 vpListElement<type> *nextTmp;
562 vpListElement<type> *prevTmp;
567 cur->next = nextTmp->next;
570 nextTmp->prev = prevTmp;
574 std::cout <<
"vpList: next element is outside (swapRight) " << std::endl;
607 vpListElement<type> *x;
609 cur->prev->next = cur->next;
610 cur->next->prev = cur->prev;
630 vpListElement<type> *e;
635 while (e != l.
last) {
701 std::cout << k <<
" ---> " << value() << std::endl;
705 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