42 #include <visp3/core/vpConfig.h>
43 #include <visp3/core/vpDebug.h>
44 #include <visp3/core/vpException.h>
48 #ifndef DOXYGEN_SHOULD_SKIP_THIS
55 template <
class type>
class vpListElement
71 vpListElement() : prev(nullptr), next(nullptr), val() { };
72 vpListElement<type> *prev;
73 vpListElement<type> *next;
145 inline void next(
void);
147 inline void front(
void);
148 inline void end(
void);
149 inline bool outside(
void)
const;
151 bool empty(
void)
const;
153 inline type &
value(
void);
154 inline const type &
value(
void)
const;
162 inline void addRight(
const type &el);
163 inline void addLeft(
const type &el);
164 inline void modify(
const type &el);
193 vpListElement<type> *x =
new vpListElement<type>;
194 vpListElement<type> *y =
new vpListElement<type>;
338 template <
class type>
bool vpList<type>::empty(
void)
const {
return ((first->next == last) && (first == last->prev)); }
364 return ((cur->next == first) || (cur->next == last));
378 return ((cur->prev == first) || (cur->prev == last));
393 vpListElement<type> *x =
new vpListElement<type>;
401 std::cout <<
"vpList: outside with addRight " << std::endl;
424 vpListElement<type> *x =
new vpListElement<type>;
433 std::cout <<
"vpList: outside with addLeft " << std::endl;
456 vpListElement<type> *x =
new vpListElement<type>;
464 std::cout <<
"vpList: outside with addRight " << std::endl;
487 vpListElement<type> *x =
new vpListElement<type>;
496 std::cout <<
"vpList: outside with addLeft " << std::endl;
527 if (cur->prev != first) {
528 cur->prev->prev->next = cur;
529 cur->next->prev = cur->prev;
531 vpListElement<type> *nextTmp;
532 vpListElement<type> *prevTmp;
537 cur->next = cur->prev;
538 cur->prev = cur->prev->prev;
541 prevTmp->next = nextTmp;
544 std::cout <<
"vpList: previous element is outside (swapLeft) " << std::endl;
558 if (cur->next != last) {
559 cur->prev->next = cur->next;
560 cur->next->next->prev = cur;
562 vpListElement<type> *nextTmp;
563 vpListElement<type> *prevTmp;
568 cur->next = nextTmp->next;
571 nextTmp->prev = prevTmp;
575 std::cout <<
"vpList: next element is outside (swapRight) " << std::endl;
608 vpListElement<type> *x;
610 cur->prev->next = cur->next;
611 cur->next->prev = cur->prev;
631 vpListElement<type> *e;
636 while (e != l.
last) {
702 std::cout << k <<
" ---> " << value() << std::endl;
706 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