commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bob mcwhirter <...@werken.com>
Subject Re: [Collections][Submit] TreeNode and friends
Date Sun, 26 May 2002 14:55:25 GMT
> > 3.  What's the rationale for having equals and hashCode
> > be reference based?
> 
> The alternative is to compare both the value and children of that node. But
> in comparing the children, each child node will compare its value and
> children and so on. This would be potentially very expensive. Its also how
> JDOM does its equals method.

Just to clarify:  JDOM uses identity-based equality, not semantic.  Right?

> > 4.  Must tree iterators be depth-first?  The ordered
> > traversal for a heap tree isn't depth-first.
> 
> No, but depth first is the one I needed ;-)  There are two possibilities
> here,
> a) Add extra methods for different iteration types
> b) Remove the comment that specifies how the iteration is done.

I think, personally, for things like trees, either having

	depthFirstIterator()
	bredthFirstIterator() 

or removing all iteration from the tree directly, and require
folks to do:

	Iterator iter = new DepthFirstIterator( tree );
		
		or

	Iterator iter = new BredthFirstIterator( tree );

Just because there's no -default- way to iterate a tree, I don't
think having just a plain iterator() method is sufficient.

	-bob


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message