You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
786 lines
41 KiB
786 lines
41 KiB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/tqvaluelist.doc:41 -->
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
|
<title>TQValueList Class</title>
|
|
<style type="text/css"><!--
|
|
fn { margin-left: 1cm; text-indent: -1cm; }
|
|
a:link { color: #004faf; text-decoration: none }
|
|
a:visited { color: #672967; text-decoration: none }
|
|
body { background: #ffffff; color: black; }
|
|
--></style>
|
|
</head>
|
|
<body>
|
|
|
|
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
|
<tr bgcolor="#E5E5E5">
|
|
<td valign=center>
|
|
<a href="index.html">
|
|
<font color="#004faf">Home</font></a>
|
|
| <a href="classes.html">
|
|
<font color="#004faf">All Classes</font></a>
|
|
| <a href="mainclasses.html">
|
|
<font color="#004faf">Main Classes</font></a>
|
|
| <a href="annotated.html">
|
|
<font color="#004faf">Annotated</font></a>
|
|
| <a href="groups.html">
|
|
<font color="#004faf">Grouped Classes</font></a>
|
|
| <a href="functions.html">
|
|
<font color="#004faf">Functions</font></a>
|
|
</td>
|
|
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQValueList Class Reference</h1>
|
|
|
|
<p>The TQValueList class is a value-based template class that
|
|
provides lists.
|
|
<a href="#details">More...</a>
|
|
<p>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when TQt is built with thread support.</p>
|
|
<p><tt>#include <<a href="tqvaluelist-h.html">tqvaluelist.h</a>></tt>
|
|
<p>Inherited by <a href="tqcanvasitemlist.html">TQCanvasItemList</a>, <a href="tqstringlist.html">TQStringList</a>, and <a href="tqvaluestack.html">TQValueStack</a>.
|
|
<p><a href="tqvaluelist-members.html">List of all member functions.</a>
|
|
<h2>Public Members</h2>
|
|
<ul>
|
|
<li class=fn>typedef TQValueListIterator<T> <a href="#iterator"><b>iterator</b></a></li>
|
|
<li class=fn>typedef TQValueListConstIterator<T> <a href="#const_iterator"><b>const_iterator</b></a></li>
|
|
<li class=fn>typedef T <a href="#value_type"><b>value_type</b></a></li>
|
|
<li class=fn>typedef value_type * <a href="#pointer"><b>pointer</b></a></li>
|
|
<li class=fn>typedef const value_type * <a href="#const_pointer"><b>const_pointer</b></a></li>
|
|
<li class=fn>typedef value_type & <a href="#reference"><b>reference</b></a></li>
|
|
<li class=fn>typedef const value_type & <a href="#const_reference"><b>const_reference</b></a></li>
|
|
<li class=fn>typedef size_t <a href="#size_type"><b>size_type</b></a></li>
|
|
<li class=fn><a href="#TQValueList"><b>TQValueList</b></a> ()</li>
|
|
<li class=fn><a href="#TQValueList-2"><b>TQValueList</b></a> ( const TQValueList<T> & l )</li>
|
|
<li class=fn><a href="#TQValueList-3"><b>TQValueList</b></a> ( const std::list<T> & l )</li>
|
|
<li class=fn><a href="#~TQValueList"><b>~TQValueList</b></a> ()</li>
|
|
<li class=fn>TQValueList<T> & <a href="#operator-eq"><b>operator=</b></a> ( const TQValueList<T> & l )</li>
|
|
<li class=fn>TQValueList<T> & <a href="#operator-eq-2"><b>operator=</b></a> ( const std::list<T> & l )</li>
|
|
<li class=fn>bool <a href="#operator-eq-eq-2"><b>operator==</b></a> ( const std::list<T> & l ) const</li>
|
|
<li class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const TQValueList<T> & l ) const</li>
|
|
<li class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const TQValueList<T> & l ) const</li>
|
|
<li class=fn>iterator <a href="#begin-2"><b>begin</b></a> ()</li>
|
|
<li class=fn>const_iterator <a href="#begin"><b>begin</b></a> () const</li>
|
|
<li class=fn>const_iterator <a href="#constBegin"><b>constBegin</b></a> () const</li>
|
|
<li class=fn>iterator <a href="#end"><b>end</b></a> ()</li>
|
|
<li class=fn>const_iterator <a href="#end-2"><b>end</b></a> () const</li>
|
|
<li class=fn>const_iterator <a href="#constEnd"><b>constEnd</b></a> () const</li>
|
|
<li class=fn>iterator <a href="#insert"><b>insert</b></a> ( iterator it, const T & x )</li>
|
|
<li class=fn>uint <a href="#remove-2"><b>remove</b></a> ( const T & x )</li>
|
|
<li class=fn>void <a href="#clear"><b>clear</b></a> ()</li>
|
|
<li class=fn>TQValueList<T> & <a href="#operator-lt-lt"><b>operator<<</b></a> ( const T & x )</li>
|
|
<li class=fn>size_type <a href="#size"><b>size</b></a> () const</li>
|
|
<li class=fn>bool <a href="#empty"><b>empty</b></a> () const</li>
|
|
<li class=fn>void <a href="#push_front"><b>push_front</b></a> ( const T & x )</li>
|
|
<li class=fn>void <a href="#push_back"><b>push_back</b></a> ( const T & x )</li>
|
|
<li class=fn>iterator <a href="#erase"><b>erase</b></a> ( iterator it )</li>
|
|
<li class=fn>iterator <a href="#erase-2"><b>erase</b></a> ( iterator first, iterator last )</li>
|
|
<li class=fn>reference <a href="#front"><b>front</b></a> ()</li>
|
|
<li class=fn>const_reference <a href="#front-2"><b>front</b></a> () const</li>
|
|
<li class=fn>reference <a href="#back"><b>back</b></a> ()</li>
|
|
<li class=fn>const_reference <a href="#back-2"><b>back</b></a> () const</li>
|
|
<li class=fn>void <a href="#pop_front"><b>pop_front</b></a> ()</li>
|
|
<li class=fn>void <a href="#pop_back"><b>pop_back</b></a> ()</li>
|
|
<li class=fn>void <a href="#insert-2"><b>insert</b></a> ( iterator pos, size_type n, const T & x )</li>
|
|
<li class=fn>TQValueList<T> <a href="#operator+"><b>operator+</b></a> ( const TQValueList<T> & l ) const</li>
|
|
<li class=fn>TQValueList<T> & <a href="#operator+-eq"><b>operator+=</b></a> ( const TQValueList<T> & l )</li>
|
|
<li class=fn>iterator <a href="#fromLast-2"><b>fromLast</b></a> ()</li>
|
|
<li class=fn>const_iterator <a href="#fromLast"><b>fromLast</b></a> () const</li>
|
|
<li class=fn>bool <a href="#isEmpty"><b>isEmpty</b></a> () const</li>
|
|
<li class=fn>iterator <a href="#append"><b>append</b></a> ( const T & x )</li>
|
|
<li class=fn>iterator <a href="#prepend"><b>prepend</b></a> ( const T & x )</li>
|
|
<li class=fn>iterator <a href="#remove"><b>remove</b></a> ( iterator it )</li>
|
|
<li class=fn>T & <a href="#first"><b>first</b></a> ()</li>
|
|
<li class=fn>const T & <a href="#first-2"><b>first</b></a> () const</li>
|
|
<li class=fn>T & <a href="#last"><b>last</b></a> ()</li>
|
|
<li class=fn>const T & <a href="#last-2"><b>last</b></a> () const</li>
|
|
<li class=fn>T & <a href="#operator[]-2"><b>operator[]</b></a> ( size_type i )</li>
|
|
<li class=fn>const T & <a href="#operator[]"><b>operator[]</b></a> ( size_type i ) const</li>
|
|
<li class=fn>iterator <a href="#at-2"><b>at</b></a> ( size_type i )</li>
|
|
<li class=fn>const_iterator <a href="#at"><b>at</b></a> ( size_type i ) const</li>
|
|
<li class=fn>iterator <a href="#find"><b>find</b></a> ( const T & x )</li>
|
|
<li class=fn>const_iterator <a href="#find-2"><b>find</b></a> ( const T & x ) const</li>
|
|
<li class=fn>iterator <a href="#find-3"><b>find</b></a> ( iterator it, const T & x )</li>
|
|
<li class=fn>const_iterator <a href="#find-4"><b>find</b></a> ( const_iterator it, const T & x ) const</li>
|
|
<li class=fn>int <a href="#findIndex"><b>findIndex</b></a> ( const T & x ) const</li>
|
|
<li class=fn>size_type <a href="#contains"><b>contains</b></a> ( const T & x ) const</li>
|
|
<li class=fn>size_type <a href="#count"><b>count</b></a> () const</li>
|
|
<li class=fn>TQValueList<T> & <a href="#operator+-eq-2"><b>operator+=</b></a> ( const T & x )</li>
|
|
<li class=fn>typedef TQValueListIterator<T> <a href="#Iterator"><b>Iterator</b></a></li>
|
|
<li class=fn>typedef TQValueListConstIterator<T> <a href="#ConstIterator"><b>ConstIterator</b></a></li>
|
|
</ul>
|
|
<h2>Related Functions</h2>
|
|
<ul>
|
|
<li class=fn>TQDataStream & <a href="#operator-gt-gt"><b>operator>></b></a> ( TQDataStream & s, TQValueList<T> & l )</li>
|
|
<li class=fn>TQDataStream & <a href="#operator-lt-lt-2"><b>operator<<</b></a> ( TQDataStream & s, const TQValueList<T> & l )</li>
|
|
</ul>
|
|
<hr><a name="details"></a><h2>Detailed Description</h2>
|
|
|
|
|
|
The TQValueList class is a value-based template class that
|
|
provides lists.
|
|
<p>
|
|
|
|
|
|
|
|
|
|
<p> TQValueList is a TQt implementation of an STL-like list container.
|
|
It can be used in your application if the standard <tt>list</tt> is not
|
|
available for your target platform(s). TQValueList is part of the
|
|
<a href="ntqtl.html">TQt Template Library</a>.
|
|
<p> TQValueList<T> defines a template instance to create a list of
|
|
values that all have the class T. Note that TQValueList does not
|
|
store pointers to the members of the list; it holds a copy of
|
|
every member. This is why these kinds of classes are called "value
|
|
based"; <a href="tqptrlist.html">TQPtrList</a> and <a href="tqdict.html">TQDict</a> are "pointer based".
|
|
<p> TQValueList contains and manages a collection of objects of type T
|
|
and provides iterators that allow the contained objects to be
|
|
addressed. TQValueList owns the contained items. For more relaxed
|
|
ownership semantics, see <a href="tqptrcollection.html">TQPtrCollection</a> and friends which are
|
|
pointer-based containers.
|
|
<p> Some classes cannot be used within a TQValueList, for example, all
|
|
classes derived from <a href="tqobject.html">TQObject</a> and thus all classes that implement
|
|
widgets. Only values can be used in a TQValueList. To qualify as a
|
|
value the class must provide:
|
|
<ul>
|
|
<li> a copy constructor;
|
|
<li> an assignment operator;
|
|
<li> a default constructor, i.e. a constructor that does not take any arguments.
|
|
</ul>
|
|
<p> Note that C++ defaults to field-by-field assignment operators and
|
|
copy constructors if no explicit version is supplied. In many
|
|
cases this is sufficient.
|
|
<p> In addition, some compilers (e.g. Sun CC) might require that the
|
|
class provides an equality operator (<a href="#operator-eq-eq">operator==</a>()).
|
|
<p> TQValueList's function naming is consistent with the other TQt
|
|
classes (e.g. <a href="#count">count</a>(), <a href="#isEmpty">isEmpty</a>()). TQValueList also provides extra
|
|
functions for compatibility with STL algorithms, such as <a href="#size">size</a>()
|
|
and <a href="#empty">empty</a>(). Programmers already familiar with the STL <tt>list</tt> may
|
|
prefer to use the STL-compatible functions.
|
|
<p> Example:
|
|
<pre>
|
|
class Employee
|
|
{
|
|
public:
|
|
Employee(): sn(0) {}
|
|
Employee( const <a href="tqstring.html">TQString</a>& forename, const <a href="tqstring.html">TQString</a>& surname, int salary )
|
|
: fn(forename), sn(surname), sal(salary)
|
|
{}
|
|
|
|
<a href="tqstring.html">TQString</a> forename() const { return fn; }
|
|
<a href="tqstring.html">TQString</a> surname() const { return sn; }
|
|
int salary() const { return sal; }
|
|
void setSalary( int salary ) { sal = salary; }
|
|
|
|
private:
|
|
<a href="tqstring.html">TQString</a> fn;
|
|
<a href="tqstring.html">TQString</a> sn;
|
|
int sal;
|
|
};
|
|
|
|
typedef TQValueList<Employee> EmployeeList;
|
|
EmployeeList list;
|
|
|
|
list.append( Employee("John", "Doe", 50000) );
|
|
list.append( Employee("Jane", "Williams", 80000) );
|
|
list.append( Employee("Tom", "Jones", 60000) );
|
|
|
|
Employee mary( "Mary", "Hawthorne", 90000 );
|
|
list.append( mary );
|
|
mary.setSalary( 100000 );
|
|
|
|
EmployeeList::<a href="#iterator">iterator</a> it;
|
|
for ( it = list.begin(); it != list.end(); ++it )
|
|
cout << (*it).surname().latin1() << ", " <<
|
|
(*it).forename().latin1() << " earns " <<
|
|
(*it).salary() << endl;
|
|
|
|
// Output:
|
|
// Doe, John earns 50000
|
|
// Williams, Jane earns 80000
|
|
// Hawthorne, Mary earns 90000
|
|
// Jones, Tom earns 60000
|
|
</pre>
|
|
|
|
<p> Notice that the latest changes to Mary's salary did not affect the
|
|
value in the list because the list created a copy of Mary's entry.
|
|
<p> There are several ways to find items in the list. The <a href="#begin">begin</a>() and
|
|
<a href="#end">end</a>() functions return iterators to the beginning and end of the
|
|
list. The advantage of getting an iterator is that you can move
|
|
forward or backward from this position by
|
|
incrementing/decrementing the iterator. The iterator returned by
|
|
end() points to the item which is one <em>past</em> the last item in the
|
|
container. The past-the-end iterator is still associated with the
|
|
list it belongs to, however it is <em>not</em> dereferenceable;
|
|
<a href="tqsize.html#operator*-4">operator*</a>() will not return a well-defined value. If the list is
|
|
<a href="#empty">empty</a>(), the iterator returned by begin() will equal the iterator
|
|
returned by end().
|
|
<p> Another way to find an item in the list is by using the <a href="ntqtl.html#qFind">tqFind()</a> algorithm. For example:
|
|
<p> <pre>
|
|
TQValueList<int> list;
|
|
...
|
|
TQValueList<int>::<a href="#iterator">iterator</a> it = tqFind( list.<a href="#begin">begin</a>(), list.<a href="#end">end</a>(), 3 );
|
|
if ( it != list.<a href="#end">end</a>() )
|
|
// it points to the found item
|
|
</pre>
|
|
|
|
<p> It is safe to have multiple iterators a the list at the same
|
|
time. If some member of the list is removed, only iterators
|
|
pointing to the removed member become invalid. Inserting into the
|
|
list does not invalidate any iterator. For convenience, the
|
|
function <a href="#last">last</a>() returns a reference to the last item in the list,
|
|
and <a href="#first">first</a>() returns a reference to the the first item. If the
|
|
list is empty(), both last() and first() have undefined behavior
|
|
(your application will crash or do unpredictable things). Use
|
|
last() and first() with caution, for example:
|
|
<p> <pre>
|
|
TQValueList<int> list;
|
|
list.<a href="#append">append</a>( 1 );
|
|
list.<a href="#append">append</a>( 2 );
|
|
list.<a href="#append">append</a>( 3 );
|
|
...
|
|
if ( !list.<a href="#empty">empty</a>() ) {
|
|
// OK, modify the first item
|
|
int& i = list.<a href="#first">first</a>();
|
|
i = 18;
|
|
}
|
|
...
|
|
TQValueList<double> dlist;
|
|
double d = dlist.<a href="#last">last</a>(); // undefined
|
|
</pre>
|
|
|
|
<p> Because TQValueList is value-based there is no need to be careful
|
|
about deleting items in the list. The list holds its own copies
|
|
and will free them if the corresponding member or the list itself
|
|
is deleted. You can force the list to free all of its items with
|
|
<a href="#clear">clear</a>().
|
|
<p> TQValueList is <a href="shclass.html#shared-implicitly">shared implicitly</a>, which means it can be copied in
|
|
constant time, i.e. O(1). If multiple TQValueList instances share
|
|
the same data and one needs to modify its contents, this modifying
|
|
instance makes a copy and modifies its private copy; therefore it
|
|
does not affect the other instances; this takes O(n) time. This is
|
|
often called "copy on write". If a TQValueList is being used in a
|
|
multi-threaded program, you must protect all access to the list.
|
|
See <a href="tqmutex.html">TQMutex</a>.
|
|
<p> There are several ways to insert items into the list. The
|
|
<a href="#prepend">prepend</a>() and <a href="#append">append</a>() functions insert items at the beginning and
|
|
the end of the list respectively. The <a href="#insert">insert</a>() function comes in
|
|
several flavors and can be used to add one or more items at
|
|
specific positions within the list.
|
|
<p> Items can also be removed from the list in several ways. There
|
|
are several variants of the <a href="#remove">remove</a>() function, which removes a
|
|
specific item from the list. The remove() function will find and
|
|
remove items according to a specific item value.
|
|
<p> Lists can also be sorted using the <a href="ntqtl.html">TQt Template
|
|
Library</a>. For example with qHeapSort():
|
|
<p> Example:
|
|
<pre>
|
|
TQValueList<int> list;
|
|
list.<a href="#append">append</a>( 5 );
|
|
list.<a href="#append">append</a>( 8 );
|
|
list.<a href="#append">append</a>( 3 );
|
|
list.<a href="#append">append</a>( 4 );
|
|
qHeapSort( list );
|
|
</pre>
|
|
|
|
<p> <p>See also <a href="tqvaluelistiterator.html">TQValueListIterator</a>, <a href="ntqtl.html">TQt Template Library Classes</a>, <a href="shared.html">Implicitly and Explicitly Shared Classes</a>, and <a href="tools.html">Non-GUI Classes</a>.
|
|
|
|
<hr><h2>Member Type Documentation</h2>
|
|
<h3 class=fn><a name="ConstIterator"></a>TQValueList::ConstIterator</h3>
|
|
|
|
<p> This iterator is an instantiation of <a href="tqvaluelistconstiterator.html">TQValueListConstIterator</a> for
|
|
the same type as this TQValueList. In other words, if you
|
|
instantiate TQValueList<int>, ConstIterator is a
|
|
TQValueListConstIterator<int>. Several member function use it, such
|
|
as <a href="#begin">TQValueList::begin</a>(), which returns an iterator pointing to the
|
|
first item in the list.
|
|
<p> Functionally, this is almost the same as Iterator. The only
|
|
difference is you cannot use ConstIterator for non-const
|
|
operations, and that the compiler can often generate better code
|
|
if you use ConstIterator.
|
|
<p> <p>See also <a href="tqvaluelistiterator.html">TQValueListIterator</a> and <a href="#Iterator">Iterator</a>.
|
|
|
|
<h3 class=fn><a name="Iterator"></a>TQValueList::Iterator</h3>
|
|
|
|
<p> This iterator is an instantiation of <a href="tqvaluelistiterator.html">TQValueListIterator</a> for the
|
|
same type as this TQValueList. In other words, if you instantiate
|
|
TQValueList<int>, Iterator is a TQValueListIterator<int>. Several
|
|
member function use it, such as <a href="#begin">TQValueList::begin</a>(), which returns
|
|
an iterator pointing to the first item in the list.
|
|
<p> Functionally, this is almost the same as ConstIterator. The only
|
|
difference is that you cannot use ConstIterator for non-const
|
|
operations, and that the compiler can often generate better code
|
|
if you use ConstIterator.
|
|
<p> <p>See also <a href="tqvaluelistiterator.html">TQValueListIterator</a> and <a href="#ConstIterator">ConstIterator</a>.
|
|
|
|
<h3 class=fn><a name="const_iterator"></a>TQValueList::const_iterator</h3>
|
|
The list's const iterator type, <a href="tqvaluelistconstiterator.html">TQValueListConstIterator</a>.
|
|
<h3 class=fn><a name="const_pointer"></a>TQValueList::const_pointer</h3>
|
|
The const pointer to T type.
|
|
<h3 class=fn><a name="const_reference"></a>TQValueList::const_reference</h3>
|
|
The const reference to T type.
|
|
<h3 class=fn><a name="iterator"></a>TQValueList::iterator</h3>
|
|
The list's iterator type, <a href="tqvaluelistiterator.html">TQValueListIterator</a>.
|
|
<h3 class=fn><a name="pointer"></a>TQValueList::pointer</h3>
|
|
The pointer to T type.
|
|
<h3 class=fn><a name="reference"></a>TQValueList::reference</h3>
|
|
The reference to T type.
|
|
<h3 class=fn><a name="size_type"></a>TQValueList::size_type</h3>
|
|
An unsigned integral type, used to represent various sizes.
|
|
<h3 class=fn><a name="value_type"></a>TQValueList::value_type</h3>
|
|
The type of the object stored in the list, T.
|
|
<hr><h2>Member Function Documentation</h2>
|
|
<h3 class=fn><a name="TQValueList"></a>TQValueList::TQValueList ()
|
|
</h3>
|
|
|
|
<p> Constructs an empty list.
|
|
|
|
<h3 class=fn><a name="TQValueList-2"></a>TQValueList::TQValueList ( const <a href="tqvaluelist.html">TQValueList</a><T> & l )
|
|
</h3>
|
|
|
|
<p> Constructs a copy of <em>l</em>.
|
|
<p> This operation takes O(1) time because TQValueList is <a href="shclass.html#implicitly-shared">implicitly shared</a>.
|
|
<p> The first modification to a list will take O(n) time.
|
|
|
|
<h3 class=fn><a name="TQValueList-3"></a>TQValueList::TQValueList ( const std::list<T> & l )
|
|
</h3>
|
|
|
|
<p> Contructs a copy of <em>l</em>.
|
|
<p> This constructor is provided for compatibility with STL
|
|
containers.
|
|
|
|
<h3 class=fn><a name="~TQValueList"></a>TQValueList::~TQValueList ()
|
|
</h3>
|
|
|
|
<p> Destroys the list. References to the values in the list and all
|
|
iterators of this list become invalidated. Note that it is
|
|
impossible for an iterator to check whether or not it is valid:
|
|
TQValueList is highly tuned for performance, not for error
|
|
checking.
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html#iterator">iterator</a> <a name="append"></a>TQValueList::append ( const T & x )
|
|
</h3>
|
|
|
|
<p> Inserts <em>x</em> at the end of the list.
|
|
<p> <p>See also <a href="#insert">insert</a>() and <a href="#prepend">prepend</a>().
|
|
|
|
<p>Examples: <a href="checklists-example.html#x434">checklists/checklists.cpp</a> and <a href="simple-font-demo-example.html#x2853">fonts/simple-tqfont-demo/viewer.cpp</a>.
|
|
<h3 class=fn><a href="tqvaluelist.html#const_iterator">const_iterator</a> <a name="at"></a>TQValueList::at ( <a href="tqvaluelist.html#size_type">size_type</a> i ) const
|
|
</h3>
|
|
|
|
<p> Returns an iterator pointing to the item at position <em>i</em> in the
|
|
list, or an undefined value if the index is out of range.
|
|
<p> <b>Warning:</b> This function uses a linear search and can be extremely
|
|
slow for large lists. TQValueList is not optimized for random item
|
|
access. If you need random access use a different container, such
|
|
as <a href="tqvaluevector.html">TQValueVector</a>.
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html#iterator">iterator</a> <a name="at-2"></a>TQValueList::at ( <a href="tqvaluelist.html#size_type">size_type</a> i )
|
|
</h3>
|
|
|
|
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Returns an iterator pointing to the item at position <em>i</em> in the
|
|
list, or an undefined value if the index is out of range.
|
|
<p>
|
|
<h3 class=fn><a href="tqvaluelist.html#reference">reference</a> <a name="back"></a>TQValueList::back ()
|
|
</h3>
|
|
|
|
<p> Returns a reference to the last item. If the list contains no last
|
|
item (i.e. <a href="#empty">empty</a>() returns TRUE), the return value is undefined.
|
|
<p> This function is provided for STL compatibility. It is equivalent
|
|
to <a href="#last">last</a>().
|
|
<p> <p>See also <a href="#front">front</a>().
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html#const_reference">const_reference</a> <a name="back-2"></a>TQValueList::back () const
|
|
</h3>
|
|
|
|
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p>
|
|
<h3 class=fn><a href="tqvaluelist.html#const_iterator">const_iterator</a> <a name="begin"></a>TQValueList::begin () const
|
|
</h3>
|
|
|
|
<p> Returns an iterator pointing to the first item in the list. This
|
|
iterator equals <a href="#end">end</a>() if the list is empty.
|
|
<p> <p>See also <a href="#first">first</a>(), <a href="#end">end</a>(), and <a href="#constBegin">constBegin</a>().
|
|
|
|
<p>Examples: <a href="canvas-example.html#x2952">canvas/canvas.cpp</a>, <a href="tutorial2-06.html#x2588">chart/canvasview.cpp</a>, <a href="tutorial2-03.html#x2554">chart/element.cpp</a>, <a href="checklists-example.html#x435">checklists/checklists.cpp</a>, <a href="sql.html#x2197">sql/overview/insert/main.cpp</a>, <a href="statistics-example.html#x2789">table/statistics/statistics.cpp</a>, and <a href="themes-example.html#x344">themes/themes.cpp</a>.
|
|
<h3 class=fn><a href="tqvaluelist.html#iterator">iterator</a> <a name="begin-2"></a>TQValueList::begin ()
|
|
</h3>
|
|
|
|
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Returns an iterator pointing to the first item in the list. This
|
|
iterator equals <a href="#end">end</a>() if the list is empty.
|
|
<p> <p>See also <a href="#first">first</a>() and <a href="#end">end</a>().
|
|
|
|
<h3 class=fn>void <a name="clear"></a>TQValueList::clear ()
|
|
</h3>
|
|
|
|
<p> Removes all items from the list.
|
|
<p> <p>See also <a href="#remove">remove</a>().
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html#const_iterator">const_iterator</a> <a name="constBegin"></a>TQValueList::constBegin () const
|
|
</h3>
|
|
|
|
<p> Returns an iterator pointing to the first item in the list. This
|
|
iterator equals <a href="#constEnd">constEnd</a>() if the list is empty.
|
|
<p> <p>See also <a href="#begin">begin</a>().
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html#const_iterator">const_iterator</a> <a name="constEnd"></a>TQValueList::constEnd () const
|
|
</h3>
|
|
|
|
<p> Returns an iterator pointing <em>past</em> the last item in the list.
|
|
This iterator equals <a href="#constBegin">constBegin</a>() if the list is empty.
|
|
<p> <p>See also <a href="#end">end</a>().
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html#size_type">size_type</a> <a name="contains"></a>TQValueList::contains ( const T & x ) const
|
|
</h3>
|
|
|
|
<p> Returns the number of occurrences of the value <em>x</em> in the list.
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html#size_type">size_type</a> <a name="count"></a>TQValueList::count () const
|
|
</h3>
|
|
|
|
<p> Returns the number of items in the list.
|
|
<p> <p>See also <a href="#isEmpty">isEmpty</a>().
|
|
|
|
<p>Examples: <a href="tutorial2-03.html#x2555">chart/element.cpp</a>, <a href="fileiconview-example.html#x874">fileiconview/tqfileiconview.cpp</a>, and <a href="statistics-example.html#x2790">table/statistics/statistics.cpp</a>.
|
|
<h3 class=fn>bool <a name="empty"></a>TQValueList::empty () const
|
|
</h3>
|
|
|
|
<p> Returns TRUE if the list contains no items; otherwise returns
|
|
FALSE.
|
|
<p> <p>See also <a href="#size">size</a>().
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html#iterator">iterator</a> <a name="end"></a>TQValueList::end ()
|
|
</h3>
|
|
|
|
<p> Returns an iterator pointing <em>past</em> the last item in the list.
|
|
This iterator equals <a href="#begin">begin</a>() if the list is empty.
|
|
<p> <p>See also <a href="#last">last</a>(), <a href="#begin">begin</a>(), and <a href="#constEnd">constEnd</a>().
|
|
|
|
<p>Examples: <a href="canvas-example.html#x2953">canvas/canvas.cpp</a>, <a href="tutorial2-06.html#x2589">chart/canvasview.cpp</a>, <a href="tutorial2-03.html#x2556">chart/element.cpp</a>, <a href="checklists-example.html#x436">checklists/checklists.cpp</a>, <a href="sql.html#x2198">sql/overview/insert/main.cpp</a>, <a href="statistics-example.html#x2791">table/statistics/statistics.cpp</a>, and <a href="themes-example.html#x345">themes/themes.cpp</a>.
|
|
<h3 class=fn><a href="tqvaluelist.html#const_iterator">const_iterator</a> <a name="end-2"></a>TQValueList::end () const
|
|
</h3>
|
|
|
|
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Returns an iterator pointing <em>past</em> the last item in the list.
|
|
This iterator equals <a href="#begin">begin</a>() if the list is empty.
|
|
<p> <p>See also <a href="#last">last</a>() and <a href="#begin">begin</a>().
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html#iterator">iterator</a> <a name="erase"></a>TQValueList::erase ( <a href="tqvaluelist.html#iterator">iterator</a> it )
|
|
</h3>
|
|
|
|
<p> Removes the item pointed to by <em>it</em> from the list. No iterators
|
|
other than <em>it</em> or other iterators pointing at the same item as
|
|
<em>it</em> are invalidated. Returns an iterator to the next item after
|
|
<em>it</em>, or <a href="#end">end</a>() if there is no such item.
|
|
<p> This function is provided for STL compatibility. It is equivalent
|
|
to <a href="#remove">remove</a>().
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html#iterator">iterator</a> <a name="erase-2"></a>TQValueList::erase ( <a href="tqvaluelist.html#iterator">iterator</a> first, <a href="tqvaluelist.html#iterator">iterator</a> last )
|
|
</h3>
|
|
|
|
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Deletes all items from <em>first</em> to <em>last</em> (not including <em>last</em>). No iterators are invalidated, except those pointing to the
|
|
removed items themselves. Returns <em>last</em>.
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html#iterator">iterator</a> <a name="find"></a>TQValueList::find ( const T & x )
|
|
</h3>
|
|
|
|
<p> Returns an iterator pointing to the first occurrence of <em>x</em> in
|
|
the list.
|
|
<p> Returns <a href="#end">end</a>() is no item matched.
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html#const_iterator">const_iterator</a> <a name="find-2"></a>TQValueList::find ( const T & x ) const
|
|
</h3>
|
|
|
|
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Returns an iterator pointing to the first occurrence of <em>x</em> in
|
|
the list.
|
|
<p> Returns <a href="#end">end</a>() if no item matched.
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html#iterator">iterator</a> <a name="find-3"></a>TQValueList::find ( <a href="tqvaluelist.html#iterator">iterator</a> it, const T & x )
|
|
</h3>
|
|
|
|
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Finds the first occurrence of <em>x</em> in the list starting at the
|
|
position given by <em>it</em>.
|
|
<p> Returns <a href="#end">end</a>() if no item matched.
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html#const_iterator">const_iterator</a> <a name="find-4"></a>TQValueList::find ( <a href="tqvaluelist.html#const_iterator">const_iterator</a> it, const T & x ) const
|
|
</h3>
|
|
|
|
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Finds the first occurrence of <em>x</em> in the list starting at the
|
|
position given by <em>it</em>.
|
|
<p> Returns <a href="#end">end</a>() if no item matched.
|
|
|
|
<h3 class=fn>int <a name="findIndex"></a>TQValueList::findIndex ( const T & x ) const
|
|
</h3>
|
|
|
|
<p> Returns the index of the first occurrence of the value <em>x</em>.
|
|
Returns -1 if no item matched.
|
|
|
|
<h3 class=fn>T & <a name="first"></a>TQValueList::first ()
|
|
</h3>
|
|
|
|
<p> Returns a reference to the first item. If the list contains no
|
|
first item (i.e. <a href="#isEmpty">isEmpty</a>() returns TRUE), the return value is
|
|
undefined.
|
|
<p> <p>See also <a href="#last">last</a>().
|
|
|
|
<p>Example: <a href="mail-example.html#x719">network/mail/smtp.cpp</a>.
|
|
<h3 class=fn>const T & <a name="first-2"></a>TQValueList::first () const
|
|
</h3>
|
|
|
|
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p>
|
|
<h3 class=fn><a href="tqvaluelist.html#const_iterator">const_iterator</a> <a name="fromLast"></a>TQValueList::fromLast () const
|
|
</h3>
|
|
|
|
<p> Returns an iterator to the last item in the list, or <a href="#end">end</a>() if
|
|
there is no last item.
|
|
<p> Use the end() function instead. For example:
|
|
<p> <pre>
|
|
TQValueList<int> l;
|
|
...
|
|
TQValueList<int>::<a href="#iterator">iterator</a> it = l.<a href="#end">end</a>();
|
|
--it;
|
|
if ( it != <a href="#end">end</a>() )
|
|
// ...
|
|
</pre>
|
|
|
|
<p>
|
|
<h3 class=fn><a href="tqvaluelist.html#iterator">iterator</a> <a name="fromLast-2"></a>TQValueList::fromLast ()
|
|
</h3>
|
|
|
|
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Returns an iterator to the last item in the list, or <a href="#end">end</a>() if
|
|
there is no last item.
|
|
<p> Use the end() function instead. For example:
|
|
<p> <pre>
|
|
TQValueList<int> l;
|
|
...
|
|
TQValueList<int>::<a href="#iterator">iterator</a> it = l.<a href="#end">end</a>();
|
|
--it;
|
|
if ( it != <a href="#end">end</a>() )
|
|
// ...
|
|
</pre>
|
|
|
|
<p>
|
|
<h3 class=fn><a href="tqvaluelist.html#reference">reference</a> <a name="front"></a>TQValueList::front ()
|
|
</h3>
|
|
|
|
<p> Returns a reference to the first item. If the list contains no
|
|
first item (i.e. <a href="#empty">empty</a>() returns TRUE), the return value is
|
|
undefined.
|
|
<p> This function is provided for STL compatibility. It is equivalent
|
|
to <a href="#first">first</a>().
|
|
<p> <p>See also <a href="#back">back</a>().
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html#const_reference">const_reference</a> <a name="front-2"></a>TQValueList::front () const
|
|
</h3>
|
|
|
|
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p>
|
|
<h3 class=fn><a href="tqvaluelist.html#iterator">iterator</a> <a name="insert"></a>TQValueList::insert ( <a href="tqvaluelist.html#iterator">iterator</a> it, const T & x )
|
|
</h3>
|
|
|
|
<p> Inserts the value <em>x</em> in front of the item pointed to by the
|
|
iterator, <em>it</em>.
|
|
<p> Returns an iterator pointing at the inserted item.
|
|
<p> <p>See also <a href="#append">append</a>() and <a href="#prepend">prepend</a>().
|
|
|
|
<p>Example: <a href="themes-example.html#x346">themes/themes.cpp</a>.
|
|
<h3 class=fn>void <a name="insert-2"></a>TQValueList::insert ( <a href="tqvaluelist.html#iterator">iterator</a> pos, <a href="tqvaluelist.html#size_type">size_type</a> n, const T & x )
|
|
</h3>
|
|
|
|
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Inserts <em>n</em> copies of <em>x</em> before position <em>pos</em>.
|
|
|
|
<h3 class=fn>bool <a name="isEmpty"></a>TQValueList::isEmpty () const
|
|
</h3>
|
|
|
|
<p> Returns TRUE if the list contains no items; otherwise returns
|
|
FALSE.
|
|
<p> <p>See also <a href="#count">count</a>().
|
|
|
|
<p>Examples: <a href="simple-font-demo-example.html#x2856">fonts/simple-tqfont-demo/viewer.cpp</a> and <a href="mail-example.html#x720">network/mail/smtp.cpp</a>.
|
|
<h3 class=fn>T & <a name="last"></a>TQValueList::last ()
|
|
</h3>
|
|
|
|
<p> Returns a reference to the last item. If the list contains no last
|
|
item (i.e. <a href="#empty">empty</a>() returns TRUE), the return value is undefined.
|
|
|
|
<h3 class=fn>const T & <a name="last-2"></a>TQValueList::last () const
|
|
</h3>
|
|
|
|
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p>
|
|
<h3 class=fn>bool <a name="operator!-eq"></a>TQValueList::operator!= ( const <a href="tqvaluelist.html">TQValueList</a><T> & l ) const
|
|
</h3>
|
|
|
|
<p> Compares both lists.
|
|
<p> Returns TRUE if this list and <em>l</em> are unequal; otherwise returns
|
|
FALSE.
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html">TQValueList</a><T> <a name="operator+"></a>TQValueList::operator+ ( const <a href="tqvaluelist.html">TQValueList</a><T> & l ) const
|
|
</h3>
|
|
|
|
<p> Creates a new list and fills it with the items of this list. Then
|
|
the items of <em>l</em> are appended. Returns the new list.
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html">TQValueList</a><T> & <a name="operator+-eq"></a>TQValueList::operator+= ( const <a href="tqvaluelist.html">TQValueList</a><T> & l )
|
|
</h3>
|
|
|
|
<p> Appends the items of <em>l</em> to this list. Returns a reference to
|
|
this list.
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html">TQValueList</a><T> & <a name="operator+-eq-2"></a>TQValueList::operator+= ( const T & x )
|
|
</h3>
|
|
|
|
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Appends the value <em>x</em> to the list. Returns a reference to the
|
|
list.
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html">TQValueList</a><T> & <a name="operator-lt-lt"></a>TQValueList::operator<< ( const T & x )
|
|
</h3>
|
|
|
|
<p> Adds the value <em>x</em> to the end of the list.
|
|
<p> Returns a reference to the list.
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html">TQValueList</a><T> & <a name="operator-eq"></a>TQValueList::operator= ( const <a href="tqvaluelist.html">TQValueList</a><T> & l )
|
|
</h3>
|
|
|
|
<p> Assigns <em>l</em> to this list and returns a reference to this list.
|
|
<p> All iterators of the current list become invalidated by this
|
|
operation. The cost of such an assignment is O(1) since TQValueList
|
|
is <a href="shclass.html#implicitly-shared">implicitly shared</a>.
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html">TQValueList</a><T> & <a name="operator-eq-2"></a>TQValueList::operator= ( const std::list<T> & l )
|
|
</h3>
|
|
|
|
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Assigns the contents of <em>l</em> to the list.
|
|
<p> All iterators of the current list become invalidated by this
|
|
operation.
|
|
|
|
<h3 class=fn>bool <a name="operator-eq-eq"></a>TQValueList::operator== ( const <a href="tqvaluelist.html">TQValueList</a><T> & l ) const
|
|
</h3>
|
|
|
|
<p> Compares both lists.
|
|
<p> Returns TRUE if this list and <em>l</em> are equal; otherwise returns
|
|
FALSE.
|
|
|
|
<h3 class=fn>bool <a name="operator-eq-eq-2"></a>TQValueList::operator== ( const std::list<T> & l ) const
|
|
</h3>
|
|
|
|
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Returns TRUE if this list and <em>l</em> are equal; otherwise returns
|
|
FALSE.
|
|
<p> This operator is provided for compatibility with STL containers.
|
|
|
|
<h3 class=fn>const T & <a name="operator[]"></a>TQValueList::operator[] ( <a href="tqvaluelist.html#size_type">size_type</a> i ) const
|
|
</h3>
|
|
|
|
<p> Returns a const reference to the item with index <em>i</em> in the list.
|
|
It is up to you to check whether this item really exists. You can
|
|
do that easily with the <a href="#count">count</a>() function. However this operator
|
|
does not check whether <em>i</em> is in range and will deliver undefined
|
|
results if it does not exist.
|
|
<p> <b>Warning:</b> This function uses a linear search and can be extremely
|
|
slow for large lists. TQValueList is not optimized for random item
|
|
access. If you need random access use a different container, such
|
|
as <a href="tqvaluevector.html">TQValueVector</a>.
|
|
|
|
<h3 class=fn>T & <a name="operator[]-2"></a>TQValueList::operator[] ( <a href="tqvaluelist.html#size_type">size_type</a> i )
|
|
</h3>
|
|
|
|
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Returns a non-const reference to the item with index <em>i</em>.
|
|
|
|
<h3 class=fn>void <a name="pop_back"></a>TQValueList::pop_back ()
|
|
</h3>
|
|
|
|
<p> Removes the last item. If there is no last item, this operation is
|
|
undefined.
|
|
<p> This function is provided for STL compatibility.
|
|
|
|
<h3 class=fn>void <a name="pop_front"></a>TQValueList::pop_front ()
|
|
</h3>
|
|
|
|
<p> Removes the first item. If there is no first item, this operation
|
|
is undefined.
|
|
<p> This function is provided for STL compatibility.
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html#iterator">iterator</a> <a name="prepend"></a>TQValueList::prepend ( const T & x )
|
|
</h3>
|
|
|
|
<p> Inserts <em>x</em> at the beginning of the list.
|
|
<p> <p>See also <a href="#insert">insert</a>() and <a href="#append">append</a>().
|
|
|
|
<h3 class=fn>void <a name="push_back"></a>TQValueList::push_back ( const T & x )
|
|
</h3>
|
|
|
|
<p> Inserts <em>x</em> at the end of the list.
|
|
<p> This function is provided for STL compatibility. It is equivalent
|
|
to <a href="#append">append</a>().
|
|
|
|
<h3 class=fn>void <a name="push_front"></a>TQValueList::push_front ( const T & x )
|
|
</h3>
|
|
|
|
<p> Inserts <em>x</em> at the beginning of the list.
|
|
<p> This function is provided for STL compatibility. It is equivalent
|
|
to <a href="#prepend">prepend</a>().
|
|
|
|
<p>Example: <a href="toplevel-example.html#x2534">toplevel/options.ui.h</a>.
|
|
<h3 class=fn><a href="tqvaluelist.html#iterator">iterator</a> <a name="remove"></a>TQValueList::remove ( <a href="tqvaluelist.html#iterator">iterator</a> it )
|
|
</h3>
|
|
|
|
<p> Removes the item pointed to by <em>it</em> from the list. No iterators
|
|
other than <em>it</em> or other iterators pointing at the same item as
|
|
<em>it</em> are invalidated. Returns an iterator to the next item after
|
|
<em>it</em>, or <a href="#end">end</a>() if there is no such item.
|
|
<p> <p>See also <a href="#clear">clear</a>().
|
|
|
|
<h3 class=fn>uint <a name="remove-2"></a>TQValueList::remove ( const T & x )
|
|
</h3>
|
|
|
|
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p> Removes all items that have value <em>x</em> and returns the number of
|
|
removed items.
|
|
|
|
<h3 class=fn><a href="tqvaluelist.html#size_type">size_type</a> <a name="size"></a>TQValueList::size () const
|
|
</h3>
|
|
|
|
<p> Returns the number of items in the list.
|
|
<p> This function is provided for STL compatibility. It is equivalent
|
|
to <a href="#count">count</a>().
|
|
<p> <p>See also <a href="#empty">empty</a>().
|
|
|
|
<hr><h2>Related Functions</h2>
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-lt-lt-2"></a>operator<< ( <a href="tqdatastream.html">TQDataStream</a> & s, const <a href="tqvaluelist.html">TQValueList</a><T> & l )
|
|
</h3>
|
|
|
|
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
<p>
|
|
<p> Writes a list, <em>l</em>, to the stream <em>s</em>. The type T stored in the
|
|
list must implement the streaming operator.
|
|
|
|
<h3 class=fn><a href="tqdatastream.html">TQDataStream</a> & <a name="operator-gt-gt"></a>operator>> ( <a href="tqdatastream.html">TQDataStream</a> & s, <a href="tqvaluelist.html">TQValueList</a><T> & l )
|
|
</h3>
|
|
|
|
<p>
|
|
<p> Reads a list, <em>l</em>, from the stream <em>s</em>. The type T stored in the
|
|
list must implement the streaming operator.
|
|
|
|
<!-- eof -->
|
|
<hr><p>
|
|
This file is part of the <a href="index.html">TQt toolkit</a>.
|
|
Copyright © 1995-2007
|
|
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
|
<table width=100% cellspacing=0 border=0><tr>
|
|
<td>Copyright © 2007
|
|
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
|
<td align=right><div align=right>TQt 3.3.8</div>
|
|
</table></div></address></body>
|
|
</html>
|