48 #include "dcmtk/config/osconfig.h" 49 #include "dcmtk/ofstd/oftypes.h" 50 #include "dcmtk/ofstd/ofcast.h" 52 #ifndef HAVE_CLASS_TEMPLATE 53 #error Your C++ compiler cannot handle class templates: 56 #if defined(HAVE_STL) || defined(HAVE_STL_LIST) 64 #ifdef HAVE_STD_NAMESPACE 65 #define OFList std::list 66 #define OFListIterator(x) std::list< x >::iterator 67 #define OFListConstIterator(x) std::list< x >::const_iterator 70 #define OFListIterator(x) list< x >::iterator 71 #define OFListConstIterator(x) list< x >::const_iterator 74 #define OFListInsert(InputIterator, T, c, pos, first, last) (c).insert((pos), (first), (last)) 75 #define OFListRemoveIf(Predicate, T, c, pred) (c).remove_if((pred)) 78 #define OFLIST_TYPENAME OFTypename 82 #define INCLUDE_CASSERT 83 #define INCLUDE_CSTDDEF 84 #include "dcmtk/ofstd/ofstdinc.h" 86 #define OFLIST_TYPENAME 89 #ifdef HAVE_SYS_TYPES_H 91 #include <sys/types.h> 123 void base_recalcListSize();
129 OFBool base_empty()
const {
return afterLast == afterLast->next; }
130 size_t base_size()
const {
return listSize; }
223 assert(!node->dummy);
313 while (vfirst != vend)
315 insert(vpos, *vfirst);
353 OFBool
empty()
const {
return OFListBase::base_empty(); }
358 size_t size()
const {
return OFListBase::base_size(); }
370 T&
back() {
return *(--end()); }
375 void push_front(
const T& x) { insert(begin(), OFconst_cast(T&, x)); }
387 void push_back(
const T& x) { insert(end(), OFconst_cast(T&, x)); }
423 while (position != last) position = erase(position);
430 void clear() { OFListBase::base_clear(); }
439 splice(position, x, x.
begin(), x.
end());
451 splice(position, x, change, i);
464 OFListBase::base_splice(position.
node, first.
node, last.
node);
472 void remove(
const T& value)
478 if (*first == value) first = erase(first);
491 #ifdef HAVE_FUNCTION_TEMPLATE 493 #define OFListInsert(InputIterator, T, c, pos, first, last) OF_ListInsert((c), (pos), (first), (last)) 495 #define OFListRemoveIf(Predicate, T, c, pred) OF_ListRemoveIf((c), (pred)) 497 #elif defined(HAVE_STATIC_TEMPLATE_METHOD) 499 #define OFListInsert(InputIterator, T, c, pos, first, last) OF_ListInsertClass<InputIterator, T>::OF_ListInsert((c), (pos), (first), (last)) 501 #define OFListRemoveIf(Predicate, T, c, pred) OF_ListRemoveIfClass<Predicate, T>::OF_ListRemoveIf((c), (pred)) 504 #error Your C++ Compiler is not capable of compiling this code 508 template <
class InputIterator,
class T>
509 #if defined(HAVE_STATIC_TEMPLATE_METHOD) && !defined(HAVE_FUNCTION_TEMPLATE) 510 class OF_ListInsertClass
516 InputIterator first, InputIterator last)
520 c.
insert(position, *first);
524 #if defined(HAVE_STATIC_TEMPLATE_METHOD) && !defined(HAVE_FUNCTION_TEMPLATE) 530 template <
class Predicate,
class T>
531 #if defined(HAVE_STATIC_TEMPLATE_METHOD) && !defined(HAVE_FUNCTION_TEMPLATE) 532 class OF_ListRemoveIfClass
537 void OF_ListRemoveIf(
OFList<T>& c, Predicate pred)
541 while (first != last)
544 first = c.
erase(first);
550 #if defined(HAVE_STATIC_TEMPLATE_METHOD) && !defined(HAVE_FUNCTION_TEMPLATE) 554 #define OFListIterator(x) OFIterator< x > 555 #define OFListConstIterator(x) OFIterator< x > OFBool operator==(const OFIterator< T > &x) const
comparison of two iterators.
OFListLinkBase * node
list node referenced by the iterator
void clear()
removes all elements from the list.
T & operator*() const
dereferences the iterator.
OFList()
default constructor
void copy(const OFList< T > &oldList)
inserts a copy of the given list into the current list.
void push_front(const T &x)
inserts before the first element of the list.
T & back()
returns a reference to the last element in the list.
void recalcListSize()
counts the elements in the list and adjusts the listSize member variable.
OFIterator< T > insert(OFIterator< T > position, const T &x)
inserts an element into the list before the given position.
OFIterator(OFListLinkBase *x)
constructor.
OFIterator< T > operator--(int)
moves the iterator to the previous element of the list.
void push_back(const T &x)
inserts after the last element of the list.
OFIterator< T > & operator++()
moves the iterator to the next element of the list.
void pop_back()
removes the last element of the list.
T * operator->() const
dereferences the iterator.
OFIterator< T > erase(OFIterator< T > position, OFIterator< T > last)
removes all elements in the range [position,last) from the list.
void pop_front()
removes the first element of the list.
OFIterator< T > & operator--()
moves the iterator to the previous element of the list.
OFIterator< T > operator++(int)
moves the iterator to the next element of the list.
void insert(OFIterator< T > position, size_t n, const T &x)
inserts n elements with value x into the list, before the given position.
void splice(OFIterator< T > position, OFList< T > &x, OFIterator< T > first, OFIterator< T > last)
inserts elements in the range [first, last) before position and removes the elements from x ...
double linked list template class.
void splice(OFIterator< T > position, OFList< T > &x)
moves the contents of list x into the current list before the given position.
OFBool operator!=(const OFIterator< T > &x) const
comparison of two iterators.
OFIterator< T > erase(OFIterator< T > position)
removes the element at the given position from the list.
OFBool empty() const
returns true if list is empty.
OFIterator()
default constructor.
T & front()
returns a reference to the first element in the list.
OFIterator< T > begin() const
returns an iterator referencing the first element in the list.
size_t size() const
returns number of elements in the list.
OFIterator(const OFIterator< T > &x)
copy constructor
void splice(OFIterator< T > position, OFList< T > &x, OFIterator< T > i)
inserts one element from list x into the current list and removes it from x
OFList(const OFList< T > &oldList)
copy constructor
iterator class for OFList.
OFIterator< T > end() const
returns an iterator which points to the past-to-end element of the list.
OFIterator< T > & operator=(const OFIterator< T > &x)
copy assignment operator