📄 classpabstractsortedlist.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>PAbstractSortedList class Reference</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.2.18 --><center><a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> </center><hr><h1>PAbstractSortedList Class Reference</h1><code>#include <<a class="el" href="lists_8h-source.html">lists.h</a>></code><p><p>Inheritance diagram for PAbstractSortedList:<p><center><img src="classPAbstractSortedList.png" usemap="#PAbstractSortedList_map" border="0" alt=""></center><map name="PAbstractSortedList_map"><area href="classPCollection.html" alt="PCollection" shape="rect" coords="0,112,123,136"><area href="classPContainer.html" alt="PContainer" shape="rect" coords="0,56,123,80"><area href="classPObject.html" alt="PObject" shape="rect" coords="0,0,123,24"></map><a href="classPAbstractSortedList-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0><tr><td></td></tr><tr><td colspan=2><br><h2>Public Methods</h2></td></tr><tr><td colspan="2"><div class="groupHeader">Construction</div></td></tr><tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#z177_0">PAbstractSortedList</a> ()</td></tr><tr><td colspan="2"><div class="groupHeader">Overrides from class PObject</div></td></tr><tr><td nowrap align=right valign=top>virtual <a class="el" href="classPObject.html#z199_0">Comparison</a> </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#z179_0">Compare</a> (const <a class="el" href="classPObject.html">PObject</a> &obj) const</td></tr><tr><td colspan="2"><div class="groupHeader">Overrides from class PContainer</div></td></tr><tr><td nowrap align=right valign=top>virtual BOOL </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#z181_0">SetSize</a> (PINDEX newSize)</td></tr><tr><td colspan="2"><div class="groupHeader">Overrides from class PCollection</div></td></tr><tr><td nowrap align=right valign=top>virtual PINDEX </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#z183_0">Append</a> (<a class="el" href="classPObject.html">PObject</a> *obj)</td></tr><tr><td nowrap align=right valign=top>virtual PINDEX </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#z183_1">Insert</a> (const <a class="el" href="classPObject.html">PObject</a> &before, <a class="el" href="classPObject.html">PObject</a> *obj)</td></tr><tr><td nowrap align=right valign=top>virtual PINDEX </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#z183_2">InsertAt</a> (PINDEX index, <a class="el" href="classPObject.html">PObject</a> *obj)</td></tr><tr><td nowrap align=right valign=top>virtual BOOL </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#z183_3">Remove</a> (const <a class="el" href="classPObject.html">PObject</a> *obj)</td></tr><tr><td nowrap align=right valign=top>virtual <a class="el" href="classPObject.html">PObject</a> * </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#z183_4">RemoveAt</a> (PINDEX index)</td></tr><tr><td nowrap align=right valign=top>virtual void </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#z183_5">RemoveAll</a> ()</td></tr><tr><td nowrap align=right valign=top>virtual BOOL </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#z183_6">SetAt</a> (PINDEX index, <a class="el" href="classPObject.html">PObject</a> *val)</td></tr><tr><td nowrap align=right valign=top>virtual <a class="el" href="classPObject.html">PObject</a> * </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#z183_7">GetAt</a> (PINDEX index) const</td></tr><tr><td nowrap align=right valign=top>virtual PINDEX </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#z183_8">GetObjectsIndex</a> (const <a class="el" href="classPObject.html">PObject</a> *obj) const</td></tr><tr><td nowrap align=right valign=top>virtual PINDEX </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#z183_9">GetValuesIndex</a> (const <a class="el" href="classPObject.html">PObject</a> &obj) const</td></tr><tr><td colspan=2><br><h2>Protected Methods</h2></td></tr><tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#b0">RemoveElement</a> (<a class="el" href="structPAbstractSortedList_1_1Element.html">Element</a> *node)</td></tr><tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#b1">LeftRotate</a> (<a class="el" href="structPAbstractSortedList_1_1Element.html">Element</a> *node)</td></tr><tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#b2">RightRotate</a> (<a class="el" href="structPAbstractSortedList_1_1Element.html">Element</a> *node)</td></tr><tr><td nowrap align=right valign=top>void </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#b3">DeleteSubTrees</a> (<a class="el" href="structPAbstractSortedList_1_1Element.html">Element</a> *node, BOOL deleteObject)</td></tr><tr><td nowrap align=right valign=top><a class="el" href="structPAbstractSortedList_1_1Element.html">Element</a> * </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#b4">Successor</a> (const <a class="el" href="structPAbstractSortedList_1_1Element.html">Element</a> *node) const</td></tr><tr><td nowrap align=right valign=top><a class="el" href="structPAbstractSortedList_1_1Element.html">Element</a> * </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#b5">Predecessor</a> (const <a class="el" href="structPAbstractSortedList_1_1Element.html">Element</a> *node) const</td></tr><tr><td nowrap align=right valign=top><a class="el" href="structPAbstractSortedList_1_1Element.html">Element</a> * </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#b6">OrderSelect</a> (<a class="el" href="structPAbstractSortedList_1_1Element.html">Element</a> *node, PINDEX index) const</td></tr><tr><td nowrap align=right valign=top>PINDEX </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#b7">ValueSelect</a> (const <a class="el" href="structPAbstractSortedList_1_1Element.html">Element</a> *node, const <a class="el" href="classPObject.html">PObject</a> &obj, const <a class="el" href="structPAbstractSortedList_1_1Element.html">Element</a> **lastElement) const</td></tr><tr><td colspan=2><br><h2>Protected Attributes</h2></td></tr><tr><td nowrap align=right valign=top><a class="el" href="structPAbstractSortedList_1_1Info.html">PAbstractSortedList::Info</a> * </td><td valign=bottom><a class="el" href="classPAbstractSortedList.html#n0">info</a></td></tr></table><hr><a name="_details"></a><h2>Detailed Description</h2>This class is a collection of objects which are descendents of the <a class="el" href="classPObject.html#b0">PObject</a># class. It is implemeted as a Red-Black binary tree to maintain the objects in rank order. Note that this requires that the PObject::Compare()# function be fully implemented oin objects contained in the collection.<p>The implementation of a sorted list allows fast inserting and deleting as well as random access of objects in the collection. As the objects are being kept sorted, "fast" is a relative term. All operations take o(lg n) unless a particular object is repeatedly accessed.<p>The class remembers the last accessed element. This state information is used to optimise access by the "virtual array" model of collections. If repeated access via ordinal index is made there is little overhead. All other access incurs a minimum overhead, but not insignificant.<p>The PAbstractSortedList class would very rarely be descended from directly by the user. The <a class="el" href="lists_8h.html#a1">PDECLARE_LIST</a># and <a class="el" href="pasn_8h.html#a3">PLIST</a># macros would normally be used to create descendent classes. They will instantiate the template based on PSortedList# or directly declare and define the class (using inline functions) if templates are not being used.<p>The PSortedList# class or <a class="el" href="lists_8h.html#a7">PDECLARE_SORTED_LIST</a># macro will define the correctly typed operators for subscript access (operator[]#). <p><hr><h2>Constructor & Destructor Documentation</h2><a name="z177_0" doxytag="PAbstractSortedList::PAbstractSortedList"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> PAbstractSortedList::PAbstractSortedList </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top">) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Create a new, empty, sorted list.<p>Note that by default, objects placed into the list will be deleted when removed or when all references to the list are destroyed. </td> </tr></table><hr><h2>Member Function Documentation</h2><a name="z183_0" doxytag="PAbstractSortedList::Append"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> virtual PINDEX PAbstractSortedList::Append </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><a class="el" href="classPObject.html">PObject</a> * </td> <td class="mdname1" valign="top" nowrap> <em>obj</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap><code> [virtual]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Add a new object to the collection. The object is always placed in the correct ordinal position in the list. It is not placed at the "end".<p><dl compact><dt><b>Returns: </b></dt><dd> index of the newly added object. </dl><p>Implements <a class="el" href="classPCollection.html#z75_0">PCollection</a>. </td> </tr></table><a name="z179_0" doxytag="PAbstractSortedList::Compare"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> virtual <a class="el" href="classPObject.html#z199_0">Comparison</a> PAbstractSortedList::Compare </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const <a class="el" href="classPObject.html">PObject</a> & </td> <td class="mdname1" valign="top" nowrap> <em>obj</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap> const<code> [virtual]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Get the relative rank of the two lists. The following algorithm is employed for the comparison: \begin{descriptions} \item[<a class="el" href="classPObject.html#z199_0s1">EqualTo</a>#] if the two lists are identical in length and each objects values, not pointer, are equal.<p>\item[<a class="el" href="classPObject.html#z199_0s0">LessThan</a>#] if the instances object value at an ordinal position is less than the corresponding objects value in the obj# parameters list.<p>This is also returned if all objects are equal and the instances list length is less than the obj# parameters list length.<p>\item[<a class="el" href="classPObject.html#z199_0s2">GreaterThan</a>#] if the instances object value at an ordinal position is greater than the corresponding objects value in the obj# parameters list.<p>This is also returned if all objects are equal and the instances list length is greater than the obj# parameters list length. \end{descriptions}<p><dl compact><dt><b>Returns: </b></dt><dd> comparison of the two objects, <a class="el" href="classPObject.html#z199_0s1">EqualTo</a># for same, <a class="el" href="classPObject.html#z199_0s0">LessThan</a># for obj# logically less than the object and <a class="el" href="classPObject.html#z199_0s2">GreaterThan</a># for obj# logically greater than the object. </dl><p>Reimplemented from <a class="el" href="classPObject.html#z199_1">PObject</a>. </td> </tr></table><a name="b3" doxytag="PAbstractSortedList::DeleteSubTrees"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void PAbstractSortedList::DeleteSubTrees </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><a class="el" href="structPAbstractSortedList_1_1Element.html">Element</a> * </td> <td class="mdname" nowrap> <em>node</em>, </td> </tr> <tr> <td></td> <td></td> <td class="md" nowrap>BOOL </td> <td class="mdname" nowrap> <em>deleteObject</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"><code> [protected]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p> </td> </tr></table><a name="z183_7" doxytag="PAbstractSortedList::GetAt"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> virtual <a class="el" href="classPObject.html">PObject</a>* PAbstractSortedList::GetAt </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">PINDEX </td> <td class="mdname1" valign="top" nowrap> <em>index</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap> const<code> [virtual]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Get the object at the specified ordinal position. If the index was greater than the size of the collection then NULL is returned.<p><dl compact><dt><b>Returns: </b></dt><dd> pointer to object at the specified index. </dl><p>Implements <a class="el" href="classPCollection.html#z75_7">PCollection</a>. </td> </tr></table><a name="z183_8" doxytag="PAbstractSortedList::GetObjectsIndex"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> virtual PINDEX PAbstractSortedList::GetObjectsIndex </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const <a class="el" href="classPObject.html">PObject</a> * </td> <td class="mdname1" valign="top" nowrap> <em>obj</em> </td> <td class="md" valign="top">) </td> <td class="md" nowrap> const<code> [virtual]</code></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Search the collection for the specific instance of the object. The object pointers are compared, not the values. A binary search is employed to locate the entry.<p>Note that that will require value comparisons to be made to find the equivalent entry and then a final check is made with the pointers to see if they are the same instance.<p><dl compact><dt><b>Returns: </b></dt><dd> ordinal index position of the object, or P_MAX_INDEX. </dl><p>Implements <a class="el" href="classPCollection.html#z75_8">PCollection</a>. </td> </tr></table><a name="z183_9" doxytag="PAbstractSortedList::GetValuesIndex"></a><p><table width="100%" cellpadding="2" cellspacing="0" border="0"> <tr> <td class="md">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -