48 #include <visp3/core/vpConfig.h>
49 #include <visp3/core/vpDebug.h>
50 #include <visp3/core/vpException.h>
54 #ifndef DOXYGEN_SHOULD_SKIP_THIS
60 template <
class type>
class vpListElement
75 vpListElement() : prev(NULL), next(NULL), val(){};
76 vpListElement<type> *prev;
77 vpListElement<type> *next;
149 inline void next(
void);
151 inline void front(
void);
152 inline void end(
void);
153 inline bool outside(
void)
const;
155 bool empty(
void)
const;
157 inline type &
value(
void);
158 inline const type &
value(
void)
const;
166 inline void addRight(
const type &el);
167 inline void addLeft(
const type &el);
168 inline void modify(
const type &el);
197 vpListElement<type> *x =
new vpListElement<type>;
198 vpListElement<type> *y =
new vpListElement<type>;
343 template <
class type>
bool vpList<type>::empty(
void)
const {
return ((first->next == last) && (first == last->prev)); }
369 return ((cur->next == first) || (cur->next == last));
383 return ((cur->prev == first) || (cur->prev == last));
398 vpListElement<type> *x =
new vpListElement<type>;
405 std::cout <<
"vpList: outside with addRight " << std::endl;
427 vpListElement<type> *x =
new vpListElement<type>;
435 std::cout <<
"vpList: outside with addLeft " << std::endl;
457 vpListElement<type> *x =
new vpListElement<type>;
464 std::cout <<
"vpList: outside with addRight " << std::endl;
486 vpListElement<type> *x =
new vpListElement<type>;
494 std::cout <<
"vpList: outside with addLeft " << std::endl;
524 if (cur->prev != first) {
525 cur->prev->prev->next = cur;
526 cur->next->prev = cur->prev;
528 vpListElement<type> *nextTmp;
529 vpListElement<type> *prevTmp;
534 cur->next = cur->prev;
535 cur->prev = cur->prev->prev;
538 prevTmp->next = nextTmp;
540 std::cout <<
"vpList: previous element is outside (swapLeft) " << std::endl;
554 if (cur->next != last) {
555 cur->prev->next = cur->next;
556 cur->next->next->prev = cur;
558 vpListElement<type> *nextTmp;
559 vpListElement<type> *prevTmp;
564 cur->next = nextTmp->next;
567 nextTmp->prev = prevTmp;
570 std::cout <<
"vpList: next element is outside (swapRight) " << std::endl;
603 vpListElement<type> *x;
605 cur->prev->next = cur->next;
606 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