Helper class to allow collection types to support iterators. More...
Public Functions
Iterable() | |
virtual | ~Iterable() |
Esri::ArcGISRuntime::Iterable::iterator | begin() |
Esri::ArcGISRuntime::Iterable::const_iterator | begin() const |
Esri::ArcGISRuntime::Iterable::const_iterator | cbegin() const |
Esri::ArcGISRuntime::Iterable::const_iterator | cend() const |
Esri::ArcGISRuntime::Iterable::const_iterator | constBegin() const |
Esri::ArcGISRuntime::Iterable::const_iterator | constEnd() const |
Esri::ArcGISRuntime::Iterable::iterator | end() |
Esri::ArcGISRuntime::Iterable::const_iterator | end() const |
Detailed Description
Any class that inherits Iterable will support C++11 range-for loops as well as anything else that works with forward iterators.
Iterable types implement std::forward_iterator_tag functionality.
The purpose of this class is to allow certain C++11 and newer features to work with exising classes in the API. For example, you can iterate over the map's layers:
for (auto* layer : *(map->operationalLayers())) { ... }
In addition to the C++11 range-based for looping, you can also use std::for_each. For example:
QStringList layerNames; std::for_each(operationalLayers->cbegin(), operationalLayers->cend(), [&layerNames](Layer* layer) { // gather all the names of the layers layerNames.append(layer->name()); });
Another example is searching for a layer with a specific name:
auto* opLayers = scene->operationalLayers(); auto it = std::find_if(opLayers->constBegin(), opLayers->constEnd(), [](Layer* l) { return l->name() == "MyLayer"; }); if (it == opLayers->constEnd()) return; // no match // we found a match Layer* match = *it;
Iterable also works with value objects. For example, you can iterate over the points in an ImmutablePointCollection:
const ImmutablePointCollection points = getPoints(); for (const Point& p : points) { // do stuff with the points... }
Member Function Documentation
Iterable::Iterable()
Default constructor.
[virtual]
Iterable::~Iterable()
Destructor.
Esri::ArcGISRuntime::Iterable::iterator Iterable::begin()
Returns a non-const iterator to the first element of the collection.
Esri::ArcGISRuntime::Iterable::const_iterator Iterable::begin() const
Returns a const iterator to the first element of the collection.
See also constBegin and cbegin.
Esri::ArcGISRuntime::Iterable::const_iterator Iterable::cbegin() const
Returns a const iterator to the first element of the collection.
See also constBegin.
Esri::ArcGISRuntime::Iterable::const_iterator Iterable::cend() const
Returns a const iterator one past the last element in the collection.
The cend
iterator should not be dereferenced as it does not point to a valid object.
See also constEnd.
Esri::ArcGISRuntime::Iterable::const_iterator Iterable::constBegin () const
Returns a const iterator to the first element of the collection.
See also cbegin.
Esri::ArcGISRuntime::Iterable::const_iterator Iterable::constEnd () const
Returns a const iterator one past the last element in the collection.
The constEnd
iterator should not be dereferenced as it does not point to a valid object.
See also cend.
Esri::ArcGISRuntime::Iterable::iterator Iterable::end()
Returns a non-const iterator one past the last element in the collection.
The end
iterator should not be dereferenced as it does not point to a valid object.
Esri::ArcGISRuntime::Iterable::const_iterator Iterable::end() const
Returns a const iterator one past the last element in the collection.
The end
iterator should not be dereferenced as it does not point to a valid object.