Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » no true Iterator support in Upp???
PROPOSAL [message #28988 is a reply to message #28965] Thu, 30 September 2010 16:16 Go to previous messageGo to previous message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
Here comes a proposal, meybe it is worth thinking about..
Iter<T>
ConstIter<T>

are interfaces to iterate through the containers (without beeing able to modify them)

currently supported containers:
ITER_CONT(Vector<T>)
ITER_CONT(Array<T>)
ITER_CONT(BiVector<T>)
ITER_CONT(BiArray<T>)
ITER_CONT(Index<T>)
ITER_CONT(ArrayIndex<T>)
ITER_CONT(Segtor<T>)

ITER_PTR(Ptr<T>)
ITER_PTR(One<T>)
ITER_PTR(T*)

Any
Value
Link<T>


the classes themselves are not changed at all.
Vector<int> vi;
vi.SetCount(10);
One<Iter<int> > ii = IterCreator::GetIter(vi);
while(ii->Next())
	ii->Get() = Random();

//or use macro
FOREACH(int, i, vi)
	i = Random();



there are also const variants, and respective macros

attached is a Test environment. it uses the Gen package from bazaar..for the Copyable interface.

a 'drawback' is the fact that the iter interfaces are all created on the heap to be able to clone them..here one can understand that i.e. C# enumerators rely on garbage collect features Smile

nevertheless, i think it could be a helping package, when implementing abstraction layers..

please comment...
  • Attachment: Iter.zip
    (Size: 4.16KB, Downloaded 213 times)
 
Read Message icon5.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Handle a RGBA* with ImageBuffer
Next Topic: Animate does not really animate
Goto Forum:
  


Current Time: Sat Jul 19 11:24:11 CEST 2025

Total time taken to generate the page: 0.03775 seconds