I have:
void add_all_msgs(std::deque<Message>::iterator &iter);
How can I make that function "generic", so it can take any kind of inputiterators ? I don't really care if it's iterating a deque,a vector or something else, as long as the iterator is iterating Message's. - is this at all straight forward possible in c++ ?
...
I'd like to read at most 20 lines from a csv file:
rows = [csvreader.next() for i in range(20)]
Works fine if the file has 20 or more rows, fails with a StopIteration exception otherwise.
Is there an elegant way to deal with an iterator that could throw a StopIteration exception in a list comprehension or should I use a regular for l...
Hello,
I am using strus2 tags in a jsp to iterate over a collection:
<s:if test="parent.entries.size > 0">
<table border="3">
<s:iterator value="parent.entries">
<tr />
<td><s:property value="entry"></td>
<td><s:property value="date" ></td>
</tr>
</s:iterator>
</table>
</s:if>
I ...
Hey everyone,
I have succesfully been able to parse a JSON into a JSONTree, however, my tree shows the iterators. I have tried iterator.remove(), but I get the error:
Error: java.lang.UnsupportedOperationException: Remove not supported on this list
Can someone please look at my code, and let me know of anything I can do? Thanks!
publ...
I have been using iterators for a while and I love them.
But although I have thought hard about it, I could not figure out "how a compiler that recognizes the iterators" be implemented. I have also researched about it, but could not find any resource explaining the situation in the compiler-design context.
To elaborate, most of the art...
i am trying to write a data iterator for SQL, it looks like the best approach is to cook up some dynamic sql for this problem.
I want the iterator to support paging, sorting, and filtering of the data, and ideally not iterate over a memory copy but to not even select the data in the first place, perhaps LINQ to SQL or Entity Framework w...
Hi,
I am writing a method which needs to check some parameters and if they are validated return an IEnumerable. E.g.
public static IEnumerable<double> GetEnum(int param)
{
if (!IsValidParameter(param))
{
throw new Exception();
}
while(true)
{
yield return 5.0;
}
}
However, I believe because of...
As part of some WSGI middleware I want to write a python class that wraps an iterator to implement a close method on the iterator.
This works fine when I try it with an old-style class, but throws a TypeError when I try it with a new-style class. What do I need to do to get this working with a new-style class?
Example:
class Iterator...
I'd like to create two containers that contain iterators to each other. I'd like to do this hopefully without introducing any intermediate/indirect types. Is this possible or do iterator types depending on knowing the size of the container's data type?
Here is some sample code that I'd like to get compiling:
#include <map>
#include <de...
Hi all,
I'm trying to implement without success a Date iterator with Joda time.
I need something that allows me to iterate all the days form startDate to endDate
Do you have any idea on how to do that?
...
Hello all ,
I was wondering how I can realize the following:
Creating a next button and when it's tapped the next UITableview row will be selected.
Since a picture is worth a thousand words I've added a screenshot.
http://img529.imageshack.us/img529/4341/picture5uuj.png
As you can see below I added a toolbar and if I press the rig...
Does the C++ Standard say I should be able to compare two default-constructed STL iterators for equality? Are default-constructed iterators equality-comparable?
I want the following, using std::list for example:
void foo(const std::list<int>::iterator iter) {
if (iter == std::list<int>::iterator()) {
// Something
}
}
...
In Java, is it legal to call remove on a collection when iterating through the collection using a foreach loop? For instance:
List<String> names = ....
for (String name : names) {
// Do something
names.remove(name).
}
As an addendum, is it legal to remove items that have not been iterated over yet? For instance,
//Assume that...
I`m writing binary search tree template for two reasons - learning C++ and learning most common algorithms and data structures. So, here is the question - as long as I want to implement iterators, it seems to me that there is no strict definition for where tree ends. What are your suggestions? How do I do this?
...
Say I have an iterator.
After iterating over a few items of the iterator, I will have to get rid of these first few items and return an iterator(preferably the same) with the rest of the items. How do I go about?
Also, Do iterators support remove or pop operations (like lists)?
...
Can somebody provide a real life example regarding use of iterators. I tried searching google but was not satisfied with the answers.
...
I'm looking for a class where I can override a method to do the work, and return the results like an iterator. Something like this:
ParallelWorkIterator<Result> itr = new ParallelWorkIterator<Result>(trials,threads) {
public Result work() {
//do work here for a single trial...
return answer;
}
};
while (itr.hasNext()) {
...
I suspect I'm doing something stupid here, but I'm confused by what seems like a simple problem with SPL:
How do I modified the contents of an array (the values in this example), using a RecursiveArrayIterator / RecursiveIteratorIterator?
Using the follow test code, I can alter the value within the loop using getInnerIterator() and off...
hi folks,
i just intent to initialize an iterator over a generic linked list like that (generic typ T seems to be erased in here since the site interpret it as tag)
public <T> LinkedList<T> sort(LinkedList<T> list){
Iterator<T> iter = new list.iterator();
...
but i got the error:
"list cannot be resolved"
what's wrong?
...
Lets say I have a linked list with a bunch of different data in it.
class Node
{
public:
Node* next;
AAA dataA;
BBB dataB;
CCC dataC;
};
Is there a way I make one iterator that would iterate over whatever variable I specify (rather than making three separate ones for each variable). I understand that the iterator coul...