Sounds good! +1 from me.

Bike shedding:

- Make Range() and ReverseRange() templates, so you can use them with any type 
that supports the appropriate operators. This also implies removing ‘Integer’ 
from their names, I think.

- It’d be nice to add a constructor that supports specifying both the beginning 
and the end points, and another constructor that further supports specifying a 
stride.

- Seth


> On Jan 27, 2015, at 6:24 PM, Xidorn Quan <quanxunz...@gmail.com> wrote:
> 
> I asked a question in #developers that what is the best way to reversely
> iterating nsTArray, and there are some suggestions:
> 
> <tbsaunde> uint32_t count = array.Length(); for (uint32_t i = length - 1; i
> < length; i--)
> <smaug> iterate from length() to 1 and index using i - 1
> <jcranmer> for (uint32_t i = array.Length(); i-- > 0; ) { }
> 
> tbsaunde's method should work fine, but not intuitive. smaug's looks fine
> to me, but could cause some problem if I use i instead of i-1 by mistake.
> jcranmer's... I don't think it is a good idea, anyway. None of them looks
> prefect to me.
> 
> 
> As we have supported range-based for loop in our code, I purpose that we
> have something like ReverseIntegerRange, and use this with range-based loop
> to iterate the index. So we can use, for example: for (auto i :
> ReverseIntegerRange(array.Length()))
> 
> Maybe we can also add IntegerRange to benefit from the integer type
> dedution.
> 
> How does it sound?
> 
> - Xidorn
> _______________________________________________
> dev-platform mailing list
> dev-platform@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform

_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to