2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * $TOG: xList.hh /main/14 1998/04/17 11:40:11 mgreess $
26 * Copyright (c) 1993 HAL Computer Systems International, Ltd.
27 * All rights reserved. Unpublished -- rights reserved under
28 * the Copyright Laws of the United States. USE OF A COPYRIGHT
29 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
32 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
33 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
34 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
35 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
38 * RESTRICTED RIGHTS LEGEND
39 * Use, duplication, or disclosure by the Government is subject
40 * to the restrictions as set forth in subparagraph (c)(l)(ii)
41 * of the Rights in Technical Data and Computer Software clause
42 * at DFARS 252.227-7013.
44 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
53 #include "List_base.hh"
55 template <class T> class xList;
56 template <class T> class List_Iterator;
60 class Link : private Link_base
62 friend class xList<T>;
63 friend class List_Iterator<T>;
66 Link (const T &element)
74 #if defined(_IBMR2) || defined(__osf__) || \
75 defined(linux) || defined(CSRG_BASED) || defined(sun)
76 class xList : public List_base
78 class xList : private List_base
81 // NOTE: This friend declaration is too general because cfront
82 // barfs when I do it the correct way. 22:05 22-Jul-93 DJB
84 friend class List_Iterator<T>;
86 #if !defined(_IBMR2) && !defined(__osf__) && \
87 !defined(linux) && !defined(CSRG_BASED) && !defined(sun)
88 template <class T> friend class List_Iterator;
95 void insert (const T &element)
96 { List_base::insert (new Link<T> (element)); }
98 void insert_before (List_Iterator<T> &iterator, const T &element);
100 void insert_after (List_Iterator<T> &iterator, const T &element);
102 void append (const T &element);
104 // Element must have an operator == that works.
105 void remove (T &element);
107 void remove (List_Iterator<T> &iterator);
110 unsigned int length() const
111 { return (List_base::length()); }
113 // Another hack. CC gets a bus error if we pass a reference to
114 // to List_Iter constructor. So we add an automatic conversion
115 // here to avoid the hassle of taking the address of a List.
116 operator const xList<T> *() const
123 #if defined(_IBMR2) || defined(__osf__) || defined(linux) || \
124 defined(CSRG_BASED) || defined(sun)
125 class List_Iterator : public List_Iterator_base
127 class List_Iterator : private List_Iterator_base
130 friend class xList<T>;
135 List_Iterator (const xList<T> *list)
136 : List_Iterator_base (list)
140 { List_Iterator_base::reset(); }
143 { List_Iterator_base::last(); }
145 void operator= (const xList<T> *list)
146 { List_Iterator_base::operator= (list); }
149 int operator!= (int i)
150 { return (List_Iterator_base::operator!= (i)); }
154 { return (((Link<T> *) List_Iterator_base::item())->f_element); }
157 { return (List_Iterator_base::operator++ ()); }
159 void *operator++ (int)
160 { return (List_Iterator_base::operator++ ()); }
162 operator void *() const
163 { return (List_Iterator_base::operator void *()); }
166 #ifdef EXPAND_TEMPLATES
170 #endif /* _xList_hh */
171 /* DO NOT ADD ANY LINES AFTER THIS #endif */