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

This commit is contained in:
Xidorn Quan 2015-02-04 19:07:32 +11:00
parent 3f8ebecfd2
commit 901d25c409

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
//