2 * $XConsortium: List.hh /main/7 1996/08/10 11:31:57 cde-hal $
4 * Copyright (c) 1992 HaL Computer Systems, Inc. All rights reserved.
5 * UNPUBLISHED -- rights reserved under the Copyright Laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
9 * This software contains confidential information and trade secrets of HaL
10 * Computer Systems, Inc. Use, disclosure, or reproduction is prohibited
11 * without the prior express written permission of HaL Computer Systems, Inc.
13 * RESTRICTED RIGHTS LEGEND
14 * Use, duplication, or disclosure by the Government is subject to
15 * restrictions as set forth in subparagraph (c)(l)(ii) of the Rights in
16 * Technical Data and Computer Software clause at DFARS 252.227-7013.
17 * HaL Computer Systems, Inc.
18 * 1315 Dell Avenue, Campbell, CA 95008
24 class List : public FolioObject
27 enum grow_method_t { GROW_ADD, GROW_MULTIPLY };
29 enum notifications { APPENDED = FolioObject::_LAST, INSERTED, REMOVED };
32 // increment really defaults to initial_size
33 List (int initial_size, int increment = 0, grow_method_t method = GROW_ADD,
34 bool delete_elements = FALSE);
37 { return (f_length); }
38 // NOTE: clean up and use either reference or ptr. figure this out - DJB
39 virtual void append (FolioObject &);
40 virtual void append (FolioObject *object)
42 virtual void remove (FolioObject &);
43 virtual void remove (FolioObject *object)
45 virtual void remove (unsigned int);
46 // Change find to return FolioObect *
47 virtual int find (FolioObject &); // returns -1 on failure
48 virtual void replace (int, FolioObject &);
49 virtual void replace (int i, FolioObject *obj);
50 virtual void insert (unsigned int, FolioObject *);
51 virtual void remove_all()
53 virtual void remove_all (bool delete_elements);
55 virtual FolioObject *operator[](int) const ;
57 virtual List *copy() const; // NOTE: just copies the pointers, not the
58 // pointed at objects - jbm
60 void dtor_delete_elements (bool delete_elements)
61 { f_dtor_delete_elements = delete_elements; }
63 protected: // functions
64 void check_space (int num_additions = 1);
66 protected: // variables
67 FolioObject **f_list_element; // array of list elements
68 unsigned short f_length;
69 unsigned short f_internal_length;
70 unsigned short f_increment;
71 grow_method_t f_grow_method;
72 bool f_dtor_delete_elements : 1;
76 List::operator[] (int position) const
78 // NOTE: need to be able to "throw" an exception here!!
79 if (position >= f_length)
82 return (f_list_element[position]);
86 List::replace (int /* position */, FolioObject& /* element */)
88 // This function is obsolete, do not try to use
89 // someone needs to clean it up.
94 List::replace (int position, FolioObject *element)
96 replace (position, *element);