1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Body/04_cea.htm

34 lines
5.7 KiB
HTML
Raw Permalink Normal View History

2024-04-01 10:24:07 +02:00
<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
<HTML>
<HEAD>
<TITLE>CLHS: Section 4.3.5.1</TITLE>
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
<LINK REL=TOP HREF="../Front/index.htm">
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
<LINK REL=PREV HREF="04_ce.htm">
<LINK REL=UP HREF="04_ce.htm">
<LINK REL=NEXT HREF="04_ceb.htm">
</HEAD>
<BODY>
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="04_ce.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="04_ce.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="04_ceb.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>
4.3.5.1 Topological Sorting</H2> <P>
Topological sorting proceeds by finding a class C in SC such that no other <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> precedes that element according to the elements in R. The class C is placed first in the result. Remove C from SC, and remove all pairs of the form (C,D), D&lt;ELEMENT-OF&gt;SC, from R. Repeat the process, adding <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>classes</I></A> with no predecessors to the end of the result. Stop when no element can be found that has no predecessor. <P>
If SC is not empty and the process has stopped, the set R is inconsistent. If every <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> in the finite set of <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>classes</I></A> is preceded by another, then R contains a loop. That is, there is a chain of classes C1,...,Cn such that Ci precedes Ci+1, 1&lt;=i&lt;n, and Cn precedes C1. <P>
Sometimes there are several <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>classes</I></A> from SC with no predecessors. In this case select the one that has a direct <A REL=DEFINITION HREF="26_glo_s.htm#subclass"><I>subclass</I></A> rightmost in the <A REL=DEFINITION HREF="26_glo_c.htm#class_precedence_list"><I>class precedence list</I></A> computed so far. (If there is no such candidate <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A>, R does not generate a partial ordering---the Rc, c&lt;ELEMENT-OF&gt;SC, are inconsistent.) <P>
In more precise terms, let {N1,...,Nm}, m&gt;=2, be the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>classes</I></A> from SC with no predecessors. Let (C1...Cn), n&gt;=1, be the <A REL=DEFINITION HREF="26_glo_c.htm#class_precedence_list"><I>class precedence list</I></A> constructed so far. C1 is the most specific <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A>, and Cn is the least specific. Let 1&lt;=j&lt;=n be the largest number such that there exists an i where 1&lt;=i&lt;=m and Ni is a direct <A REL=DEFINITION HREF="26_glo_s.htm#superclass"><I>superclass</I></A> of Cj; Ni is placed next. <P>
The effect of this rule for selecting from a set of <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>classes</I></A> with no predecessors is that the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>classes</I></A> in a simple <A REL=DEFINITION HREF="26_glo_s.htm#superclass"><I>superclass</I></A> chain are adjacent in the <A REL=DEFINITION HREF="26_glo_c.htm#class_precedence_list"><I>class precedence list</I></A> and that <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>classes</I></A> in each relatively separated subgraph are adjacent in the <A REL=DEFINITION HREF="26_glo_c.htm#class_precedence_list"><I>class precedence list</I></A>. For example, let T1 and T2 be subgraphs whose only element in common is the class J. Suppose that no superclass of J appears in either T1 or T2, and that J is in the superclass chain of every class in both T1 and T2. Let C1 be the bottom of T1; and let C2 be the bottom of T2. Suppose C is a <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> whose direct <A REL=DEFINITION HREF="26_glo_s.htm#superclass"><I>superclasses</I></A> are C1 and C2 in that order, then the <A REL=DEFINITION HREF="26_glo_c.htm#class_precedence_list"><I>class precedence list</I></A> for C starts with C and is followed by all <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>classes</I></A> in T1 except J. All the <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>classes</I></A> of T2 are next. The <A REL=DEFINITION HREF="26_glo_c.htm#class"><I>class</I></A> J and its <A REL=DEFINITION HREF="26_glo_s.htm#superclass"><I>superclasses</I></A> appear last. <P>
<HR>
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
</BODY>
</HTML>