iterator

Find max length word from arbitrary letters

I have 10 arbitrary letters and need to check the max length match from words file I started to learn RE just some time ago, and can't seem to find suitable pattern first idea that came was using set: [10 chars] but it also repeats included chars and I don't know how to avoid that I stared to learn Python recently but before RE and ...

nested foreach with iterator interface

<? foreach ($this->criteria as $key => $value): ?> <li><?= $this->accommodationsLink($this->criteria, $key) ?></li> <? endforeach ?> This code give unexpected results, because only one link is visible. But there are two items in $this->criteria. I explored the cause of the probleem. In the function accommodationsLink is another foreac...

initialise iterator in vs 2005

hello all, i have code which initalised the itreator to 0 and it works in vc6 but if compile the same in vs2005 its giving error error C2679: binary '=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion) the code is like MapofUsers::iterator itfind; itfind = 0;intialised in contruct...

map<T,T>::iterator as parameter type

I have a template class with a private map member template <typename T> class MyClass { public: MyClass(){} private: std::map<T,T> myMap; } I would like to create a private method that accepts an iterator to the map void MyFunction(std::map<T,T>::iterator &myIter){....} However, this gets a compile error: identifier 'iterat...

Input_iterator, find_if and modulus

I implemented an iterator, which has Fibonacci numbers as output. In my main() I'd like to find a number which is dividable by 17 (it's 34). Why doesn't work my find_if statement. Thank you! #include <boost/operators.hpp> #include <algorithm> #include <tr1/functional> struct FibIter: boost::input_iterator_helper<FibIter,uns...

Can i use iterator within iterator on jsp in struts2.0 ?

This is the ArrayList defined in the private ArrayList<LocWiseSaleParam> locWiseSaleList; where LocWiseSaleParam is myaction class I am using a iterator on jsp and accessing its values. but can i use the iterator with the same value as nested iterator <s:iterator value="locWiseSaleList" id="list" > <s:iterator value="l...

Iterator member behavior

I was expecting the second assert in the following to pass. I'm asking for your help. Edit: It didn't work when I had poss everywhere instead of poss_a in some places. #include <vector> #include <cassert> class Sampler { public: std::vector<int*> poss; std::vector<int*>::const_iterator poss_it; Sampler(std::vector<int*> poss_a) : ...

Number of permissible active iterators into a vector

For example is the following valid? std::vector<int> vec(5, 0); std::vector<int>::const_iterator it1(vec.begin()); std::vector<int>::const_iterator it2(vec.begin()); //Use it1 and it2 like they don't know about each other. Is there a special name for a container that permits multiple active iterators? ...

how can i get two consecutive values from Iterator

Here is my code that i tried to get two consecutive elements of Iterator. public void Test(Iterator<Value> values) { Iterator<Value> tr = values; while (tr.hasNext()) { v = tr.next(); x = v.index1; // u = null; if (tr.hasNext()) { u = tr.next(); y = u.index1; } els...

Iterator bug of (more likely) a very subtle behavior ?

Hi all, My problem requires 3 (not too long functions) to reproduce (VS2010 / .NET 4) In the first case, my IEnumerable is not evaluated (through the ToList() method) I can't see why.. // Main program private void ButtonTest_Click(object sender, RoutedEventArgs args) { int[] indexes = new int[] { 2, 2, 2, 2, 2, 2 }; v...

Passing an iterator to a function

Looking through the source code of a binary tree,I find the following function: //definition of BTR,in case you'd want to know template< class Type> struct BTR { // The item saved to that specifiec position into the tree Type value; // Points to the left leaf BTR<Type>* left; // Points to the right leaf ...

Changing a classes member through an iterator

I'm learning C++ and can't get my head around this problem: I have a simple class A class A { private: int ival; float fval; public: A(int i = 0, float f = 0.0) : ival(i), fval(f) { } ~A(){ } void show() const { cout << ival << " : " << fval << "\n"; } void setVal(int i) { ival = i; } ...

Wrapping linked lists in iterators

A set of APIs that I commonly use follow a linked-list pattern: struct SomeObject { const char* some_value; const char* some_other_value; SomeObject* next; } LONG GetObjectList( SomeObject** list ); void FreeObjectList( SomeObject* list ); This API is not mine and I cannot change it. So, I'd like to encapsulate their...

how to call an Iterator over a hashMap

i need to see my hashMap keys and values in order to check if it s working properly.but im getting an error for the below lines: Iterator iterator = myHashMap.keySet().iterator(); Flows flows = new Flows(); while(iterator.hasNext()){ Object key = iterator.next(); Object value = myHashMap.get(key); // <-- ...

C++ Iterator do what?

Code: vector<weight *> &res; vector<weight>::iterator it = lower_bound(w.begin(), w.end(), queryweight); while(it != w.end()) { weight *w = &(*it); if(w->weight >= 60) break; res.push_back(w); it++; } I think the lower_bound do a binary search (?), so in the end, does the C++ code intend to get the wei...

Deriving from std::back_insert_iterator ?

I want to derive from std::back_insert_iterator to create a kind of filter for a string type, say back_xml_insert_iterator, that will examine the characters passed through it looking for characters that can not be emitted "naked" into an XML stream, e.g., '"', '&', '<', '>', and '\'', and will on-the-fly insert their character entity ref...

Higher order iterators in Ruby?

I was reading a Ruby question about the .each iterator, and someone stated that using .each can be a code smell if higher order iterators are better suited for the task. What are higher order iterators in Ruby? edit: Jörg W Mittag, the author of the StackOverflow answer that I was referring to mentioned that he meant to write higher lev...

all but the last item from a Scala Iterator (a.k.a. Iterator.init)

I have a number of large files where I want to process all but the last line in each file. If the files were small, I could just convert to a TraversableLike and use the "init" method, e.g.: lines.toList.init But the files are large so I need to keep things as an iterator. Is there a simple way to get something like "init" on an Itera...

Using boost::iterator_facade<>

I have a linked list structure: struct SomeLinkedList { const char* bar; int lots_of_interesting_stuff_in_here; DWORD foo; SomeLinkedList* pNext; }; It is part of an existing API and I cannot change it. I would like to add iterator support. The boost::iterator_facade<> library seemed ideal for the purpose. class Some...

Testing whether an iterator points to the last item?

I have an stl iterator resulting from a std::find() and wish to test whether it is the last element. One way to write this is as follows: mine *match = someValue; vector<mine *> Mine(someContent); vector<mine *>::iterator itr = std::find(Mine.begin(), Mine.end(), match); if (itr == --Mine.end()) { doSomething; } But it seems to me...