2
我想提請任何遞歸方法調用堆棧,所以我創建了這樣一個模式,繪製調用堆棧的遞歸方法
recursiveMethod(){
//Break recursion condition
if(){
// Add value here to the return values' list- No drawing
return
}
else{
//Draw stack with the value which will be pushed to the stack here
variable <- recursiveMethod()
//Clear the drawing which represents the poped value from the stack here
return variable
}}
應用架構將看起來像這樣,
alt text http://i40.tinypic.com/11tbrdf.jpg
注:
- 此架構可以通過在遞歸調用中使遞歸調用在單獨的返回語句中進行遞歸調用,從而得出遞歸調用方法n。
- returnValues列表是一個保存所有返回值的列表,僅用於查看問題。
- 繪製堆棧意味着,只需繪製一個簡單的單元格「矩形」+繪製推送的字符串。
您怎麼看待這個問題?任何建議都非常受歡迎。
「繪製堆疊」是什麼意思?也許我不瞭解情況。 – WhirlWind 2010-04-13 00:35:24
我編輯了我的帖子。 「繪製堆棧意味着,只需繪製一個簡單的單元格」矩形「+繪製推送的字符串。」 – Lisa 2010-04-13 00:48:22
該方案看起來可行。我建議在圍繞它構建GUI之前在ascii中嘗試它。 – Beta 2010-04-13 17:09:46