?? qptrlist.html
字號:
<h3 class=fn><a name="QPtrList-2"></a>QPtrList::QPtrList ( const <a href="qptrlist.html">QPtrList</a><type> & list )
</h3>
構造一個<em>list</em>的復制。
<p> <em>list</em>的每一個項都<a href="#append">被添加</a>到這個列表中。只有指針被復制(淺復制)。
<h3 class=fn><a name="~QPtrList"></a>QPtrList::~QPtrList ()
</h3>
移除列表中的所有項并且銷毀這個列表。
<p> 訪問這個列表的所有列表迭代器都會被重置。
<p> <p>也可以參考<a href="qptrcollection.html#setAutoDelete">setAutoDelete</a>()。
<h3 class=fn>void <a name="append"></a>QPtrList::append ( const type * item )
</h3>
在列表的最后插入<em>item</em>。
<p> 被插入的項變為當前列表項。這和<tt>insert( count(), item )</tt>是相同的。
<p> <em>item</em>必須不是一個空指針。
<p> <p>也可以參考<a href="#insert">insert</a>()、<a href="#current">current</a>()和<a href="#prepend">prepend</a>()。
<p>實例:<a href="customlayout-example.html#x1371">customlayout/border.cpp</a>、<a href="customlayout-example.html#x1389">customlayout/card.cpp</a>、<a href="customlayout-example.html#x1348">customlayout/flow.cpp</a>、<a href="grapher-nsplugin-example.html#x2778">grapher/grapher.cpp</a>、<a href="listviews-example.html#x347">listviews/listviews.cpp</a>、<a href="listviews-example.html#x318">listviews/listviews.h</a>和<a href="qwerty-example.html#x385">qwerty/qwerty.cpp</a>。
<h3 class=fn>type * <a name="at"></a>QPtrList::at ( uint index )
</h3>
返回一個在列表<em>index</em>位置的項的指針,如果索引超出范圍,返回空。
<p> 如果<em>index</em>有效,設置這個項為當前列表項。有效范圍是<tt>0……(count() - 1)</tt>。
<p> 這個函數是非常有效的。它從第一項、最后一項或當前項中最接近<em>index</em>的開始掃描。
<p> <p>也可以參考<a href="#current">current</a>()。
<p>實例:<a href="customlayout-example.html#x1372">customlayout/border.cpp</a>、<a href="customlayout-example.html#x1390">customlayout/card.cpp</a>、<a href="customlayout-example.html#x1349">customlayout/flow.cpp</a>、<a href="dirview-example.html#x1737">dirview/dirview.cpp</a>、<a href="fileiconview-example.html#x863">fileiconview/qfileiconview.cpp</a>、<a href="mdi-example.html#x2035">mdi/application.cpp</a>和<a href="qwerty-example.html#x386">qwerty/qwerty.cpp</a>。
<h3 class=fn>int <a name="at-2"></a>QPtrList::at () const
</h3>
這是一個重載成員函數,提供了方便。它的行為基本上和上面的函數相同。
<p> 返回當前列表項的索引。如果當前項為空,返回值為-1。
<p>也可以參考<a href="#current">current</a>()。
<h3 class=fn>bool <a name="autoDelete"></a>QPtrCollection::autoDelete () const
</h3>
<p> 返回自動刪除選項的設置。默認為假。
<p> <p>也可以參考<a href="qptrcollection.html#setAutoDelete">setAutoDelete</a>()。
<h3 class=fn>void <a name="clear"></a>QPtrList::clear ()<tt> [虛]</tt>
</h3>
移除列表中所有項。
<p> 如果<a href="qptrcollection.html#setAutoDelete">自動刪除</a>生效,被移除的項目將被刪除。
<p> 所有訪問這個列表的列表迭代器都將被重置。
<p> <p>也可以參考<a href="#remove">remove</a>()、<a href="#take">take</a>()和<a href="qptrcollection.html#setAutoDelete">setAutoDelete</a>()。
<p>從<a href="qptrcollection.html#clear">QPtrCollection</a>中重新實現。
<h3 class=fn>int <a name="compareItems"></a>QPtrList::compareItems ( <a href="qptrcollection.html#Item">QPtrCollection::Item</a> item1, <a href="qptrcollection.html#Item">QPtrCollection::Item</a> item2 )<tt> [虛 保護]</tt>
</h3>
<p> 這個虛函數比較兩個列表項。
<p> 返回:
<ul>
<li> 如果<em>item1</em>==<em>item2</em>,返回0
<li> 如果<em>item1</em>!=<em>item2</em>,返回非0
</ul>
<p> 這個函數返回<em>int</em>而不是<em>bool</em>,這樣可以重新實現返回三個值并且使用它來排序:
<p> <ul>
<li> 如果<em>item1</em> == <em>item2</em>,返回0
<li> 如果<em>item1</em>><em>item2</em>,返回>0(正整數)
<li> 如果<em>item1</em><<em>item2</em>,返回<0(負整數)
</ul>
<p> <a href="#inSort">inSort</a>()需要<a href="#compareItems">compareItems</a>()像這里所描述的這樣來被實現。
<p> 這個函數不應該修改列表,因為一些常量函數調用compareItems()。
<p> 默認實現是比較指針。
<h3 class=fn>uint <a name="contains"></a>QPtrList::contains ( const type * item ) const
</h3>
計算并且返回<em>item</em>在列表中出現的次數。
<p> 當在列表中搜索<em>item</em>時,<a href="#compareItems">compareItems</a>()函數被調用。如果compareItems()沒有被重新實現,調用<a href="#containsRef">containsRef</a>()是更有效率的。
<p> 這個函數不影響當前列表項。
<p> <p>也可以參考<a href="#containsRef">containsRef</a>()和<a href="#compareItems">compareItems</a>()。
<h3 class=fn>uint <a name="containsRef"></a>QPtrList::containsRef ( const type * item ) const
</h3>
計算并且返回<em>item</em>在列表中出現的次數。
<p> 調用這個函數比<a href="#contains">contains</a>()快多了,因為contains()使用<a href="#compareItems">compareItems</a>()來用<em>item</em>與列表中的每一個項進行比較。這個函數只比較指針。
<p> 這個函數不影響當前列表項。
<p> <p>也可以參考<a href="#contains">contains</a>()。
<h3 class=fn>uint <a name="count"></a>QPtrList::count () const<tt> [虛]</tt>
</h3>
返回列表中項的數量。
<p>也可以參考<a href="#isEmpty">isEmpty</a>()。
<p>實例:<a href="customlayout-example.html#x1373">customlayout/border.cpp</a>、<a href="customlayout-example.html#x1391">customlayout/card.cpp</a>、<a href="customlayout-example.html#x1350">customlayout/flow.cpp</a>、<a href="fileiconview-example.html#x864">fileiconview/qfileiconview.cpp</a>、<a href="grapher-nsplugin-example.html#x2779">grapher/grapher.cpp</a>、<a href="mdi-example.html#x2036">mdi/application.cpp</a>和<a href="qwerty-example.html#x387">qwerty/qwerty.cpp</a>。
<p>從<a href="qptrcollection.html#count">QPtrCollection</a>中重新實現的。
<h3 class=fn>type * <a name="current"></a>QPtrList::current () const
</h3>
返回一個指向當前列表項的指針。當前列表項可能為空(意味著當前索引為-1)。
<p>也可以參考<a href="#at">at</a>()。
<h3 class=fn>QLNode * <a name="currentNode"></a>QPtrList::currentNode () const
</h3>
返回指向當前列表節點的指針。
<p> 節點可以被保存并且稍后使用<a href="#removeNode">removeNode</a>()移除。這樣做的優點是可以直接移除這個項,而不用搜索列表。
<p> <b>警告:</b>不要調用這個函數,除非你是專家。
<p> <p>也可以參考<a href="#removeNode">removeNode</a>()、<a href="#takeNode">takeNode</a>()和<a href="#current">current</a>()。
<h3 class=fn>int <a name="find"></a>QPtrList::find ( const type * item )
</h3>
找到<em>item</em>在列表中第一次出現的位置。
<p> 如果這個項被找到,列表會設置當前項指向找到的項,并且返回這個項的索引。如果沒有被找到,列表設置當前項為空,當前索引為-1,并且返回-1。
<p> 當在列表中搜索這個項時,<a href="#compareItems">compareItems</a>()函數被調用。如果compareItems()沒有被重新實現,調用<a href="#findRef">findRef</a>()是更有效率的。
<p> <p>也可以參考<a href="#findNext">findNext</a>()、<a href="#findRef">findRef</a>()、<a href="#compareItems">compareItems</a>()和<a href="#current">current</a>()。
<h3 class=fn>int <a name="findNext"></a>QPtrList::findNext ( const type * item )
</h3>
從當前列表項,找到<em>item</em>在列表中下一次出現的位置。
<p> 如果這個項被找到,列表會設置當前項指向找到的項,并且返回這個項的索引。如果沒有被找到,列表設置當前項為空,當前索引為-1,并且返回-1。
<p> 當在列表中搜索這個項時,<a href="#compareItems">compareItems</a>()函數被調用。如果compareItems()沒有被重新實現,調用<a href="#findNextRef">findNextRef</a>()是更有效率的。
<p> <p>也可以參考<a href="#find">find</a>()、<a href="#findNextRef">findNextRef</a>()、<a href="#compareItems">compareItems</a>()和<a href="#current">current</a>()。
<h3 class=fn>int <a name="findNextRef"></a>QPtrList::findNextRef ( const type * item )
</h3>
從當前列表項,找到<em>item</em>在列表中下一次出現的位置。
<p> 如果這個項被找到,列表會設置當前項指向找到的項,并且返回這個項的索引。如果沒有被找到,列表設置當前項為空,當前索引為-1,并且返回-1。
<p> 調用這個函數比<a href="#findNext">findNext</a>()快得多,因為findNext()是使用<a href="#compareItems">compareItems</a>()來用<em>item</em>與列表中的每一個項進行比較。這個函數只比較指針。
<p> <p>也可以參考<a href="#findRef">findRef</a>()、<a href="#findNext">findNext</a>()和<a href="#current">current</a>()。
<h3 class=fn>int <a name="findRef"></a>QPtrList::findRef ( const type * item )
</h3>
找到<em>item</em>在列表中第一次出現的位置。
<p> 如果這個項被找到,列表會設置當前項指向找到的項,并且返回這個項的索引。如果沒有被找到,列表設置當前項為空,當前索引為-1,并且返回-1。
<p> 調用這個函數比<a href="#find">find</a>()快得多,因為find()是使用<a href="#compareItems">compareItems</a>()來用<em>item</em>與列表中的每一個項進行比較。這個函數只比較指針。
<p> <p>也可以參考<a href="#findNextRef">findNextRef</a>()、<a href="#find">find</a>()和<a href="#current">current</a>()。
<h3 class=fn>type * <a name="first"></a>QPtrList::first ()
</h3>
返回指向列表中第一個項的指針并且使它成為當前列表項,或者如果列表為空當前項就為空。
<p>也可以參考<a href="#getFirst">getFirst</a>()、<a href="#last">last</a>()、<a href="#next">next</a>()、<a href="#prev">prev</a>()和<a href="#current">current</a>()。
<p>實例:<a href="grapher-nsplugin-example.html#x2780">grapher/grapher.cpp</a>、<a href="listviews-example.html#x319">listviews/listviews.h</a>和<a href="showimg-example.html#x1281">showimg/showimg.cpp</a>。
<h3 class=fn>type * <a name="getFirst"></a>QPtrList::getFirst () const
</h3>
返回指向列表中第一個項的指針,如果列表為空返回空。
<p> 這個函數不影響當前列表項。
<p> <p>也可以參考<a href="#first">first</a>()和<a href="#getLast">getLast</a>()。
<h3 class=fn>type * <a name="getLast"></a>QPtrList::getLast () const
</h3>
Returns a pointer to the last item in the list, or null if the
list is empty.
返回指向列表中最后一個項的指針,如果列表為空返回空。
<p> 這個函數不影響當前列表項。
<p> <p>也可以參考<a href="#last">last</a>()和<a href="#getFirst">getFirst</a>()。
<h3 class=fn>void <a name="inSort"></a>QPtrList::inSort ( const type * item )
</h3>
把<em>item</em>插入到列表中它被排序的位置。
<p> 排序依靠的是虛函數<a href="#compareItems">compareItems</a>()。為了維護這個派遜,所有的項都必須使用<a href="#inSort">inSort</a>()來插入。
<p> 被插入的項變為當前項。
<p> <em>item</em>必須不能是一個空指針。
<p> 請注意inSort()很慢。如果你想先向列表插入很多項,插入完之后再排序,你應該使用<a href="#sort">sort</a>()。inSort()進行了O(n)次比較。這就意味著插入n個項到你的列表需要比較O(n^2)次,而sort()做同樣的工作只需要O(n*log n)次。所以只有在你有一個預先排好序的列表并且想向其中插入少量的項時,再使用inSort()。
<p> <p>也可以參考<a href="#insert">insert</a>()、<a href="#compareItems">compareItems</a>()、<a href="#current">current</a>()和<a href="#sort">sort</a>()。
<h3 class=fn>bool <a name="insert"></a>QPtrList::insert ( uint index, const type * item )
</h3>
插入<em>item</em>到列表的<em>index</em>位置。
<p> 如果成功返回真,或者如果<em>index</em>超出范圍返回假。有效的范圍是從0到<a href="#count">count</a>()(包括count())。如果<em>index</em>==count(),項就被添加。
<p> 被插入的項變為當前項。
<p> <em>item</em>必須不能是一個空指針。
<p> <p>也可以參考<a href="#append">append</a>()和<a href="#current">current</a>()。
<h3 class=fn>bool <a name="isEmpty"></a>QPtrList::isEmpty () const
</h3>
如果列表是空的,返回真,否則返回假。
<p> <p>也可以參考<a href="#count">count</a>()。
<h3 class=fn>type * <a name="last"></a>QPtrList::last ()
</h3>
返回指向列表最后一項的指針,并且把這一項變為當前列表項,如果列表為空,當前列表項為空。
<p>也可以參考<a href="#getLast">getLast</a>()、<a href="#first">first</a>()、<a href="#next">next</a>()、<a href="#prev">prev</a>()和<a href="#current">current</a>()。
<h3 class=fn>type * <a name="next"></a>QPtrList::next ()
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -