hey guys..need some help with a project...im basically to implement the following 5 algorithms for a driver program...
here are the algorithms:
accumulate(b, e, t)
equal(b, e, t)
fill(b, e, t) - is to copies the value t into all the elements in the range [b, e).
lexicographic_compare(b, e, b2, e2) - returns true if each element in the range [b, e) is less than the corresponding element in the range [b2, 2e), and false otherwise.
min_element(b, e) - min_element(b, e) returns an iterator pointing to the smallest element in the range [b, e).
this is what I have so far..
can you guys go over it and see if there are mistakes, also i'm not sure how to do the min_element and equal functions so any pointers would help..thanksCode:#ifndef GUARD_myalgorithm_h #define GUARD_myalgorithm_h template <class In, class Out> Out my_copy(In b, In e, Out d) { while (b != e) *d++ = *b++; return d; } template <class In, class Out> int my_accumulate(In b, In e, Out t) { int aaa = *t; while (b != e) { aaa = aaa + *b; b++; } return aaa; } template <class In> bool my_equal(In b, In e, In t) { return true; } template <class In> void my_fill(In b, In e, In t) { while (b != e) { *b = *t; b++; } } template <class In> bool my_lexicographic_compare(In b, In e, In b2, In e2) { while (b != e && b2 != e2) { for (b; b != e; b++) if (*b >= *b2) return false; if (*b < *b2) } template <class In> iter my_min_element(In b, In e) { return; } #endif



LinkBack URL
About LinkBacks



