Submitted by ttrenka on Thu, 04/13/2006 - 22:01.
I'm getting back to making fixes to the Collections, and
there will be a number of breaking changes--namely with the Iterators (which are horribly broken). Both the Iterator and the DictionaryIterator will change the way elements are accessed. For example:
var a=someArrayList; // type dojo.collections.ArrayList
var iterator=a.getIterator();
while(e.current() e.get()){
doSomething(e.element);
}
The key here is the way you iterate; iterators have a new method called
current get (note that this is a method that replaces the "current" property); this method returns the
current element and
then advances the internal cursor by one. If the iterator has reached the end of internal list,
current() get() returns null (making it useful as a test, like above). There is also an
atEnd method (an actual method, replacing the atEnd property) which allows you to check to see if the collection has finished iterating.
The element on which the iterator is currently sitting is also accessible via the
element property (see above); this is a convienence property more than anything else.
Iterators also will support a
map method, allowing you to do functional iteration instead:
var result=(a.getIterator()).map(doSomething);
These changes are still being worked on but will be checked in some time next week, so if you develop against the HEAD revision and are using Collections, be warned!
(UPDATE: changing "current()" to "get()" per Bill Keese's suggestion. Thanks Bill!)
Hmm... old name and new
Ya, yuck. Most commensense
Rick: the consensus on the
I like the way Java API
Alex: Really? Activity on
So how about a ruby/python
See map(). The issue there
PLEASE, do not call it
Daniel, Lots of different
please provide some inputs