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 * $XConsortium: List.hh /main/7 1996/08/10 11:31:57 cde-hal $
26 * Copyright (c) 1992 HaL Computer Systems, Inc. All rights reserved.
27 * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
28 * States. Use of a copyright notice is precautionary only and does not
29 * imply publication or disclosure.
31 * This software contains confidential information and trade secrets of HaL
32 * Computer Systems, Inc. Use, disclosure, or reproduction is prohibited
33 * without the prior express written permission of HaL Computer Systems, Inc.
35 * RESTRICTED RIGHTS LEGEND
36 * Use, duplication, or disclosure by the Government is subject to
37 * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
38 * Technical Data and Computer Software clause at DFARS 252.227-7013.
39 * HaL Computer Systems, Inc.
40 * 1315 Dell Avenue, Campbell, CA 95008
46 class List : public FolioObject
49 enum grow_method_t { GROW_ADD, GROW_MULTIPLY };
51 enum notifications { APPENDED = FolioObject::_LAST, INSERTED, REMOVED };
54 // increment really defaults to initial_size
55 List (int initial_size, int increment = 0, grow_method_t method = GROW_ADD,
56 bool delete_elements = FALSE);
59 { return (f_length); }
60 // NOTE: clean up and use either reference or ptr. figure this out - DJB
61 virtual void append (FolioObject &);
62 virtual void append (FolioObject *object)
64 virtual void remove (FolioObject &);
65 virtual void remove (FolioObject *object)
67 virtual void remove (unsigned int);
68 // Change find to return FolioObect *
69 virtual int find (FolioObject &); // returns -1 on failure
70 virtual void replace (int, FolioObject &);
71 virtual void replace (int i, FolioObject *obj);
72 virtual void insert (unsigned int, FolioObject *);
73 virtual void remove_all()
75 virtual void remove_all (bool delete_elements);
77 virtual FolioObject *operator[](int) const ;
79 virtual List *copy() const; // NOTE: just copies the pointers, not the
80 // pointed at objects - jbm
82 void dtor_delete_elements (bool delete_elements)
83 { f_dtor_delete_elements = delete_elements; }
85 protected: // functions
86 void check_space (int num_additions = 1);
88 protected: // variables
89 FolioObject **f_list_element; // array of list elements
90 unsigned short f_length;
91 unsigned short f_internal_length;
92 unsigned short f_increment;
93 grow_method_t f_grow_method;
94 bool f_dtor_delete_elements : 1;
98 List::operator[] (int position) const
100 // NOTE: need to be able to "throw" an exception here!!
101 if (position >= f_length)
104 return (f_list_element[position]);
108 List::replace (int /* position */, FolioObject& /* element */)
110 // This function is obsolete, do not try to use
111 // someone needs to clean it up.
116 List::replace (int position, FolioObject *element)
118 replace (position, *element);