This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes recursion Performance , Global Var Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "recursion Performance , Global Var " Watch "recursion Performance , Global Var " New topic
Author

recursion Performance , Global Var

EM. Lashkar
Greenhorn

Joined: Jan 31, 2003
Posts: 9
I am writing a mehod in a bean which returns a Set of "All" generations of subBusinesses ( Children) for a given business.
/************************************/
public Set getAllChildren3( String p_orgId){

Object l_busParentObj1 = null;


Map l_tempMap1 = new HashMap();
Set l_tempSet1 = new TreeSet();



// Getting all the 1st gen children
l_tempMap1= (Map)getChildBusMap( p_orgId) ;


if ( l_tempMap1.size()>0)
{
tempSet.addAll(l_tempMap1.keySet());
l_tempSet1.addAll(l_tempMap1.keySet());
for (Iterator iTemp1=l_tempSet1.iterator(); iTemp1.hasNext(); )
{
l_busParentObj1= iTemp1.next();
if ( isThereChildBus(l_busParentObj1.toString()))
getAllChildren3( l_busParentObj1.toString());
}
}
return tempSet ;
}
/************************************/
// the method "getChildBusMap(" returns the immediate subBusiness( 1st generation Children) for a given Business
// where "tempSet" is a global reUsable Set Object, currently using only in this method.
The method works just fine , but I hate the fact that I had to use aglobal variable ! Its lot of work to keep track of global variables . Do you have any suggestion as to HOW I COULD USE A LOCAL VARIABLE in this recursion in place of "tempSet".
Any other design suggestion ?
Thx in dvance for reading this.
ML
[ February 22, 2003: Message edited by: EM. Lashkar ]

ML
 
GeeCON Prague 2014
 
subject: recursion Performance , Global Var