Loading...

lilypond-devel@gnu.org

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: Gets vertical skylines from grob stencils (issue 5626052) Joe Neeman Fri Feb 17 01:00:10 2012

On Thu, Feb 16, 2012 at 11:42 PM, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:

> On Feb 16, 2012, at 9:31 PM, Joe Neeman wrote:
>
>
> On Thu, Feb 16, 2012 at 3:14 AM, [EMAIL PROTECTED] <
> [EMAIL PROTECTED]> wrote:
>
>>
>> On Feb 16, 2012, at 11:40 AM, [EMAIL PROTECTED] wrote:
>>
>> >
>> > The buildings are in increasing order, so this should work:
>> >
>> > Real last_end = -infinity_f;
>> > for (...)
>> >  {
>> >    if (i->y_intercept_ > -infinity_f)
>> >      return last_end;
>> >    last_end = i->end_;
>> >  }
>> > return infinity_f;
>> >
>>
>> Hey,
>>
>> I know this is a lame question, but how would one write the reverse
>> iterator.  I tried using reverse_iterator and g++ barfs, and I can't use
>> the same syntax one would use in a for loop w/ a vector.
>>
>
> That's a bit hard to say without knowing what you tried... did you use
> rbegin() and rend()?
>
>
> Yup - I more or less copied the example from cplusplus.com.  As an
> experiment, try writing a reverse iterator in that file to the tune of:
>
>   for (list<Building>::reverse_iterator i = buildings_.rbegin (); i !=
> buildings_.rend (); ++i)
>
> Anywhere in a function.  You should see a compiler error.
>

How about -- instead of ++?

I fixed it, though, by reversing a copy of the list and iterating forward
> through it.
>

That's still linear time, though...
_______________________________________________
lilypond-devel mailing list
[EMAIL PROTECTED]
https://lists.gnu.org/mailman/listinfo/lilypond-devel