no bug - Import translations from android-l10n r=release a=l10n CLOSED TREE
[gecko.git] / dom / xslt / base / txList.h
blobeeafd12dda8cb04f520d64389f46ae120cd8cbb1
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
9 #include "txCore.h"
11 class txListIterator;
13 /**
14 * Represents an ordered list of Object pointers. Modeled after a Java 2 List.
15 **/
16 class txList : public txObject {
17 friend class txListIterator;
19 public:
20 /**
21 * Creates an empty txList
22 **/
23 txList();
25 /**
26 * txList destructor, object references will not be deleted.
27 **/
28 ~txList();
30 /**
31 * Returns the number of items in this txList
32 **/
33 int32_t getLength();
35 /**
36 * Returns true if there are no items in this txList
38 inline bool isEmpty() { return itemCount == 0; }
40 /**
41 * Adds the given Object to the list
42 **/
43 void add(void* objPtr);
46 * Removes all the objects from the list
48 void clear();
50 protected:
51 struct ListItem {
52 ListItem* nextItem;
53 ListItem* prevItem;
54 void* objPtr;
57 /**
58 * Removes the given ListItem pointer from the list
59 **/
60 ListItem* remove(ListItem* sItem);
62 private:
63 txList(const txList& aOther); // not implemented
65 ListItem* firstItem;
66 ListItem* lastItem;
67 int32_t itemCount;
69 void insertAfter(void* objPtr, ListItem* sItem);
70 void insertBefore(void* objPtr, ListItem* sItem);
73 /**
74 * An Iterator for the txList Class
75 **/
76 class txListIterator {
77 public:
78 /**
79 * Creates a new txListIterator for the given txList
80 * @param list, the txList to create an Iterator for
81 **/
82 explicit txListIterator(txList* list);
84 /**
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
89 **/
90 void addAfter(void* objPtr);
92 /**
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
97 **/
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,
103 * otherwise false
105 bool hasNext();
108 * Returns the next Object pointer from the list
110 void* next();
113 * Returns the previous Object pointer from the list
115 void* previous();
118 * Returns the current Object
120 void* current();
123 * Removes the Object last returned by the next() or previous() methods;
124 * @return the removed Object pointer
126 void* remove();
129 * Resets the current location within the txList to the beginning of the
130 * txList
132 void reset();
135 * Resets the current location within the txList to the end of the txList
137 void resetToEnd();
139 private:
140 //-- points to the current list item
141 txList::ListItem* currentItem;
143 //-- points to the list to iterator over
144 txList* list;
146 //-- we've moved off the end of the list
147 bool atEndOfList;
150 using List = txList;
152 #endif