Hi All,

Has anyone written Iterators for CF? I did not find any so I wrote my own.
Just in case someone might find this useful (I certainly do!) it is included
and supports the following:

Iterators for:
Queries (Iterate by column or rows)
Lists
Structs (keys, values or key value pairs)

All iterators are used something like this:
var iterator = createObject('component',QueryIterator).init(aQuery,[a Col
Name Or 0 For rows])
while(iterator.hasNext()) {
        nextItem = iterator.next()
}

cfloop pretty much negates the need for iterators, but the for-in loop only
does structs in cfscript. Hence more need for iterators.  <<Iterator.cfc>>  
<<ListIterator.cfc>>  <<QueryIterator.cfc>>  <<StructIterator.cfc>> 

Cheers
Hardy Jonck
www.gmsonline.co.za
 

Attachment: Iterator.cfc
Description: Binary data

Attachment: ListIterator.cfc
Description: Binary data

Attachment: QueryIterator.cfc
Description: Binary data

Attachment: StructIterator.cfc
Description: Binary data

Reply via email to