# ecs::SparseArray

[More...](#detailed-description)

`#include <SparseArray.hpp>`

## Public Types

|                                                                                                                                                                        | Name                                                                                                                                                                    |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| using std::optional< Component >                                                                                                                                       | [**valueType**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-valuetype)                   |
| using [valueType](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-valuetype) &              | [**referenceType**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-referencetype)           |
| using [valueType](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-valuetype) const &        | [**constReferenceType**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-constreferencetype) |
| using std::vector< [valueType](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-valuetype) > | [**container**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-container)                   |
| using typename container::size\_type                                                                                                                                   | [**sizeType**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-sizetype)                     |
| using typename container::iterator                                                                                                                                     | [**iterator**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-iterator)                     |
| using typename container::const\_iterator                                                                                                                              | [**constIterator**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-constiterator)           |

## Public Functions

|                                                                                                                                                                                                                | Name                                                                                                                                                                                                                                                                                                                             |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|                                                                                                                                                                                                                | [**SparseArray**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#function-sparsearray)()                                                                                                                                                                   |
|                                                                                                                                                                                                                | [**SparseArray**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#function-sparsearray)([SparseArray](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md) const & other)                  |
|                                                                                                                                                                                                                | [**SparseArray**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#function-sparsearray)([SparseArray](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md) && other)                       |
|                                                                                                                                                                                                                | [**\~SparseArray**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#function-~sparsearray)() =default                                                                                                                                                       |
| [SparseArray](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md) &                                                                          | [**operator=**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#function-operator=)([SparseArray](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md) const & other)                      |
| [SparseArray](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md) &                                                                          | [**operator=**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#function-operator=)([SparseArray](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md) && other)                           |
| [referenceType](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-referencetype)                                                      | [**operator\[\]**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#function-operator\[])(size\_t idx)                                                                                                                                                       |
| [constReferenceType](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-constreferencetype)                                            | [**operator\[\]**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#function-operator\[])(size\_t idx) const                                                                                                                                                 |
| [iterator](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-iterator)                                                                | [**begin**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#function-begin)()                                                                                                                                                                               |
| [constIterator](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-constiterator)                                                      | [**begin**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#function-begin)() const                                                                                                                                                                         |
| [constIterator](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-constiterator)                                                      | [**cBegin**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#function-cbegin)() const                                                                                                                                                                       |
| [iterator](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-iterator)                                                                | [**end**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#function-end)()                                                                                                                                                                                   |
| [constIterator](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-constiterator)                                                      | [**end**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#function-end)() const                                                                                                                                                                             |
| [constIterator](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-constiterator)                                                      | [**cEnd**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#function-cend)() const                                                                                                                                                                           |
| [sizeType](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-sizetype)                                                                | [**size**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#function-size)() const                                                                                                                                                                           |
| [referenceType](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-referencetype)                                                      | [**insertAt**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#function-insertat)([sizeType](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-sizetype) pos, Component const & c) |
| [referenceType](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-referencetype)                                                      | [**insertAt**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#function-insertat)([sizeType](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-sizetype) pos, Component && c)      |
| <p>template &#x3C;class... Params><br><a href="https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-referencetype">referenceType</a></p> | [**emplaceAt**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#function-emplaceat)([sizeType](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-sizetype) pos, Params &&... args) |
| void                                                                                                                                                                                                           | [**erase**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#function-erase)([sizeType](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-sizetype) pos)                            |
| [sizeType](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-sizetype)                                                                | [**getIndex**](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#function-getindex)([valueType](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md#using-valuetype) const & c) const        |

## Detailed Description

```cpp
template <typename Component >
class ecs::SparseArray;
```

**Template Parameters**:

* **Component** The type of component used as with template

[SparseArray](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md) class is the component container of the ecs.

This can be quite useful to store components that are defined for most entities, because you don't have to store the entity ID alongside the component.

## Public Types Documentation

### using valueType

```cpp
using ecs::SparseArray< Component >::valueType =  std::optional<Component>;
```

### using referenceType

```cpp
using ecs::SparseArray< Component >::referenceType =  valueType &;
```

### using constReferenceType

```cpp
using ecs::SparseArray< Component >::constReferenceType =  valueType const &;
```

### using container

```cpp
using ecs::SparseArray< Component >::container =  std::vector<valueType>;
```

### using sizeType

```cpp
using ecs::SparseArray< Component >::sizeType =  typename container::size_type;
```

### using iterator

```cpp
using ecs::SparseArray< Component >::iterator =  typename container::iterator;
```

### using constIterator

```cpp
using ecs::SparseArray< Component >::constIterator =  typename container::const_iterator;
```

## Public Functions Documentation

### function SparseArray

```cpp
inline SparseArray()
```

Default constructor & destructor of the [SparseArray](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md) class

### function SparseArray

```cpp
inline SparseArray(
    SparseArray const & other
)
```

### function SparseArray

```cpp
inline SparseArray(
    SparseArray && other
)
```

### function \~SparseArray

```cpp
~SparseArray() =default
```

### function operator=

```cpp
inline SparseArray & operator=(
    SparseArray const & other
)
```

**Parameters**:

* **other** The [SparseArray](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md) you want to copy

**Return**: The Sparse array present in the class at the moment

Operator copy of the [SparseArray](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md) class

### function operator=

```cpp
inline SparseArray & operator=(
    SparseArray && other
)
```

**Parameters**:

* **other** The [SparseArray](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md) you want to move

**Return**: The Sparse array present in the class at the moment

Operator move of the [SparseArray](https://github.com/TEAM-AAAAAAAAAAAAAAAA/RTYPE-TECHNICAL-DOCS/blob/main/Classes/Classes/classecs_1_1_sparse_array.md) class

### function operator\[]

```cpp
inline referenceType operator[](
    size_t idx
)
```

### function operator\[]

```cpp
inline constReferenceType operator[](
    size_t idx
) const
```

### function begin

```cpp
inline iterator begin()
```

### function begin

```cpp
inline constIterator begin() const
```

### function cBegin

```cpp
inline constIterator cBegin() const
```

### function end

```cpp
inline iterator end()
```

### function end

```cpp
inline constIterator end() const
```

### function cEnd

```cpp
inline constIterator cEnd() const
```

### function size

```cpp
inline sizeType size() const
```

### function insertAt

```cpp
inline referenceType insertAt(
    sizeType pos,
    Component const & c
)
```

### function insertAt

```cpp
inline referenceType insertAt(
    sizeType pos,
    Component && c
)
```

### function emplaceAt

```cpp
template <class... Params>
inline referenceType emplaceAt(
    sizeType pos,
    Params &&... args
)
```

### function erase

```cpp
inline void erase(
    sizeType pos
)
```

### function getIndex

```cpp
inline sizeType getIndex(
    valueType const & c
) const
```

**Parameters**:

* **c** The std::optional, type of the component you want the index

**Return**: The sizeType of the valueType's index you are looking for

This function is used to get the index of the std::optional of the std::vector\<std::optional> \_data according to the given valueType (std::optional)

***

Updated on 2022-11-13 at 17:21:37 +0100
