Lecture 6 Notes

Every time the traversal reaches a node n for which a

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 8PwP|1Pw“†‹”†iƒ” ŠŒx{ˆŠy ‚yt~}{zysxwu ‚{ˆ¡± t ˆs ™yq rr {q— tz Šy 8“‚V”wiV†|"viE“Ži†i“†ˆ }ˆxy „ °5G8“‚“iPE“P‚“Vwƒws ˜ ‘ t ˆs™–t ¯yŒ y~Št ¥ ’ ‘  x r s ™ } ˆ x y  © y  Œ— › ‘ y  ~ Š t G5`w”†‚V“Vi|‚V“‚®ª”1“iw”ws ˜ ui†i“†ˆ  }ˆxy ’ ‘ › ¬ q  ‰t › s ˆ y ¬ t z Š y  t ˆ  › s ˆ y— Œ G8­qwwƒ8“‚VqPEiC`P8“‚P‚V«ª”q ’ `¥ ¥’ rs ›Ÿ }ˆxy ˆ "vV‚PiVi“‚viiiP‚||4v‚|†‚†“†i“‚i“‚€wiw|§iwwVV }ˆxyˆ„‘ xrs™}ˆxy©yŒ yq¨ ¦ qzr x ¥’ ‘£ › – – s— r s › Ÿ } ˆ x y  ˆ „‘ £ › "G|ˆ¤%“i¤RV‚PiVi“‚P|“ˆ¢iP€1“‚C`‚“†i‚”‚›  r sz ˆ s ™  ˆ { ¡  –z{ ’ ‘ y~Št G4%“Vw”‚s ˜ } Pwv†‚|i†iP‚“Vwƒws ˜  rs›Ÿ}ˆxyˆ y~Št „‘ ˆ{yztz ™ P5R“‚”Vi1žPwbœP‚”†i8™ }  › ˆ{yztz „‘q‰t›sˆy P†wwƒ8“‚V•iƒ1V“šG8“‚i€wiVVPb“Vwƒws ˜ Œ}z ˆ y~ t ˆs ™yq r r {q y~Št ——— VVn“‚V”qƒ•8“†€1iV”1PPq –yyz ‚{ tˆ{yqxˆyt}{ “ V“ ’ ‘ Š‰sˆ‡ttsr… G4RVP‚i€Vwi‚DP‚ŽD€‹iP‚i|iwi‚†i1P‚€t }  Œq Š‰sˆ‡ttsr… qzysy „ ‚yt~}{zysxwu Eƒ‚€8“‚P|1“‚“†vVwiPq ttsr h ƒ 8€ ƒ k € h „ The method takes a string that specifies the traversal to be performed. It first creates a visitor to implement the behavior that is to be performed during the traversal. Once the visitor is created, then initiates the traversal by calling the method of the current class graph , ), the traversal passing as arguments the object at which to start the traversal ( to be performed ( ), and the visitor to be executed along the way ( ). o ‡ ƒ ˜ — k 8€ o h o o h  w€ ˜ 1™ ˜ — o l 8l o µ „ l l –˜ µ |`‚— ˜ ƒ wh ƒ € µ †— µ h o p h ƒ €  w€ c h ƒ wh ƒ € ‡ –˜ µ |`†— ƒ 8€ The execution of follows the visitor pattern [4], augmented by reflection. Every time the traversal reaches a node n for which a method has been defined, it calls n . The traversal method only on objects for which a algorithm uses reflection to call the method has been defined. Thus, when the node is a variable, the method (the “visitor method”) is called, adding the node to the , set. Similarly, on completion of the search, the traversal calls which returns the collected hash set. p c µ °So ¶ hƒ 1w„ ‘ h ”‰ µ –˜µ P`†— ¶˜ )1™ ˜ µ †— ‰ o hƒ 1w„ ‘ h h1ƒw„ ‘ h hƒ Ew„ ‘ h p Y p |c h ˆ… l 8— k d ƒ…€h·€h Ew‚ˆww1‡ ‰ ” ” µ h l”— GV‚™ ƒ — kc hƒ Ew„ ‘ h ” ” µ Unlike the case of the ordinary visitor pattern, no preparation in the underlying objects is nec...
View Full Document

This document was uploaded on 03/17/2014 for the course CSG 111 at Northeastern.

Ask a homework question - tutors are online