2 * $TOG: xList.hh /main/14 1998/04/17 11:40:11 mgreess $
4 * Copyright (c) 1993 HAL Computer Systems International, Ltd.
5 * All rights reserved. Unpublished -- rights reserved under
6 * the Copyright Laws of the United States. USE OF A COPYRIGHT
7 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
10 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
11 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
12 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
13 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
16 * RESTRICTED RIGHTS LEGEND
17 * Use, duplication, or disclosure by the Government is subject
18 * to the restrictions as set forth in subparagraph (c)(l)(ii)
19 * of the Rights in Technical Data and Computer Software clause
20 * at DFARS 252.227-7013.
22 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
31 #include "List_base.hh"
33 template <class T> class xList;
34 template <class T> class List_Iterator;
38 class Link : private Link_base
40 friend class xList<T>;
41 friend class List_Iterator<T>;
44 Link (const T &element)
52 #if defined(__uxp__) || defined(_IBMR2) || defined(__osf__) || defined(USL) || defined(linux) || defined(CSRG_BASED)
53 class xList : public List_base
55 class xList : private List_base
58 // NOTE: This friend declaration is too general because cfront
59 // barfs when I do it the correct way. 22:05 22-Jul-93 DJB
61 friend class List_Iterator<T>;
63 #if !defined(_IBMR2) && !defined(__osf__) && !defined(USL) && !defined(linux) && !defined(CSRG_BASED)
64 template <class T> friend class List_Iterator;
71 void insert (const T &element)
72 { List_base::insert (new Link<T> (element)); }
74 void insert_before (List_Iterator<T> &iterator, const T &element);
76 void insert_after (List_Iterator<T> &iterator, const T &element);
78 void append (const T &element);
80 // Element must have an operator == that works.
81 void remove (T &element);
83 void remove (List_Iterator<T> &iterator);
86 unsigned int length() const
87 { return (List_base::length()); }
89 // Another hack. CC gets a bus error if we pass a reference to
90 // to List_Iter constructor. So we add an automatic conversion
91 // here to avoid the hassle of taking the address of a List.
92 operator const xList<T> *() const
99 #if defined(_IBMR2) || defined(__osf__) || defined(linux) || defined(CSRG_BASED)
100 class List_Iterator : public List_Iterator_base
102 class List_Iterator : private List_Iterator_base
105 friend class xList<T>;
110 List_Iterator (const xList<T> *list)
111 : List_Iterator_base (list)
115 { List_Iterator_base::reset(); }
118 { List_Iterator_base::last(); }
120 void operator= (const xList<T> *list)
121 { List_Iterator_base::operator= (list); }
124 int operator!= (int i)
125 { return (List_Iterator_base::operator!= (i)); }
129 { return (((Link<T> *) List_Iterator_base::item())->f_element); }
132 { return (List_Iterator_base::operator++ ()); }
134 void *operator++ (int)
135 { return (List_Iterator_base::operator++ ()); }
137 operator void *() const
138 { return (List_Iterator_base::operator void *()); }
141 #ifdef EXPAND_TEMPLATES
145 #endif /* _xList_hh */
146 /* DO NOT ADD ANY LINES AFTER THIS #endif */