I am trying to use the PHP recursive directory iterator to find php and html files in order to list those by date. The code used is as follows:
$filelist = array();
$iterator = new RecursiveDirectoryIterator( $this->_jrootpath );
foreach(new RecursiveIteratorIterator($iterator) as $file) {
if ( !$file->isDir() ) {
if ( preg_...
Hey everyone!
I am studying Data Structures in java and I am having difficulty with using generics in Binary Search Trees.
For our assignment we are to implement a Binary Search Tree using nodes that contain a parent, left and right node as well as a data value.
The data value in our case takes the form of a Pair object. This is what i...
When I try to use a set iterator in debug mode in C++, I get an error that says "map/set iterator not dereferencable". I don't understand because I thought dereferincing was how you are supposed to use an iterator. The code looks like this:
set<int>::iterator myIterator;
for(myIterator = mySet.begin();
myIterator != mySet.end();
...
I'm trying to write the Haskel function 'splitEvery' in Python. Here is it's definition:
splitEvery :: Int -> [e] -> [[e]]
@'splitEvery' n@ splits a list into length-n pieces. The last
piece will be shorter if @n@ does not evenly divide the length of
the list.
The basic version of this works fine, but I want a version tha...
Hi,
I found the following code in the book "Accelerated C++" (Chapter 6.1.1), but I can't compile it. The problem is with the find_if lines. I have the necessary includes (vector, string, algorithm, cctype). Any idea?
Thanks, Jabba
bool space(char c) {
return isspace(c);
}
bool not_space(char c) {
return !isspace(c);
}
vector<s...
Hi! I have a question.
I have a list of names, say 8 names: Joe, Bob, Andrew, Bill, Charlie, Sarah, Ann, Victor
The count of names might differ**.
1) What should I use as name list? Hashmap, Vector, Hashtable, List, ArrayList?
2) I need to match them up like this: Joe-Bob, Andrew-Bill, Charlie-Sarah, Ann-Victor. Could you please sho...
I've had the same need a few times now and wanted to get other thoughts on the right way to structure a solution. The need is to perform some operation on many elements on many threads without needing to have all elements in memory at once, just the ones under computation. As in, Iterables.partition is insufficient because it brings al...
Whats the difference?
I want to be able to see if an element is in a HashMap and I just found out that if I do h[element], it will return the default element if it is not found, and not null. How would I use the iterator find method to see if the element is there?
Thanks
...
my code run wrong
class a(object):
def __iter(self):
return 33
b={'a':'aaa','b':'bbb'}
c=a()
print b.itervalues()
print c.itervalues()
Please try to use the code, rather than text, because my English is not very good, thank you
...
i don't know "self._iterator = iter(self._container)"in next code.
in django.http :
class HttpResponse(object):
def __iter__(self):
self._iterator = iter(self._container)
return self
def next(self):
chunk = self._iterator.next()
if isinstance(chunk, unicode):
chunk = chunk.encode(sel...
I want to replace empty lines in my string with an iterating number
e.g.
replace
String:
"My first line
My second line
My third line"
with
"
1
My first line
2
My second line
3
My third line"
I can match and replace these lines using
var newstring = TestVar.replace (/(^|\n\n)/g, "\nhello\n");
However I'm struggling to ad...
I have the following code in django.template:
class Template(object):
def __init__(self, template_string, origin=None, name='<Unknown Template>'):
try:
template_string = smart_unicode(template_string)
except UnicodeDecodeError:
raise TemplateEncodingError("Templates can only be constructed fro...
i created a map.
i want to print the index of the key to a file using the itr in the map.
this is what i mean:
map <string,int> VendorList;
VendorList[abc] = 0;
VendorList[mazda] = 111;
VendorList[ford] = 222;
VendorList[zoo] = 444;
map <string,int>::iterator itr=VendorList.find("ford");
fstream textfile;
textfile << itr;
if i put i...
Haven't Python iterators got a hasNext method?
...
hello
Is there C++ equivalent for python Xrange generator in either STL or boost?
xrange basically generates incremented number with each call to ++ operator.
the constructor is like this:
xrange(first, last, increment)
was hoping to do something like this using boost for each:
foreach(int i, xrange(N))
I. am aware of the for loo...
I have these two classes in OCaml
class type ['a] collection =
object
method add : 'a -> unit
method clear : unit -> unit
method iterator : unit -> 'a iterator
method remove : 'a -> unit
end
class type ['a] iterator =
object
method hasNext : unit -> bool
method next : unit -> 'a
end
And I need to cr...
Hi,
I was wondering why the GetEnumerator() method was factored out of IEnumerator and placed in IEnumerable. It seems to me that it would make more sense to keep all of the enumerator methods in IEnumerator.
Thanks,
Scott
...
string::iterator it;
for (it = str.begin(); it < str.end(); it++)
cout << *it;
cout << endl;
Why not:
for (int i = 0; i < str.size(); i++)
cout << str[i];
cout << endl;
It seems that string::iterator does not provide range check either. Why should we use string::iterator rather than index?
Thanks.
...
I have an iterator class that loops over an array of objects and lazily loads from the database when it needs to (when it's not loaded into memory). Problem is this is iterating around 200,000 times and I found out from here: http://www.garfieldtech.com/blog/magic-benchmarks that the iterator interface is incredibly slow.
Would anyone k...
Given a list of n distinct items, how can I step through each permutation of the items swapping just one pair of values at a time? (I assume it is possible, it certainly feels like it should be.)
What I'm looking for is an iterator that yields the indices of the next pair of items to swap, such that if iterated n!-1 times it will step t...