Ok, Iterators seem to slow the performance down far too much in applications. I don't know of any way to get around them. Can someone give me a suggestion on what I can use instead of iterators?
Printable View
Ok, Iterators seem to slow the performance down far too much in applications. I don't know of any way to get around them. Can someone give me a suggestion on what I can use instead of iterators?
iteration is the fastest method for looping trough the memory(if you do it right)
Code:int* data = malloc(sizeof(int) * 10);
int set = 10;
for(int* iter = data + 10; iter >= data; --iter)
*iter = --set;
free(data);
An iterator is a concept, not a type. So what you're saying doesn't really make sense.Quote:
Originally Posted by Rehorav
For example, pointers are random access iterators, so what do you mean by "iterators"? Pointers? A vector::iterator? A std::list::iterator? A map::iterator? Your own custom iterator?
Regards,
Paul McKenzie
Well what I really want to know, is what I can use instead of:
Code:n=0 ; n<5 ; n++
see As Paul Suggest you that An iterator is a concept, not a type. Show what u mean by all of this things .if you directly want to perform some operation . use Vector or List what ever you want. you can use Recursion which is pretty fast.But you have to handle this in a very efficient manner.
what is this . if i put a for with braces it makes a for loop . and simply writing this is a Error like n++ doesn't have a semicolon. Second what ever state ment you write a loop if will execute till then loop condition is true . but what about your this lines is it going to serve something good for you. don't think soo.Code:n=0 ; n<5 ; n++
Thanx
Thanx
Quote:
Originally Posted by Rehorav
There is nothing wrong or any performance issue with iteration using for-loop. I don't think you can do anything that is faster than the for-loop.Code:for(n=0 ; n<5 ; n++)
{
//...
}
One reason that it becomes a performance issue would be because you are writing the code to search through a very long array. If that is the case, you are approaching the problem incorrectly because there are many methods/algorithms that are well-suited for this task. For example, you can use binary search in a sorted array, hash-table, etc.
You should be using ++n, not n++Quote:
Originally Posted by Rehorav
From the FAQ: http://www.codeguru.com/forum/showthread.php?t=231052