commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@eurobell.co.uk>
Subject Re: [collections] - Few more collections for the masses... (impor tant for Struts view objects, maybe other projects)
Date Sat, 18 May 2002 10:19:08 GMT
From: Arron Bates <arron@keyboardmonkey.com>
> James Strachan wrote:
> >Also are these collections 'lazy'?  i.e. is their point to lazily
construct
> >elements as they are asked for, on demand, in the same way as the lazy
> >initialization pattern for bean properties? Maybe calling them lazy might
be
> >better then?
> >
> Lazy says nothing about having the collection expand, or reserve spaces
> for called objects, not set objects. Lazy would say more of the
> collection itself than how it manages things.

I think I'm with James on this one. Reserve is a name that makes sense for
the List implementation, but not for the Map one. Lazy is about saying that
the collection creates objects on demand if the entry is null, or rather if
get method would have returned null (or for list if the get method is out of
bounds).

Viewed as a lazy instantiation group of collection proxies, I think that it
could be useful for commons. Of the 8 possible types that have been
mentioned, lazy instantiation is applicable to all. For LazyCollection, the
only access is via an iterator. The iterator should loop through the
collection and on the next() method should return a newly created object if
it was about to return null. For LazyList the code remains roughly as you
have it, except that DeadObject is relaced by null. And so on.

Thus, all 8 collections have potential 'Lazy' implementations. The
PredicateUtils class does show how this can be implemented without scarily
enlarging the interface.

Finally, I would implement the clean() method as a separate static method
that removes null's from a Collection/Map.

Stephen




--
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