2012-02-11 39 views

回答

0

選擇一個(我假設給定的子樹),然後先找到這組父:

while (element.getParent()!=null) 
    element = element.getParent(); 
parent = element; 

現在你有父母,你只需要迭代其子女遞歸:

TreeItem TreeItem::getLastChild() 
{ 
children = getChildren(); 
if (children == null) 
    return parent; 

int maxIndex = 0; 

    // find child with maximum index 
    ..... 

    return foundedChild.getLastChild(); 
} 
相關問題