Delphi32.com - Home!
| Home/News | Downloads | Forums | D32 Magazine | Resources | Info and Facts |  
 
 Components: Miscellaneous: Miscellaneous


Name: Iterators Date: 10/21/03 8:05:00 PM
Environment:
Delphi 1.0, Delphi 3.0, Delphi 5.0, Delphi 7.0, Kylix 2, Windows 2000, Windows 95, Windows NT, Windows XP, Delphi 2.0, Delphi 4.0, Delphi 6.0, Kylix 1, Kylix 3, Windows 3.1, Windows 98, Windows NT 4.0
Download
Type: Freeware with Source Size: 7715
Price:
Source:
Online Registration: Link Not Available
Description:
Motivation: Delegation of extensive loop constructions as one procedure call. One should not be forced to repeat them again and again. The traditional way (e.g. C++ STL) uses an object with up to 6 methods (create, init, eof, value, step, free); in contrast to this with CLU-iterators you cannot run two iterators simultaneously (in one thread) to e.g. compare two lists but it is much easier, and by the way no space on the heap is necessary. By the way: In qgrids.pas the method TSparsePointerArray.ForAll and in TVision's TCollection.ForEach and TCollection.FirstThat such iterators were already simulated... Application: Loop through containers (lists, trees, parameters, directories, registry, etc.). "frame routines", e.g. for locking purposes. Semantic: Principely the iterator is called, which on its part calls the loop body on each yield. The loop body and its scope (principly a local procedure) are transferred as hidden parameters.The iterator communicates with the loop body via reference parameters. Simple example (result: '1 2 3 4 7 8 9 10 ') type tn_set=byte; tsn_set=set of tn_set; iterator for_in(var i:byte; const s:tsn_set); var j: tn_set; ss: tsn_set; begin ss:=s; (* Local copy, might be necessary or implicitely supplied *) for j:=0 to 255 do begin if j in ss then begin i:=j; YIELD(iterator_base); end; end; end; var q: tn_set; begin for_in(q, [1..3, 7..10]) do begin write(q,' '); end; end. References: http://www.home.unix-ag.org/tjabo/ruby/uguide/uguide08.html http://webster.cs.ucr.edu/Page_asm/ArtofAssembly/ch12/CH12-6.html


Additional Information: 
  • Total downloads between 10/22/03 and 7/6/08: 467
Author: Jasper Neumann No Homepage Specified
  
Components: Miscellaneous: Miscellaneous <<  Browse  >> Freeware with Source



 
 Hits/month  2,500,000+ 
 Downloads
 (Since May 2000)
 7,393,709 
 Total Files  6,023 
 Forum msgs  7,670 
 Articles/FAQs  70+/900+ 
Kylix
Tips n Tricks
FAQs
Knowledge Base
Bug Listings
Articles
Books
Newsgroups
Links
Submissions
Testimonials
Advertising
Contact Us
About Us
Search Amazon:
Top Selling Software at Amazon

| Home/News | Downloads | Forums | Resources | Info and Facts | Testimonials |
  Site Search:
 


Comments/Problems: Webmaster@delphi32.com
Copyright © 1998-2006, Delphi32.com. All rights reserved.
Terms of Use