diff options
Diffstat (limited to 'doc/collect.doc')
-rw-r--r-- | doc/collect.doc | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/doc/collect.doc b/doc/collect.doc index d7dfdeb79..09ee58382 100644 --- a/doc/collect.doc +++ b/doc/collect.doc @@ -68,11 +68,11 @@ The value-based collections are: The pointer-based collections are: \list \i \l QCache and \l QIntCache, LRU (least recently used) caches. -\i \l QDict, \l QIntDict and \l QPtrDict dictionaries. -\i \l QPtrList, a doubly linked list. -\i \l QPtrQueue, a FIFO (first in, first out) queue. -\i \l QPtrStack, a LIFO (last in, first out) stack. -\i \l QPtrVector, a vector. +\i \l QDict, \l QIntDict and \l TQPtrDict dictionaries. +\i \l TQPtrList, a doubly linked list. +\i \l TQPtrQueue, a FIFO (first in, first out) queue. +\i \l TQPtrStack, a LIFO (last in, first out) stack. +\i \l TQPtrVector, a vector. \endlist \l QMemArray is exceptional; it is neither pointer nor value based, @@ -87,8 +87,8 @@ is a class for traversing the items in a collection: \link QIntCacheIterator QIntCacheIterator\endlink \i \link QDictIterator QDictIterator\endlink, \link QIntDictIterator QIntDictIterator\endlink, and - \link QPtrDictIterator QPtrDictIterator\endlink -\i \link QPtrListIterator QPtrListIterator\endlink + \link TQPtrDictIterator TQPtrDictIterator\endlink +\i \link TQPtrListIterator TQPtrListIterator\endlink \i \link TQValueListIterator TQValueListIterator\endlink, and \link TQValueListConstIterator TQValueListConstIterator\endlink \i \link TQMapIterator TQMapIterator\endlink, and @@ -113,13 +113,13 @@ This strategy allows Qt's templates to be very economical on space (instantiating one of these templates adds only inlinable calls to the base classes), without hurting performance. -\section1 A QPtrList Example +\section1 A TQPtrList Example This example shows how to store Employee items in a list and prints them out in reverse order: \code - #include <ntqptrlist.h> + #include <tqptrlist.h> #include <ntqstring.h> #include <stdio.h> @@ -136,14 +136,14 @@ them out in reverse order: int main() { - QPtrList<Employee> list; // list of pointers to Employee + TQPtrList<Employee> list; // list of pointers to Employee list.setAutoDelete( TRUE ); // delete items when they are removed list.append( new Employee("Bill", 50000) ); list.append( new Employee("Steve",80000) ); list.append( new Employee("Ron", 60000) ); - QPtrListIterator<Employee> it(list); // iterator for employee list + TQPtrListIterator<Employee> it(list); // iterator for employee list for ( it.toLast(); it.current(); --it) ) { Employee *emp = it.current(); printf( "%s earns %d\n", emp->name(), emp->salary() ); @@ -162,12 +162,12 @@ Program output: \section1 Managing Collection Items -All pointer-based collections inherit the \l QPtrCollection base class. +All pointer-based collections inherit the \l TQPtrCollection base class. This class only knows about the number of items in the collection and the deletion strategy. By default, items in a collection are not deleted when they are -removed from the collection. The \l QPtrCollection::setAutoDelete() +removed from the collection. The \l TQPtrCollection::setAutoDelete() function specifies the deletion strategy. In the list example, we enable auto-deletion to make the list delete the items when they are removed from the list. @@ -176,27 +176,27 @@ When inserting an item into a collection, only the pointer is copied, not the item itself. This is called a shallow copy. It is possible to make the collection copy all of the item's data (known as a deep copy) when an item is inserted. All collection functions that insert an -item call the virtual function \l QPtrCollection::newItem() for the item +item call the virtual function \l TQPtrCollection::newItem() for the item to be inserted. Inherit a collection and reimplement it if you want to have deep copies in your collection. When removing an item from a list, the virtual function -\l{QPtrCollection::deleteItem()} is called. The default implementation +\l{TQPtrCollection::deleteItem()} is called. The default implementation in all collection classes deletes the item if auto-deletion is enabled. \section1 Usage -A pointer-based collection class, such as QPtrList\<type\>, defines a +A pointer-based collection class, such as TQPtrList\<type\>, defines a collection of \e pointers to \e type objects. The pointer (*) is implicit. -We discuss \l QPtrList here, but the same techniques apply to all +We discuss \l TQPtrList here, but the same techniques apply to all pointer-based collection classes and all collection class iterators. Template instantiation: \code - QPtrList<Employee> list; // wherever the list is used + TQPtrList<Employee> list; // wherever the list is used \endcode The item's class or type, Employee in our example, must be defined prior @@ -205,23 +205,23 @@ to the list definition. \code // Does not work: Employee is not defined class Employee; - QPtrList<Employee> list; + TQPtrList<Employee> list; // This works: Employee is defined before it is used class Employee { ... }; - QPtrList<Employee> list; + TQPtrList<Employee> list; \endcode \section1 Iterators -Although \l QPtrList has member functions to traverse the list, it can -often be better to make use of an iterator. \l QPtrListIterator is very +Although \l TQPtrList has member functions to traverse the list, it can +often be better to make use of an iterator. \l TQPtrListIterator is very safe and can traverse lists that are being modified at the same time. Multiple iterators can work independently on the same collection. -A QPtrList has an internal list of all the iterators that are +A TQPtrList has an internal list of all the iterators that are currently operating on it. When a list entry is removed, the list updates all iterators accordingly. @@ -239,8 +239,8 @@ Qt has the following predefined collection classes: \endlist In almost all cases you would choose \l QStringList, a value -list of implicitly shared TQString Unicode strings. QPtrStrList and -QPtrStrIList store only char pointers, not the strings themselves. +list of implicitly shared TQString Unicode strings. TQPtrStrList and +TQPtrStrIList store only char pointers, not the strings themselves. \section1 List of Pointer-based Collection Classes and Related Iterator Classes |