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.
tqt3/doc/html/tqvaluestack.html

159 lines
7.1 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/tqvaluestack.doc:41 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQValueStack 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&nbsp;Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped&nbsp;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>TQValueStack Class Reference</h1>
<p>The TQValueStack class is a value-based template class that provides a stack.
<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 &lt;<a href="tqvaluestack-h.html">tqvaluestack.h</a>&gt;</tt>
<p>Inherits <a href="tqvaluelist.html">TQValueList</a>&lt;T&gt;.
<p><a href="tqvaluestack-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQValueStack"><b>TQValueStack</b></a> ()</li>
<li class=fn><a href="#~TQValueStack"><b>~TQValueStack</b></a> ()</li>
<li class=fn>void <a href="#push"><b>push</b></a> ( const&nbsp;T&nbsp;&amp;&nbsp;d )</li>
<li class=fn>T <a href="#pop"><b>pop</b></a> ()</li>
<li class=fn>T &amp; <a href="#top"><b>top</b></a> ()</li>
<li class=fn>const T &amp; <a href="#top-2"><b>top</b></a> () const</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The TQValueStack class is a value-based template class that provides a stack.
<p>
<p> Define a template instance TQValueStack&lt;X&gt; to create a stack of
values that all have the class X. TQValueStack is part of the <a href="tqtl.html">TQt Template Library</a>.
<p> Note that TQValueStack does not store pointers to the members of
the stack; it holds a copy of every member. That is why these
kinds of classes are called "value based"; <a href="tqptrstack.html">TQPtrStack</a>, <a href="tqptrlist.html">TQPtrList</a>,
<a href="tqdict.html">TQDict</a>, etc., are "pointer based".
<p> A stack is a last in, first out (LIFO) structure. Items are added
to the top of the stack with <a href="#push">push</a>() and retrieved from the top
with <a href="#pop">pop</a>(). The <a href="#top">top</a>() function provides access to the topmost item
without removing it.
<p> Example:
<pre>
TQValueStack&lt;int&gt; stack;
stack.<a href="#push">push</a>( 1 );
stack.<a href="#push">push</a>( 2 );
stack.<a href="#push">push</a>( 3 );
while ( ! stack.<a href="tqvaluelist.html#isEmpty">isEmpty</a>() )
cout &lt;&lt; "Item: " &lt;&lt; stack.<a href="#pop">pop</a>() &lt;&lt; endl;
// Output:
// Item: 3
// Item: 2
// Item: 1
</pre>
<p> TQValueStack is a specialized <a href="tqvaluelist.html">TQValueList</a> provided for convenience.
All of TQValueList's functionality also applies to <a href="tqptrstack.html">TQPtrStack</a>, for
example the facility to iterate over all elements using
TQValueStack<T>::Iterator. See <a href="tqvaluelistiterator.html">TQValueListIterator</a> for further
details.
<p> Some classes cannot be used within a TQValueStack, for example
everything derived from <a href="tqobject.html">TQObject</a> and thus all classes that
implement widgets. Only values can be used in a TQValueStack. 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>See also <a href="tqtl.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 Function Documentation</h2>
<h3 class=fn><a name="TQValueStack"></a>TQValueStack::TQValueStack ()
</h3>
<p> Constructs an empty stack.
<h3 class=fn><a name="~TQValueStack"></a>TQValueStack::~TQValueStack ()
</h3>
<p> Destroys the stack. References to the values in the stack and all
iterators of this stack become invalidated. Because TQValueStack is
highly tuned for performance, you won't see warnings if you use
invalid iterators because it is impossible for an iterator to
check whether or not it is valid.
<h3 class=fn>T <a name="pop"></a>TQValueStack::pop ()
</h3>
<p> Removes the top item from the stack and returns it.
<p> <p>See also <a href="#top">top</a>() and <a href="#push">push</a>().
<h3 class=fn>void <a name="push"></a>TQValueStack::push ( const&nbsp;T&nbsp;&amp;&nbsp;d )
</h3>
<p> Adds element, <em>d</em>, to the top of the stack. Last in, first out.
<p> This function is equivalent to <a href="tqvaluelist.html#append">append</a>().
<p> <p>See also <a href="#pop">pop</a>() and <a href="#top">top</a>().
<h3 class=fn>T &amp; <a name="top"></a>TQValueStack::top ()
</h3>
<p> Returns a reference to the top item of the stack or the item
referenced by <a href="tqvaluelist.html#end">end</a>() if no such item exists. Note that you must not
change the value the end() iterator points to.
<p> This function is equivalent to <a href="tqvaluelist.html#last">last</a>().
<p> <p>See also <a href="#pop">pop</a>(), <a href="#push">push</a>(), and <a href="tqvaluelist.html#fromLast">TQValueList::fromLast</a>().
<h3 class=fn>const T &amp; <a name="top-2"></a>TQValueStack::top () const
</h3>
<p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns a reference to the top item of the stack or the item
referenced by <a href="tqvaluelist.html#end">end</a>() if no such item exists.
<p> This function is equivalent to <a href="tqvaluelist.html#last">last</a>().
<p> <p>See also <a href="#pop">pop</a>(), <a href="#push">push</a>(), and <a href="tqvaluelist.html#fromLast">TQValueList::fromLast</a>().
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">TQt toolkit</a>.
Copyright &copy; 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 &copy; 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>