![]() |
Blitz Bugs : |
From: Julian Cummings (cummings_at_[hidden])
Date: 2004-09-17 12:34:39
I have committed some changes to the blitz cvs repository last night
that address this inconsistent behavior with the blitz Array iterators.
With these changes, you will find that the begin and end iterators are
equal for a blitz Array that is made with the default constructor or is
constructed with zero size or is resized to zero size using the resize()
method. Thanks for pointing out this problem.
Regards, Julian C.
N Smethurst wrote:
>Hello there
>
>I discovered a bug in Array. When an array is initialised to zero size, the
>begin() iterator does not equal the end() interator.
>
>For example:
> Array<float, 1> vec(0);
> Array<float, 1>::iterator begin = vec.begin();
> Array<float, 1>::iterator end = vec.end();
>
> cout << "begin == end : " << (begin == end) << endl;
> cout << "begin != end : " << (begin != end) << endl;
>
>This gives:
> begin == end : 0
> begin != end : 1
>
>However, when an array is created then resized, there is no bug:
> Array<float, 1> vec;
> vec.resize(0);
> Array<float, 1>::iterator begin = vec.begin();
> Array<float, 1>::iterator end = vec.end();
> cout << "begin == end : " << (begin == end) << endl;
> cout << "begin != end : " << (begin != end) << endl;
>
>This gives:
> begin == end : 1
> begin != end : 0
>
>The behaviour is the same with higher dimension arrays:
> Array<float, 2> mat(0, 0);
> // begin != end
> Array<float, 2>::iterator begin = mat.begin();
> Array<float, 2>::iterator end = mat.end();
>
> Array<float, 2> mat1;
> mat1.resize(0, 0);
> // begin1 == end1
> Array<float, 2>::iterator begin1 = mat1.begin();
> Array<float, 2>::iterator end1 = mat1.end();
>
>Regards
>
>Nicholas
>_______________________________________________
>Blitz-bugs mailing list
>Blitz-bugs_at_[hidden]
>http://www.oonumerics.org/mailman/listinfo.cgi/blitz-bugs
>
>
-- Dr. Julian C. Cummings E-mail: cummings_at_[hidden] California Institute of Technology Phone: 626-395-2543 1200 E. California Blvd., Mail Code 158-79 Fax: 626-584-5917 Pasadena, CA 91125