📄 oflist.h
字号:
*/ OFList() : OFListBase() { } /** copy constructor */ OFList(const OFList<T>& oldList):OFListBase() { copy(oldList); } /** returns an iterator referencing the first element in the list. * If the list is empty, then begin() == end(). * @return iterator to first element of list, by value. */ OFIterator<T> begin() const { return OFIterator<T>(OFListBase::base_begin()); } /** returns an iterator which points to the past-to-end element * of the list. * @return iterator to past-to-end, by value. */ OFIterator<T> end() const { return OFIterator<T>(OFListBase::base_end()); } /** returns true if list is empty. * @return OFTrue if list is empty, OFFalse otherwise. */ OFBool empty() const { return OFListBase::base_empty(); } /** returns number of elements in the list. * @return number of elements */ size_t size() const { return OFListBase::base_size(); } /** returns a reference to the first element in the list. * May only be called if list is non-empty. * @return first element in list, by reference */ T& front() { return *begin(); } /** returns a reference to the last element in the list. * May only be called if list is non-empty. * @return last element in list, by reference */ T& back() { return *(--end()); } /** inserts before the first element of the list. * @param x value from which the new list entry is copy constructed */ void push_front(const T& x) { insert(begin(), OFconst_cast(T&, x)); } /* const cast away to keep some old compilers happy */ /** removes the first element of the list. * May only be called if list is non-empty. * All iterators pointing to the removed element become invalid. */ void pop_front() { erase(begin()); } /** inserts after the last element of the list. * @param x value from which the new list entry is copy constructed */ void push_back(const T& x) { insert(end(), OFconst_cast(T&, x)); } /* const cast away to keep some old compilers happy */ /** removes the last element of the list. * May only be called if list is non-empty. * All iterators pointing to the removed element become invalid. */ void pop_back() { erase(--end()); } /** inserts n elements with value x into the list, before the given position. * @param position iterator to position before which the elements are inserted * @param n number of entries to be created * @param x value from which the new list entries are copy-constructed */ void insert(OFIterator<T> position, size_t n, const T& x) { while(n--) OFListBase::base_insert(position.node, new OFListLink<T>(x)); } /** removes the element at the given position from the list. * All iterators pointing to the removed element become invalid. * @return iterator pointing to the element after the removed one */ OFIterator<T> erase(OFIterator<T> position) { return OFIterator<T>(OFListBase::base_erase(position.node)); } /** removes all elements in the range [position,last) from the list. * All iterators pointing to the removed elements become invalid. * @param position iterator to the first element to be deleted * @param last iterator pointing to the element after the last element to be removed * @return iterator pointing to the element after the last removed element */ OFIterator<T> erase(OFIterator<T> position, OFIterator<T> last) { while (position != last) position = erase(position); return last; } /** removes all elements from the list. * All iterators pointing to elements in the list become invalid. */ void clear() { OFListBase::base_clear(); } /** moves the contents of list x into the current list before the * given position. * @param position iterator to position before which the elements are inserted * @param x list from which the elements are taken, becomes empty */ void splice(OFIterator<T> position, OFList<T>& x) { splice(position, x, x.begin(), x.end()); } /** inserts one element from list x into the current list and removes it from x * @param position iterator to position before which the element is inserted * @param x list from which the element is taken * @param i iterator to element in list x which is to be moved */ void splice(OFIterator<T> position, OFList<T>& x, OFIterator<T> i) { OFIterator<T> change(i); ++i; splice(position, x, change, i); } /** inserts elements in the range [first, last) before position and * removes the elements from x * @param position iterator to position before which the elements are inserted * @param x list from which the elements are taken * @param first iterator to first element in list x to be moved * @param last iterator to element after last element in list x to be moved */ void splice(OFIterator<T> position, OFList<T>& x, OFIterator<T> first, OFIterator<T> last) { OFListBase::base_splice(position.node, first.node, last.node); x.recalcListSize(); } /** removes all elements from the list referred by an iterator i where * *i == value * @param value value to be compared with list contents */ void remove(const T& value) { OFIterator<T> first = begin(); OFIterator<T> last = end(); while(first != last) { if (*first == value) first = erase(first); else ++first; } }private: /** private undefined copy assignment operator */ OFList<T>& operator=(const OFList<T>& arg);};#ifdef HAVE_FUNCTION_TEMPLATE#define OFListInsert(InputIterator, T, c, pos, first, last) OF_ListInsert((c), (pos), (first), (last))#define OFListRemoveIf(Predicate, T, c, pred) OF_ListRemoveIf((c), (pred))#elif defined(HAVE_STATIC_TEMPLATE_METHOD)#define OFListInsert(InputIterator, T, c, pos, first, last) OF_ListInsertClass<InputIterator, T>::OF_ListInsert((c), (pos), (first), (last))#define OFListRemoveIf(Predicate, T, c, pred) OF_ListRemoveIfClass<Predicate, T>::OF_ListRemoveIf((c), (pred))#else#error Your C++ Compiler is not capable of compiling this code#endif// Insert the elements in range [first, last) into listtemplate <class InputIterator, class T>#if defined(HAVE_STATIC_TEMPLATE_METHOD) && !defined(HAVE_FUNCTION_TEMPLATE)class OF_ListInsertClass{public:static#endifvoid OF_ListInsert(OFList<T>& c, OFIterator<T> position, InputIterator first, InputIterator last){ while(first != last) { c.insert(position, *first); ++first; }}#if defined(HAVE_STATIC_TEMPLATE_METHOD) && !defined(HAVE_FUNCTION_TEMPLATE)};#endif// Erases all elements in the list referred by an iterator i where// pred(*i) == truetemplate <class Predicate, class T>#if defined(HAVE_STATIC_TEMPLATE_METHOD) && !defined(HAVE_FUNCTION_TEMPLATE)class OF_ListRemoveIfClass{public:static#endifvoid OF_ListRemoveIf(OFList<T>& c, Predicate pred){ OFIterator<T> first = c.begin(); OFIterator<T> last = c.end(); while (first != last) { if (pred(*first)) first = c.erase(first); else ++first; }}#if defined(HAVE_STATIC_TEMPLATE_METHOD) && !defined(HAVE_FUNCTION_TEMPLATE)};#endif#define OFListIterator(x) OFIterator< x >#define OFListConstIterator(x) OFIterator< x >#endif#endif/*** CVS/RCS Log:** $Log: oflist.h,v $** Revision 1.22 2005/12/08 16:05:58 meichel** Changed include path schema for all DCMTK header files**** Revision 1.21 2004/04/14 11:44:48 joergr** Replaced non-Unix newline characters.**** Revision 1.20 2003/08/07 11:44:55 joergr** Slightly modified header comments to conform to doxygen syntax.**** Revision 1.19 2003/07/11 13:46:14 joergr** Added workaround to get rid of "implicit typename" warnings on gcc 3.x** (introduced macro OFLIST_TYPENAME).**** Revision 1.18 2003/07/09 13:57:43 meichel** Adapted type casts to new-style typecast operators defined in ofcast.h**** Revision 1.17 2003/06/12 15:20:30 joergr** Slightly modified macro definitions to avoid potential parser errors (added** space character after '<' and before '>').**** Revision 1.16 2003/06/12 13:21:54 joergr** Introduced macro OFListConstIterator() to support STL const_iterators.**** Revision 1.15 2003/06/03 10:20:00 meichel** OFList now explicitly defined as std::list if std namespace present**** Revision 1.14 2002/11/27 11:23:05 meichel** Adapted module ofstd to use of new header file ofstdinc.h**** Revision 1.13 2001/08/23 16:05:52 meichel** Added private undefined copy assignment operators to avoid gcc warnings**** Revision 1.12 2001/06/01 15:51:34 meichel** Updated copyright header**** Revision 1.11 2000/10/10 12:01:21 meichel** Created/updated doc++ comments**** Revision 1.10 2000/03/08 16:36:02 meichel** Updated copyright header.**** Revision 1.9 1998/11/27 12:42:51 joergr** Added copyright message to source files and changed CVS header.**** Revision 1.8 1998/07/02 07:47:02 meichel** Some code purifications to avoid gcc 2.8.1 -Weffc++ warnings.**** Revision 1.7 1998/06/29 12:09:23 meichel** Removed some name clashes (e.g. local variable with same** name as class member) to improve maintainability.** Applied some code purifications proposed by the gcc 2.8.1 -Weffc++ option.**** Revision 1.6 1998/02/06 15:07:38 meichel** Removed many minor problems (name clashes, unreached code)** reported by Sun CC4 with "+w" or Sun CC2.**** Revision 1.5 1997/11/10 16:31:19 meichel** Corrected bug possibly causing a memory leak in OFList.** Added virtual destructors to classes OFListLinkBase and OFListLink.**** Revision 1.4 1997/09/11 15:43:15 hewett** Minor changes to eliminate warnings when compiled under the** Signus GnuWin32 envionment. Changed order of initialisers** for OFListLink and OFStackLink. Make ~OFLisBase and ~OFStackBase** virtual destructors.**** Revision 1.3 1997/07/24 13:11:00 andreas** - Removed Warnings from SUN CC 2.0.1**** Revision 1.2 1997/07/07 07:34:18 andreas** - Corrected destructor for OFListBase, now the dummy element is** deleted.**** Revision 1.1 1997/07/02 11:51:14 andreas** - Preliminary release of the OFFIS Standard Library.** In the future this library shall contain a subset of the** ANSI C++ Library (Version 3) that works on a lot of different** compilers. Additionally this library shall include classes and** functions that are often used. All classes and functions begin** with OF... This library is independent of the DICOM development and** shall contain no DICOM specific stuff.*****/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -