1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
{
18 friend class txListIterator
;
23 * Creates an empty txList
28 * txList destructor, object references will not be deleted.
33 * Returns the number of items in this txList
38 * Returns true if there are no items in this txList
42 return itemCount
== 0;
46 * Adds the given Object to the list
48 nsresult
add(void* objPtr
);
51 * Removes all the objects from the list
64 * Removes the given ListItem pointer from the list
66 ListItem
* remove(ListItem
* sItem
);
69 txList(const txList
& aOther
); // not implemented
75 nsresult
insertAfter(void* objPtr
, ListItem
* sItem
);
76 nsresult
insertBefore(void* objPtr
, ListItem
* sItem
);
82 * An Iterator for the txList Class
84 class txListIterator
{
88 * Creates a new txListIterator for the given txList
89 * @param list, the txList to create an Iterator for
91 explicit txListIterator(txList
* list
);
94 * Adds the Object pointer to the txList pointed to by this txListIterator.
95 * The Object pointer is inserted as the next item in the txList
96 * based on the current position within the txList
97 * @param objPtr the Object pointer to add to the list
99 nsresult
addAfter(void* objPtr
);
102 * Adds the Object pointer to the txList pointed to by this txListIterator.
103 * The Object pointer is inserted as the previous item in the txList
104 * based on the current position within the txList
105 * @param objPtr the Object pointer to add to the list
107 nsresult
addBefore(void* objPtr
);
110 * Returns true if a successful call to the next() method can be made
111 * @return true if a successful call to the next() method can be made,
117 * Returns the next Object pointer from the list
122 * Returns the previous Object pointer from the list
127 * Returns the current Object
132 * Removes the Object last returned by the next() or previous() methods;
133 * @return the removed Object pointer
138 * Resets the current location within the txList to the beginning of the txList
143 * Resets the current location within the txList to the end of the txList
149 //-- points to the current list item
150 txList::ListItem
* currentItem
;
152 //-- points to the list to iterator over
155 //-- we've moved off the end of the list