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 librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 // $XConsortium: UAS_PtrList.cc /main/5 1996/08/06 09:23:58 rcs $
25 #include "Managers/CatMgr.hh"
26 #include "Registration.hh"
29 UAS_PtrList<T>::UAS_PtrList() {
36 UAS_PtrList<T>::UAS_PtrList (const UAS_PtrList<T> &l) {
38 fNumItems = l.fNumItems;
39 fListSize = l.fListSize;
41 fItems = new Tptr[fListSize];
42 for (int i = 0; i < fNumItems; i ++)
43 fItems[i] = l.fItems[i];
48 UAS_PtrList<T>::~UAS_PtrList () {
54 UAS_PtrList<T>::operator = (const UAS_PtrList<T> &l) {
59 fListSize = l.fListSize;
60 fNumItems = l.fNumItems;
62 fItems = new Tptr[fListSize];
63 for (int i = 0; i < fNumItems; i ++)
64 fItems[i] = l.fItems[i];
71 UAS_PtrList<T>::operator [] (int i) const {
77 UAS_PtrList<T>::item (int i) const {
78 if (i < 0 || i >= fNumItems)
79 throw (UAS_Exception (
80 (char*)UAS_String(CATGETS(Set_UAS_Base, 4, "File a Bug"))));
86 UAS_PtrList<T>::numItems () const {
92 UAS_PtrList<T>::append (T *newItem) {
93 if (fNumItems == fListSize) {
94 T **newList = new Tptr[fListSize += 4];
95 for (int i = 0; i < fNumItems; i ++)
96 newList[i] = fItems[i];
100 fItems[fNumItems ++] = newItem;
105 UAS_PtrList<T>::remove (T *oldItem) {
107 for (i = 0; i < fNumItems; i ++)
108 if (fItems[i] == oldItem)
112 for (i ++; i < fNumItems; i ++)
113 fItems[i-1] = fItems[i];
119 UAS_PtrList<T>::clear () {