    

 ## On this page

  

 

 # Class ansys::dpf::Collection

 Last update: 25.03.2026 

<a id="classansys-dpf-collection"></a>

![](https://img.shields.io/badge/language-C%2B%2B-blue "C++")![](https://img.shields.io/badge/-public-brightgreen "public")

Contains a group of entries of same type. The AnyCollection is designed as a set of entries ordered through labels and ids. Labels identify how the entries are filtered.

**See also**: [Any](classansys-dpf-any.md#classansys-dpf-any)

**Template parameters**:

- typename DataT

**Inherits from**:

- ansys::dpf::CollectionBase

## Members

- [add](classansys-dpf-collection.md#classansys-dpf-collection-1afc36f19a39c1909d695f80ff22e0eeb0)
- [addLabel](classansys-dpf-collectionbase.md#classansys-dpf-collectionbase-1a623a0b168512a4621fb7af8084f9872b)
- [addLabel](classansys-dpf-collectionbase.md#classansys-dpf-collectionbase-1ac6ce7bc876d6a94a97996d5febba5116)
- [addLabels](classansys-dpf-collectionbase.md#classansys-dpf-collectionbase-1ae97480559c14c59e830559582c1f2cd5)
- [at](classansys-dpf-collection.md#classansys-dpf-collection-1ad69525d9782d30f290d3f250576aa3d1)
- [at](classansys-dpf-collection.md#classansys-dpf-collection-1ab5a9fa1e466cf9e36ae26d5419768c6d)
- [callAPI](classansys-dpf-dpftypes.md#classansys-dpf-dpftypes-1aea34d37e0c080126eff70db34bf46597)
- [Collection](classansys-dpf-collection.md#classansys-dpf-collection-1a9d8754d9166c282d4b43863472ae1171)
- [Collection](classansys-dpf-collection.md#classansys-dpf-collection-1ad71430265c0f1891bd415082f28b0d36)
- [Collection](classansys-dpf-collection.md#classansys-dpf-collection-1ac67a41f31cce324a441d456ccfadbe1f)
- [Collection](classansys-dpf-collection.md#classansys-dpf-collection-1ac50cf5a210cd3d391525a18c3abefca3)
- [Collection](classansys-dpf-collection.md#classansys-dpf-collection-1ad86df2fa4903a8891826f44b195dc344)
- [Collection](classansys-dpf-collection.md#classansys-dpf-collection-1acbbfa8b0684530e727c378eeb5c8d46f)
- [Collection](classansys-dpf-collection.md#classansys-dpf-collection-1a37fdf6aad0fc6b3ebcb39c1a03f78429)
- [createSubCollection](classansys-dpf-collection.md#classansys-dpf-collection-1a027dbff1f436f77a4857899ef78e6b15)
- [describe](classansys-dpf-dpftypes.md#classansys-dpf-dpftypes-1a9977945710983bc03d2940fa007847b2)
- [empty](classansys-dpf-dpftypes.md#classansys-dpf-dpftypes-1a39cd546c42518e2332be8f287db95459)
- [emptyCollection](classansys-dpf-collection.md#classansys-dpf-collection-1a545436af4a3a2c404796ab128ad06890)
- [getClient](classansys-dpf-dpftypes.md#classansys-dpf-dpftypes-1a968afd9daa0b0f13b65a2ac61369d73a)
- [getEntries](classansys-dpf-collection.md#classansys-dpf-collection-1a04b6d0e9e544f69be27dcfc3c79d5537)
- [getEntriesIndices](classansys-dpf-collection.md#classansys-dpf-collection-1a8e724ea1528d5244ffb4860e67a39698)
- [getEntry](classansys-dpf-collection.md#classansys-dpf-collection-1a6dea8d438075e38470c4b9a46ca9ec07)
- [getLabelSpace](classansys-dpf-collectionbase.md#classansys-dpf-collectionbase-1a66d62492d07889a95a5d10f9d827cd11)
- [getMatchingEntitiesIndices](classansys-dpf-collection.md#classansys-dpf-collection-1ab36f06c3b91692697f5c0a65dde0d33e)
- [getMatchingEntity](classansys-dpf-collection.md#classansys-dpf-collection-1a1ce412d54e6e0aa61a60aa86b344acae)
- [getSizeFor](classansys-dpf-collectionbase.md#classansys-dpf-collectionbase-1aab65999d65acb4eab6aa7375266e5456)
- [hasBeenMovedLocally](classansys-dpf-dpftypes.md#classansys-dpf-dpftypes-1a1a5634202c15404b6b24e8f50e51cb66)
- [hasInternalObject](classansys-dpf-dpftypes.md#classansys-dpf-dpftypes-1ae198f89868d85c7db6dc1a934a1d3c15)
- [hasLabel](classansys-dpf-collectionbase.md#classansys-dpf-collectionbase-1a82ac9433fd3963b37b07989ef05de331)
- [id](classansys-dpf-collectionbase.md#classansys-dpf-collectionbase-1a5e8d2dd8b9b6cf273985ce3ead392830)
- [isOnCommonAPI](classansys-dpf-dpftypes.md#classansys-dpf-dpftypes-1a9f9789ff61cc9d400a2a344830706b73)
- [isSameObject](classansys-dpf-dpftypes.md#classansys-dpf-dpftypes-1aa64d5f8fcd7d85ad6ebf708494dbefd7)
- [labels](classansys-dpf-collectionbase.md#classansys-dpf-collectionbase-1a2c1bb3718e1a96d3f40b64794eb25f91)
- [labelScoping](classansys-dpf-collectionbase.md#classansys-dpf-collectionbase-1ac61aef82ffe249c95dd10cf40de7c910)
- [name](classansys-dpf-collectionbase.md#classansys-dpf-collectionbase-1a691450ab7c89db80f39d6bb2d10eace4)
- [operator=](classansys-dpf-collection.md#classansys-dpf-collection-1aee0b20090571d8d9218bc48ca542b6c3)
- [operator=](classansys-dpf-collection.md#classansys-dpf-collection-1a782d90e147798e3e81b7b5b331fa8eb0)
- [operator\[\]](classansys-dpf-collection.md#classansys-dpf-collection-1a65acae9c8be4c94b19a82c28ae4419f7)
- [reserve](classansys-dpf-collectionbase.md#classansys-dpf-collectionbase-1a98ab98c9a6b91b886fd600ed7d9e633b)
- [resize](classansys-dpf-collectionbase.md#classansys-dpf-collectionbase-1ac88664d3e1d22abb74a95c8223b1e771)
- [setId](classansys-dpf-collectionbase.md#classansys-dpf-collectionbase-1a93ebbfe9396dd1c4f447e799db6cbf3b)
- [setName](classansys-dpf-collectionbase.md#classansys-dpf-collectionbase-1a44394f964c6130dcbaed446cec3b0197)
- [setSupport](classansys-dpf-collectionbase.md#classansys-dpf-collectionbase-1ae6f7683496d153ed944856d42b97dc82)
- [setSupport](classansys-dpf-collectionbase.md#classansys-dpf-collectionbase-1ada2a037068417557fd7d410577a7fbb9)
- [size](classansys-dpf-collectionbase.md#classansys-dpf-collectionbase-1a69e6878d2d691807f8a45ddfbda42f9e)
- [support](classansys-dpf-collectionbase.md#classansys-dpf-collectionbase-1a9830a03b992af391bf03acad90eac372)
- [update](classansys-dpf-collection.md#classansys-dpf-collection-1a2ee31954dd991137fe535f3a3b3ffeed)
- [~Collection](classansys-dpf-collection.md#classansys-dpf-collection-1a6b3beab75f7875ebe3f39e9844ee5277)
- [~CollectionBase](classansys-dpf-collectionbase.md#classansys-dpf-collectionbase-1a99e04439d35f26b89f4d66813d74035b)
- [~DpfTypes](classansys-dpf-dpftypes.md#classansys-dpf-dpftypes-1ab7c83b6ea160c2b115e056f6c312112f)

## Friends

## Public functions

<a id="classansys-dpf-collection-1a9d8754d9166c282d4b43863472ae1171"></a>

### Function Collection

![](https://img.shields.io/badge/-public-brightgreen "public")

```cpp
ansys::dpf::Collection< DataT >::Collection()

```

**Return type**:

<a id="classansys-dpf-collection-1a6b3beab75f7875ebe3f39e9844ee5277"></a>

### Function ~Collection

![](https://img.shields.io/badge/-public-brightgreen "public")

```cpp
virtual ansys::dpf::Collection< DataT >::~Collection()=default

```

**Return type**:

<a id="classansys-dpf-collection-1ad71430265c0f1891bd415082f28b0d36"></a>

### Function Collection

![](https://img.shields.io/badge/-public-brightgreen "public")

```cpp
ansys::dpf::Collection< DataT >::Collection(Collection< DataT > const &)

```

**Parameters**:

- rhsCollection&lt; DataT &gt; const &amp;

**Return type**:

<a id="classansys-dpf-collection-1ac67a41f31cce324a441d456ccfadbe1f"></a>

### Function Collection

![](https://img.shields.io/badge/-public-brightgreen "public")

```cpp
ansys::dpf::Collection< DataT >::Collection(Collection< DataT > &&) noexcept

```

**Parameters**:

- rhsCollection&lt; DataT &gt; &amp;&amp;

**Return type**:

<a id="classansys-dpf-collection-1ac50cf5a210cd3d391525a18c3abefca3"></a>

### Function Collection

![](https://img.shields.io/badge/-public-brightgreen "public")

```cpp
ansys::dpf::Collection< DataT >::Collection(std::vector< std::string > const &labels)

```

Create container for a group of entries with the given labels.

**Parameters**:

- std::vector&lt; std::string &gt; const &amp; **labels**: \[in\] Labels for group of entries.

**Return type**:

<a id="classansys-dpf-collection-1ad86df2fa4903a8891826f44b195dc344"></a>

### Function Collection

![](https://img.shields.io/badge/-public-brightgreen "public")

```cpp
ansys::dpf::Collection< DataT >::Collection(Client const *const client)

```

Create a new collection on a server.

**Parameters**:

- [Client](classansys-dpf-client.md#classansys-dpf-client) const \*const **client**: \[in\] [Client](classansys-dpf-client.md#classansys-dpf-client) instance designating the IP, port and protocol to use.

**Return type**:

<a id="classansys-dpf-collection-1acbbfa8b0684530e727c378eeb5c8d46f"></a>

### Function Collection

![](https://img.shields.io/badge/-public-brightgreen "public")

```cpp
ansys::dpf::Collection< DataT >::Collection(Client const *const client, std::vector< std::string > const &labels)

```

Create a collection with the given labels on a server.

**Parameters**:

- [Client](classansys-dpf-client.md#classansys-dpf-client) const \*const **client**: \[in\] [Client](classansys-dpf-client.md#classansys-dpf-client) instance designating the IP, port and protocol to use.
- std::vector&lt; std::string &gt; const &amp; **labels**: \[in\] Labels for meshes.

**Return type**:

<a id="classansys-dpf-collection-1a37fdf6aad0fc6b3ebcb39c1a03f78429"></a>

### Function Collection

![](https://img.shields.io/badge/-public-brightgreen "public")

```cpp
ansys::dpf::Collection< DataT >::Collection(int id, Client const *const client)

```

Retrieve an existing instance of [Collection](classansys-dpf-collection.md#classansys-dpf-collection) on a server.

**Parameters**:

- int **id**: \[in\] Id of the [Collection](classansys-dpf-collection.md#classansys-dpf-collection) object on the server's database.
- [Client](classansys-dpf-client.md#classansys-dpf-client) const \*const **client**: \[in\] [Client](classansys-dpf-client.md#classansys-dpf-client) instance designating the IP, port and protocol to use.

**Return type**:

<a id="classansys-dpf-collection-1aee0b20090571d8d9218bc48ca542b6c3"></a>

### Function operator=

![](https://img.shields.io/badge/-public-brightgreen "public")

```cpp
Collection< DataT > & ansys::dpf::Collection< DataT >::operator=(Collection< DataT > const &)

```

**Parameters**:

- rhsCollection&lt; DataT &gt; const &amp;

**Return type**: Collection &amp;

<a id="classansys-dpf-collection-1a782d90e147798e3e81b7b5b331fa8eb0"></a>

### Function operator=

![](https://img.shields.io/badge/-public-brightgreen "public")

```cpp
Collection< DataT > & ansys::dpf::Collection< DataT >::operator=(Collection< DataT > &&) noexcept

```

**Parameters**:

- rhsCollection&lt; DataT &gt; &amp;&amp;

**Return type**: Collection &amp;

<a id="classansys-dpf-collection-1a65acae9c8be4c94b19a82c28ae4419f7"></a>

### Function operator\[\]

![](https://img.shields.io/badge/-public-brightgreen "public")

```cpp
DataT ansys::dpf::Collection< DataT >::operator[](dp_int index)

```

**Returns**:

[Any](classansys-dpf-any.md#classansys-dpf-any) for given index.

**Parameters**:

- [dp\_int](namespaceansys-dpf.md#namespaceansys-dpf-1a60d181a1f9d29cc7cc38b25dac4401f0) **index**: \[in\] Index of entries within container.

**Return type**: DataT

<a id="classansys-dpf-collection-1ad69525d9782d30f290d3f250576aa3d1"></a>

### Function at

![](https://img.shields.io/badge/-public-brightgreen "public")

```cpp
DataT ansys::dpf::Collection< DataT >::at(dp_index index)

```

**Returns**:

DataT for given index.

**Parameters**:

- [dp\_index](namespaceansys-dpf.md#namespaceansys-dpf-1a417548d1b705a9ba54ba9429afe68920) **index**: \[in\] Index of [Any](classansys-dpf-any.md#classansys-dpf-any) to get.

**Return type**: DataT

<a id="classansys-dpf-collection-1ab5a9fa1e466cf9e36ae26d5419768c6d"></a>

### Function at

![](https://img.shields.io/badge/-public-brightgreen "public")![](https://img.shields.io/badge/-const-lightblue "const")

```cpp
const DataT ansys::dpf::Collection< DataT >::at(dp_index index) const

```

**Returns**:

DataT for given index.

**Parameters**:

- [dp\_index](namespaceansys-dpf.md#namespaceansys-dpf-1a417548d1b705a9ba54ba9429afe68920) **index**: \[in\] Index of [Any](classansys-dpf-any.md#classansys-dpf-any) to get.

**Return type**: const DataT

<a id="classansys-dpf-collection-1a2ee31954dd991137fe535f3a3b3ffeed"></a>

### Function update

![](https://img.shields.io/badge/-public-brightgreen "public")

```cpp
void ansys::dpf::Collection< DataT >::update(DataT &f, dp_index index)

```

Update a [Any](classansys-dpf-any.md#classansys-dpf-any) at index.

**Parameters**:

- DataT &amp; **f**: \[in\] New [Any](classansys-dpf-any.md#classansys-dpf-any).
- [dp\_index](namespaceansys-dpf.md#namespaceansys-dpf-1a417548d1b705a9ba54ba9429afe68920) **index**: \[in\] Index of [Any](classansys-dpf-any.md#classansys-dpf-any) to update.

**Return type**: void

<a id="classansys-dpf-collection-1afc36f19a39c1909d695f80ff22e0eeb0"></a>

### Function add

![](https://img.shields.io/badge/-public-brightgreen "public")

```cpp
void ansys::dpf::Collection< DataT >::add(LabelSpace const &labels, DataT const &f, bool can_replace=true)

```

Add [Any](classansys-dpf-any.md#classansys-dpf-any) with given label space.

**Parameters**:

- [LabelSpace](classansys-dpf-labelspace.md#classansys-dpf-labelspace) const &amp; **labels**: \[in\] [Label](structansys-dpf-label.md#structansys-dpf-label) space for [Any](classansys-dpf-any.md#classansys-dpf-any).
- DataT const &amp; **f**: \[in\] [Any](classansys-dpf-any.md#classansys-dpf-any) to add.
- bool **can\_replace** = true : \[in\] if can\_replace is false, then, the entity is pushed back without checking if the label space already exists, available starting with 2024R2.

**Return type**: void

<a id="classansys-dpf-collection-1a04b6d0e9e544f69be27dcfc3c79d5537"></a>

### Function getEntries

![](https://img.shields.io/badge/-public-brightgreen "public")![](https://img.shields.io/badge/-const-lightblue "const")

```cpp
std::vector< DataT > ansys::dpf::Collection< DataT >::getEntries(LabelSpace const &label_space) const

```

**Returns**:

Vector of entries for given label space.

**Parameters**:

- [LabelSpace](classansys-dpf-labelspace.md#classansys-dpf-labelspace) const &amp; **label\_space**: \[in\] [Label](structansys-dpf-label.md#structansys-dpf-label) space for which to get entries.

**Return type**: std::vector&lt; DataT &gt;

<a id="classansys-dpf-collection-1a6dea8d438075e38470c4b9a46ca9ec07"></a>

### Function getEntry

![](https://img.shields.io/badge/-public-brightgreen "public")![](https://img.shields.io/badge/-const-lightblue "const")

```cpp
DataT ansys::dpf::Collection< DataT >::getEntry(LabelSpace const &label_space) const

```

**Returns**:

First [Any](classansys-dpf-any.md#classansys-dpf-any) for given label space.

**Parameters**:

- [LabelSpace](classansys-dpf-labelspace.md#classansys-dpf-labelspace) const &amp; **label\_space**: \[in\] [Label](structansys-dpf-label.md#structansys-dpf-label) space for which to get [Any](classansys-dpf-any.md#classansys-dpf-any).

**Return type**: DataT

<a id="classansys-dpf-collection-1a8e724ea1528d5244ffb4860e67a39698"></a>

### Function getEntriesIndices

![](https://img.shields.io/badge/-public-brightgreen "public")![](https://img.shields.io/badge/-const-lightblue "const")

```cpp
std::vector< dp_index > ansys::dpf::Collection< DataT >::getEntriesIndices(LabelSpace const &lab_space) const

```

**Parameters**:

- [LabelSpace](classansys-dpf-labelspace.md#classansys-dpf-labelspace) const &amp; **lab\_space**

**Return type**: std::vector&lt; [dp\_index](namespaceansys-dpf.md#namespaceansys-dpf-1a417548d1b705a9ba54ba9429afe68920) &gt;

<a id="classansys-dpf-collection-1ab36f06c3b91692697f5c0a65dde0d33e"></a>

### Function getMatchingEntitiesIndices

![](https://img.shields.io/badge/-public-brightgreen "public")![](https://img.shields.io/badge/-const-lightblue "const")

```cpp
DpfVector< int > ansys::dpf::Collection< DataT >::getMatchingEntitiesIndices(LabelSpace const &label_space) const

```

**Returns**:

Vector of matching entries to the given label space.

**Parameters**:

- [LabelSpace](classansys-dpf-labelspace.md#classansys-dpf-labelspace) const &amp; **label\_space**: \[in\] [Label](structansys-dpf-label.md#structansys-dpf-label) space for which to get entries.

**Return type**: [DpfVector](classansys-dpf-dpfvector.md#classansys-dpf-dpfvector)&lt; [dp\_index](namespaceansys-dpf.md#namespaceansys-dpf-1a417548d1b705a9ba54ba9429afe68920) &gt;

<a id="classansys-dpf-collection-1a1ce412d54e6e0aa61a60aa86b344acae"></a>

### Function getMatchingEntity

![](https://img.shields.io/badge/-public-brightgreen "public")![](https://img.shields.io/badge/-const-lightblue "const")

```cpp
DataT ansys::dpf::Collection< DataT >::getMatchingEntity(LabelSpace const &label_space) const

```

**Returns**:

First matching [Any](classansys-dpf-any.md#classansys-dpf-any) for given label space.

**Parameters**:

- [LabelSpace](classansys-dpf-labelspace.md#classansys-dpf-labelspace) const &amp; **label\_space**: \[in\] [Label](structansys-dpf-label.md#structansys-dpf-label) space for which to get [Any](classansys-dpf-any.md#classansys-dpf-any).

**Return type**: DataT

<a id="classansys-dpf-collection-1a027dbff1f436f77a4857899ef78e6b15"></a>

### Function createSubCollection

![](https://img.shields.io/badge/-public-brightgreen "public")![](https://img.shields.io/badge/-const-lightblue "const")

```cpp
Collection< DataT > ansys::dpf::Collection< DataT >::createSubCollection(LabelSpace const &lab_space) const

```

create a [Collection](classansys-dpf-collection.md#classansys-dpf-collection) with all the entries corresponding to the label space in input

**Parameters**:

- [LabelSpace](classansys-dpf-labelspace.md#classansys-dpf-labelspace) const &amp; **lab\_space**

**Return type**: Collection&lt; DataT &gt;

## Public static functions

<a id="classansys-dpf-collection-1a545436af4a3a2c404796ab128ad06890"></a>

### Function emptyCollection

![](https://img.shields.io/badge/-public-brightgreen "public")![](https://img.shields.io/badge/-static-lightgrey "static")

```cpp
Collection< DataT > ansys::dpf::Collection< DataT >::emptyCollection()

```

Create an empty container. **Returns**:

Empty container.

**Return type**: Collection&lt; DataT &gt;