Lecture 19 Part 3: More Visitors

October 5, 2012

Ambient temperature: 74.5oF Concepts There are three approaches to the “sum” algorithm on the NEList/MTList list structure: nonEmptyCase(…) { return MY_VALUE + rest_of_list.execute( this ); } This is TAIL recursion, and accumulates the return value on the STACK. Another name for it is “Forward Accumulation.” nonEmptyCase(…) { return rest_of_list.execute( this ) + MY_VALUE; } This […]


Lecture 19 continuted: More Visitors

October 3, 2012

Ambient temperature: 74.4oF Concepts Dr. Wong demonstrates the visitor design pattern: The HostA-HostB-HostC visitor pattern from last class’ lecture. Linked Lists with counting, summation, copying, and mapped addition. The visitor pattern is an example of “double dispatch:” First the visitor object is dispatched to a host object, then a particular method is dispatched from the […]