Iterable Class

  • Iterable
  • template <typename T> 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::AggregateFieldListModel, Esri::ArcGISRuntime::AnalysisListModel, Esri::ArcGISRuntime::AnalysisOverlayListModel, Esri::ArcGISRuntime::ArcGISFeatureListModel, Esri::ArcGISRuntime::ArcGISSublayerListModel, Esri::ArcGISRuntime::BasemapListModel, Esri::ArcGISRuntime::BookmarkListModel, Esri::ArcGISRuntime::ClassBreakListModel, Esri::ArcGISRuntime::CodedValueDescriptionListModel, Esri::ArcGISRuntime::DisplayFilterListModel, Esri::ArcGISRuntime::DistanceSymbolRangeListModel, Esri::ArcGISRuntime::ElevationSourceListModel, Esri::ArcGISRuntime::FeatureCollectionTableListModel, Esri::ArcGISRuntime::FeatureTableListModel, Esri::ArcGISRuntime::FieldDescriptionListModel, Esri::ArcGISRuntime::GeometricEffectListModel, Esri::ArcGISRuntime::GeotriggerListModel, Esri::ArcGISRuntime::GraphicListModel, Esri::ArcGISRuntime::GraphicsOverlayListModel, Esri::ArcGISRuntime::ImageOverlayListModel, Esri::ArcGISRuntime::ImmutablePartCollection, Esri::ArcGISRuntime::ImmutablePointCollection, Esri::ArcGISRuntime::ImmutablePortalItemListModel, Esri::ArcGISRuntime::KmlGeometryListModel, Esri::ArcGISRuntime::KmlNodeListModel, Esri::ArcGISRuntime::LabelDefinitionListModel, Esri::ArcGISRuntime::LabelStackSeparatorListModel, Esri::ArcGISRuntime::LayerListModel, Esri::ArcGISRuntime::LegendInfoListModel, Esri::ArcGISRuntime::PartCollection, Esri::ArcGISRuntime::PointCollection, Esri::ArcGISRuntime::PopupAttachmentListModel, Esri::ArcGISRuntime::PopupFieldListModel, Esri::ArcGISRuntime::PopupMediaListModel, Esri::ArcGISRuntime::PortalFolderListModel, Esri::ArcGISRuntime::PortalGroupListModel, Esri::ArcGISRuntime::PortalItemCommentListModel, Esri::ArcGISRuntime::PortalItemListModel, Esri::ArcGISRuntime::PortalPrivilegeListModel, Esri::ArcGISRuntime::PreplannedMapAreaListModel, Esri::ArcGISRuntime::ScaleRangeDisplayFilterListModel, Esri::ArcGISRuntime::SubtypeSublayerListModel, Esri::ArcGISRuntime::SymbolLayerListModel, Esri::ArcGISRuntime::SymbolListModel, Esri::ArcGISRuntime::UniqueValueListModel, Esri::ArcGISRuntime::UtilityAssetTypeListModel, Esri::ArcGISRuntime::UtilityNetworkListModel, Esri::ArcGISRuntime::UtilityPropagatorListModel, Esri::ArcGISRuntime::UtilityTraceFunctionBarrierListModel, Esri::ArcGISRuntime::UtilityTraceFunctionListModel, Esri::ArcGISRuntime::UtilityTraceResultListModel, and Esri::ArcGISRuntime::VectorMarkerSymbolElementListModel

    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.

    See also constEnd and cend.

    Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.

    You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

    Your ArcGIS portal

    Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

    Your ArcGIS Location Platform dashboard

    Manage billing, monitor service usage, and access additional resources.

    Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

    Close