Skip To Content ArcGIS for Developers Sign In Dashboard

Iterable Class

(Esri::ArcGISRuntime::Iterable)

Helper class to allow collection types to support iterators. More...

Header: #include <Iterable>
Since: Esri::ArcGISRuntime 100.5
Inherited By:

Esri::ArcGISRuntime::AnalysisListModel, Esri::ArcGISRuntime::AnalysisOverlayListModel, Esri::ArcGISRuntime::ArcGISFeatureListModel, Esri::ArcGISRuntime::ArcGISSublayerListModel, Esri::ArcGISRuntime::BasemapListModel, Esri::ArcGISRuntime::BookmarkListModel, Esri::ArcGISRuntime::ClassBreakListModel, Esri::ArcGISRuntime::DistanceSymbolRangeListModel, Esri::ArcGISRuntime::ElevationSourceListModel, Esri::ArcGISRuntime::FeatureCollectionTableListModel, Esri::ArcGISRuntime::FeatureTableListModel, Esri::ArcGISRuntime::GeometricEffectListModel, Esri::ArcGISRuntime::GraphicListModel, Esri::ArcGISRuntime::GraphicsOverlayListModel, Esri::ArcGISRuntime::ImmutablePartCollection, Esri::ArcGISRuntime::ImmutablePointCollection, Esri::ArcGISRuntime::ImmutablePortalItemListModel, Esri::ArcGISRuntime::KmlGeometryListModel, Esri::ArcGISRuntime::KmlNodeListModel, Esri::ArcGISRuntime::LabelDefinitionListModel, Esri::ArcGISRuntime::LayerListModel, Esri::ArcGISRuntime::LegendInfoListModel, Esri::ArcGISRuntime::PartCollection, Esri::ArcGISRuntime::PointCollection, Esri::ArcGISRuntime::PopupAttachmentListModel, Esri::ArcGISRuntime::PortalFolderListModel, Esri::ArcGISRuntime::PortalGroupListModel, Esri::ArcGISRuntime::PortalItemCommentListModel, Esri::ArcGISRuntime::PortalItemListModel, Esri::ArcGISRuntime::PortalPrivilegeListModel, Esri::ArcGISRuntime::PreplannedMapAreaListModel, Esri::ArcGISRuntime::SymbolLayerListModel, Esri::ArcGISRuntime::SymbolListModel, Esri::ArcGISRuntime::UniqueValueListModel, Esri::ArcGISRuntime::UtilityTraceResultListModel, and Esri::ArcGISRuntime::VectorMarkerSymbolElementListModel

Public Types

class const_iterator
class iterator

Public Functions

iterator begin()
const_iterator begin() const
const_iterator cbegin() const
const_iterator cend() const
const_iterator constBegin() const
const_iterator constEnd() const
iterator end()
const_iterator end() const

Detailed Description

Helper class to allow collection types to support iterators.

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

iterator Iterable::begin()

Returns a non-const iterator to the first element of the collection.

const_iterator Iterable::begin() const

Returns a const iterator to the first element of the collection.

See also constBegin and cbegin.

const_iterator Iterable::cbegin() const

Returns a const iterator to the first element of the collection.

See also constBegin.

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 doesn't point to a valid object.

See also constEnd.

const_iterator Iterable::constBegin() const

Returns a const iterator to the first element of the collection.

See also cbegin.

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 doesn't point to a valid object.

See also cend.

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 doesn't point to a valid object.

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 doesn't point to a valid object.

See also constEnd and cend.


Feedback on this topic?