import java.util.Collection;
import example.Event;
public interface Query
{
public boolean hasMore ();
public Collection<Event> getNext ( long count ) throws Exception;
}
This is the interface I have, which I want to implement.
The implementation is supposed to be like this:
import java.util.ArrayList;
import java.util.Col...
Hello,
Today I wrote a small predicate to find matching symbols in a container.
But I'm faced to a problem: I want to use this predicate in a std::find_if call inside a const-method of a class, searching in a container that is a member of this class.
But I just noticed that neither std::find nor std::find_if are able to operate on con...
The compiler (VC8) error is:
error C2680: 'std::_Tree<_Traits>::iterator' : invalid target type for dynamic_cast
the source code to simulate the error :
[EDIT]source fixed now
#include <map>
#include <string>
struct tag_data
{
int in;
int on;
std::string sn;
};
class myclass
{
private:
typedef std::map<std::string, tag...
I have been thinking about the IEnumerator.Reset() method. I read in the MSDN documentation that it only there for COM interop. As a C++ programmer it looks to me like a IEnumerator which supports Reset is what I would call a forward iterator, while an IEnumerator which does not support Reset is really an input iterator.
So part one of ...
I'm trying to jump through some hoops to organize data in a special way. I'm including a simplified piece of code that demonstrates my pain.
I can't use boost.
I'm using the latest version of g++ in cygwin.
#include <iostream>
#include <map>
using namespace std;
int main () {
map< int,int > genmap;
map< int,int >::iterator g...
The following does not compile, and I cannot for the life of me see why!
#include <list>
using namespace std;
list<char> myList;
list<int>::iterator it;
it = myList.begin();
The error:
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::list<_Ty>::_Iterator<_Secure_validation>' (or there is no...
l = range(100)
for i in l:
print i,
print l.pop(0),
print l.pop(0)
The above python code gives the output quite different from expected. I want to loop over items so that I can skip an item while looping.
Please explain.
...
public synchronized X getAnotherX(){
if(iterator.hasNext()){
X b = iterator.next();
String name = b.getInputFileName();
...
return b;
}
else{return null;}
}
despite the synchronized statement in the declaration header, i still get a ConcurrentModificationException Exception at the line where i use iterator.next(); w...
My problem is more complex than this, so I've narrowed it down to a very simple example that would show me enough to know how to handle the rest.
Say I have an input iterator. I want make a new input iterator derived from it, where each element is the combination of multiple sequential elements of the original input with the following p...
Hello all!
Just now, I'm reading Josuttis' STL book.
As far as I know -- c++ vector is a c-array that can be reallocated. So, I understand, why after push_back() all iterators and references can become invalid.
But my question is about std::deque. As I know it is array of large blocks (c-array of c-arrays). So push_front() inserts elem...
Possible Duplicates:
Iterate a list as tuples in python
How do I iterate over the tuples of the items of two or more lists in Python?
I have two iterables in Python and I want to go over them in pairs:
foo = (1,2,3)
bar = (4,5,6)
for (f,b) in some_iterator(foo, bar):
print "f: ", f ,"; b: ", b
should result in:
f: 1; ...
When I retrieve the begin() iterator of a boost::tokenizer, I get a crash in msvcp90d.dll, that says "ITERATOR LIST CORRUPTED", which looks suspiciously like issues I have run into before with the _HAS_ITERATOR_DEBUGGING compiler flag, however I have verified that my program is being compiled with this flag turned off.
Here is the prog...
When trying to compile the following:
#include <string>
#include <iterator>
#include <iostream>
using namespace std;
int main() {
string s(istream_iterator<char>(cin), istream_iterator<char>());
return s.size();
}
g++ 4.4.1 gives me:
main.cc: In function ‘int main()’:
main.cc:6: error: request for member ‘size’ in ‘s’, which is o...
This is an excerpt of some c++ code, that i'll have to explain in detail in some days:
std::vector<int> vct(8, 5);
std::generate(vct.begin(), vct.end(), &rand);
std::copy(vct.rbegin(), vct.rend(),
std::ostream_iterator<int>(std::cout, "\n"));
i think i understand everything about it, except that tiny mystical &rand. what exactly...
I'm trying to create a utility class for traversing all the files in a directory, including those within subdirectories and sub-subdirectories. I tried to use a generator because generators are cool; however, I hit a snag.
def grab_files(directory):
for name in os.listdir(directory):
full_path = os.path.join(directory, name...
I have a STL::multimap and I search it with equal_range to return an upper and lower bound. Can I find the number of elements in this range without iterating through them all and counting them one by one?
#include <iostream>
#include <map>
using namespace std;
int main () {
multimap<int,int> mm;
pair<multimap<int, int>::iterat...
(Note: I'm writing this project for learning only; comments about it being redundant are... uh, redundant. ;)
I'm trying to implement a random access iterator, but I've found very little literature on the subject, so I'm going by trial and error combined with Wikpedias list of operator overload prototypes.
It's worked well enough so far...
I wrote an OutputIterator for an answer to another question. Here it is:
#include <queue>
using namespace std;
template< typename T, typename U >
class queue_inserter {
queue<T, U> &qu;
public:
queue_inserter(queue<T,U> &q) : qu(q) { }
queue_inserter<T,U> operator ++ (int) { return *this; }
queue_inserter<T,U> operat...
I have been searching for sample code creating iterator for my own container, but I haven't really found a good example. I know this been asked before (http://stackoverflow.com/questions/148540/c-creating-my-own-iterators) but didn't see any satisfactory answer with examples.
I am looking for simple sample code to start how to design ...
Is there an efficient, practical way to iterate over a binary tree given the following constraints:
You do not have control of the call stack, and thus may not use recursion. All state must live inside the iterator/range object, not on the stack.
No heap allocations may be used anywhere in the algorithm.
The tree may be immutable, and...