jQuery in Action, 3rd edition
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "recursion Performance , Global Var " Watch "recursion Performance , Global Var " New topic

recursion Performance , Global Var

EM. Lashkar

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)
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.
[ February 22, 2003: Message edited by: EM. Lashkar ]

I agree. Here's the link: http://aspose.com/file-tools
subject: recursion Performance , Global Var
It's not a secret anymore!