1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef TRANSFRMX_LIST_H
7 #define TRANSFRMX_LIST_H
14 * Represents an ordered list of Object pointers. Modeled after a Java 2 List.
16 class txList
: public txObject
{
17 friend class txListIterator
;
21 * Creates an empty txList
26 * txList destructor, object references will not be deleted.
31 * Returns the number of items in this txList
36 * Returns true if there are no items in this txList
38 inline bool isEmpty() { return itemCount
== 0; }
41 * Adds the given Object to the list
43 void add(void* objPtr
);
46 * Removes all the objects from the list
58 * Removes the given ListItem pointer from the list
60 ListItem
* remove(ListItem
* sItem
);
63 txList(const txList
& aOther
); // not implemented
69 void insertAfter(void* objPtr
, ListItem
* sItem
);
70 void insertBefore(void* objPtr
, ListItem
* sItem
);
74 * An Iterator for the txList Class
76 class txListIterator
{
79 * Creates a new txListIterator for the given txList
80 * @param list, the txList to create an Iterator for
82 explicit txListIterator(txList
* list
);
85 * Adds the Object pointer to the txList pointed to by this txListIterator.
86 * The Object pointer is inserted as the next item in the txList
87 * based on the current position within the txList
88 * @param objPtr the Object pointer to add to the list
90 void addAfter(void* objPtr
);
93 * Adds the Object pointer to the txList pointed to by this txListIterator.
94 * The Object pointer is inserted as the previous item in the txList
95 * based on the current position within the txList
96 * @param objPtr the Object pointer to add to the list
98 void addBefore(void* objPtr
);
101 * Returns true if a successful call to the next() method can be made
102 * @return true if a successful call to the next() method can be made,
108 * Returns the next Object pointer from the list
113 * Returns the previous Object pointer from the list
118 * Returns the current Object
123 * Removes the Object last returned by the next() or previous() methods;
124 * @return the removed Object pointer
129 * Resets the current location within the txList to the beginning of the
135 * Resets the current location within the txList to the end of the txList
140 //-- points to the current list item
141 txList::ListItem
* currentItem
;
143 //-- points to the list to iterator over
146 //-- we've moved off the end of the list