 |
Visual Servoing Platform
version 3.3.0
|
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;
113 template <
class type>
class vpList
127 vpListElement<type> *
first;
135 vpListElement<type> *
last;
143 vpListElement<type> *
cur;
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>;
219 template <
class type>
vpList<type>::vpList() : nb(0), first(NULL), last(NULL), cur(NULL) { init(); }
343 template <
class type>
bool vpList<type>::empty(
void)
const {
return ((first->next == last) && (first == last->prev)); }
356 template <
class type>
bool vpList<type>::outside(
void)
const {
return ((cur == first) || (cur == last)); }
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;
void kill()
Destroy the list.
vpList()
Basic constructor, initialization, Create an empty list.
vpList< type > & operator=(const vpList< type > &l)
Copy constructor const.
type & previousValue(void)
return the value of the previous element
bool empty(void) const
Test if the list is empty.
virtual ~vpList()
vpList destructor
Provide simple list management.
void front(void)
Position the current element on the first element of the list.
void addRight(const type &el)
add a new element in the list, at the right of the current one
bool nextOutside(void) const
Test if the next element is outside the list (ie if the current element is the last one)
void swapLeft()
Switch the current element with the element on the left.
vpListElement< type > * cur
the current item in the list
bool previousOutside(void) const
Test if the previous element is outside the list (ie if the current element is the firts one)
void display()
Print (std::cout) all the element of the list.
type & lastValue(void)
return the last element of the list
void operator+=(vpList< type > &l)
Append two lists.
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 modify(const type &el)
Modify the value of the current element.
type & firstValue(void)
return the first element of the list
type & nextValue(void)
return the value of the next element
bool outside(void) const
Test if the current element is outside the list (on the virtual element)
type & value(void)
return the value of the current element
vpListElement< type > * first
! number of items in the List
void swapRight()
Switch the current element with the element on the right.
void previous(void)
position the current element on the previous one
vpListElement< type > * last
the last virtualitem in the list
void suppress(void)
suppress the current element
unsigned int nbElements(void)
return the number of element in the list
unsigned int nbElement(void)
return the number of element in the list
void end(void)
Position the current element on the last element of the list.