Bug 1126552 part 1 - Make nsTArray support range-based for loops. r=froydnj

--HG--
extra : source : d8670bac983f9bc2b5886af2396d84ec9b4832a7
This commit is contained in:
Xidorn Quan 2015-02-04 19:07:32 +11:00
parent fdcf9f2cbb
commit a8d5780b14

View File

@ -768,6 +768,8 @@ public:
typedef nsTArray_Impl<E, Alloc> self_type;
typedef nsTArrayElementTraits<E> elem_traits;
typedef nsTArray_SafeElementAtHelper<E, self_type> safeelementat_helper_type;
typedef elem_type* iterator;
typedef const elem_type* const_iterator;
using safeelementat_helper_type::SafeElementAt;
using base_type::EmptyHdr;
@ -991,6 +993,14 @@ public:
return SafeElementAt(Length() - 1, aDef);
}
// Methods for range-based for loops.
iterator begin() { return Elements(); }
const_iterator begin() const { return Elements(); }
const_iterator cbegin() const { return begin(); }
iterator end() { return Elements() + Length(); }
const_iterator end() const { return Elements() + Length(); }
const_iterator cend() const { return end(); }
//
// Search methods
//