TQStrList Class

Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# TQStrList Class Reference

The TQStrList class provides a doubly-linked list of char*. More...

`#include <ntqstrlist.h>`

Inherits TQPtrList<char>.

Inherited by TQStrIList.

List of all member functions.

## Public Members

- TQStrList ( bool deepCopies = true )
- TQStrList ( const TQStrList & list )
- ~TQStrList ()
- TQStrList & operator= ( const TQStrList & list )

## Detailed Description

The TQStrList class provides a doubly-linked list of char*.

If you want a string list of TQStrings use TQStringList.

This class is a TQPtrList<char> instance (a list of char*).

TQStrList can make deep or shallow copies of the strings that are inserted.

A deep copy means that memory is allocated for the string and then the string data is copied into that memory. A shallow copy is just a copy of the pointer value and not of the string data itself.

The disadvantage of shallow copies is that because a pointer can be deleted only once, the program must put all strings in a central place and know when it is safe to delete them (i.e. when the strings are no longer referenced by other parts of the program). This can make the program more complex. The advantage of shallow copies is that they consume far less memory than deep copies. It is also much faster to copy a pointer (typically 4 or 8 bytes) than to copy string data.

A TQStrList that operates on deep copies will, by default, turn on auto-deletion (see setAutoDelete()). Thus, by default TQStrList will deallocate any string copies it allocates.

The virtual compareItems() function is reimplemented and does a case-sensitive string comparison. The inSort() function will insert strings in sorted order. In general it is fastest to insert the strings as they come and sort() at the end; inSort() is useful when you just have to add a few extra strings to an already sorted list.

The TQStrListIterator class is an iterator for TQStrList.

See also Collection Classes, Text Related Classes, and Non-GUI Classes.

## Member Function Documentation

### TQStrList::TQStrList ( bool deepCopies = true )

Constructs an empty list of strings. Will make deep copies of all inserted strings if deepCopies is true, or use shallow copies if deepCopies is false.

### TQStrList::TQStrList ( const TQStrList & list )

Constructs a copy of list.

If list has deep copies, this list will also get deep copies. Only the pointers are copied (shallow copy) if the other list does not use deep copies.

### TQStrList::~TQStrList ()

Destroys the list. All strings are removed.

### TQStrList & TQStrList::operator= ( const TQStrList & list )

Assigns list to this list and returns a reference to this list.

If list has deep copies, this list will also get deep copies. Only the pointers are copied (shallow copy) if the other list does not use deep copies.

This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.