I released another SqueakMap package tonight called "Lazy Collections". Here's the excerpt:
- The idea for LazyCollection is very simple. It takes a functional
approach to the common collection protocol of select:, collect:, and
reject:. By functional, I mean the collection is not changed nor is a new
one created. The blocks are kept around until they are absolutely
needed. I have been wanting this functionality for some time because
it's nice for large collections. If you have a collection in which you are
calling a lot selects, rejects, or collects on, then this will not create
the intermediate collections. It will wait until you ask something of the
collection where it can not delay the answer. This should make these
chained operations must faster on large collections.
This was a lot of fun to program and it's not that big. Take whatever
you want from it!
Basically, I implemented new selectors collect:, reject:, and select: called lazyCollect:, lazyReject:, and lazySelect: respectively. Now, these new implementations return a simple place holder object instead of calculating a new collection. It keeps the blocks around. This is useful when you're doing selects and collects in series. It simply combines the blocks. It was a lot of fun to write and it's something that I've blogged about before. It was a short little excursion. I will probably be adding more to it in the future, but I'm very happy with it right now. I hope you enjoy it!