| <large>libXpertMassCore and libXpertMassGui Developer Documentation</large>

- libXpertMassCore
- IndexRange

# MsXpS::libXpertMassCore::IndexRange Class

class MsXpS::libXpertMassCore::IndexRange

The IndexRange class provides a range of indices that delimit a region of interest in a Polymer's Sequence instance. More...

Header: | `#include <MsXpS/libXpertMassCore/IndexRange.hpp>`
Inherits: | QObject

- List of all members, including inherited members
- IndexRange is part of libXpertMassCore Utilities.

## Public Functions

| IndexRange(QObject *parent = nullptr)
| IndexRange(qsizetype index_start, qsizetype index_stop, QObject *parent = nullptr)
| IndexRange(const MsXpS::libXpertMassCore::IndexRange &other, QObject *parent = nullptr)
virtual | ~IndexRange()
MsXpS::libXpertMassCore::IndexRange * | clone(QObject *parent = nullptr)
QString | indicesAsText() const
void | initialize(const MsXpS::libXpertMassCore::IndexRange &other)
bool | isValid() const
QString | positionsAsText() const
void | reset()
void | sortAscending()
void | sortDescending()
bool | operator!=(const MsXpS::libXpertMassCore::IndexRange &other) const
bool | operator==(const MsXpS::libXpertMassCore::IndexRange &other) const

## Public Variables

qsizetype | m_start
qsizetype | m_stop

## Static Public Members

MsXpS::libXpertMassCore::IndexRange * | clone(const MsXpS::libXpertMassCore::IndexRange &other, QObject *parent = nullptr)

## Detailed Description

One major IndexRange use case is when defining for what sequence region of a Polymer the masses or the elemental composition is to be computed. Another use case is when performing Sequence cleavages or Oligomer fragmentations: the IndexRange enables the delimitation of the sequence of interest inside a given Polymer's Sequence instance.

When instantiating a new IndexRange, the start and stop values are automatically sorted in ascending order (start <= stop).

See also IndexRangeCollection, sortAscending(), and sortDescending().

## Member Function Documentation

### `[explicit invokable]` IndexRange::IndexRange(QObject *parent = nullptr)

Constructs an IndexRange instance using parent as the parent object of this new instance.

Upon construction, the member data m_start and m_stop are initialized with std::numeric_limits<std::size_t>::max() values as a means to check if the IndexRange was initialized by the user or not.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[explicit invokable]` IndexRange::IndexRange(qsizetype index_start, qsizetype index_stop, QObject *parent = nullptr)

brief Constructs an IndexRange instance initializing the* start and stop members to the index_start and index_stop values, respectively.

The values are sorted in ascending order upon construction.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[explicit invokable]` IndexRange::IndexRange(const MsXpS::libXpertMassCore::IndexRange &other, QObject *parent = nullptr)

Constructs an IndexRange instance using other as a template and parent as the parent of this new instance.

The values are sorted in ascending order upon construction.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also sortAscending() and sortDescending().

### `[virtual noexcept]` IndexRange::~IndexRange()

brief Destructs this IndexRange instance.

### `[invokable]` MsXpS::libXpertMassCore::IndexRange *IndexRange::clone(QObject *parent = nullptr)

Allocates an returns a new IndexRange instance, initializing it using this instance's member values and setting its parent to parent.

The values are sorted in ascending order in the clone.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also sortAscending() and sortDescending().

### `[static invokable]` MsXpS::libXpertMassCore::IndexRange *IndexRange::clone(const MsXpS::libXpertMassCore::IndexRange &other, QObject *parent = nullptr)

br*ief Allocates an returns a new IndexRange instance, initializing it using other and setting its parent to parent.

The values are sorted in ascending order in the clone.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also sortAscending() and sortDescending().

### QString IndexRange::indicesAsText() const

Returns a string representing this IndexRange instance in the form "[start-stop]".

The start and stop values are indices (not positions).

See also positionsAsText().

### `[invokable]` void IndexRange::initialize(const MsXpS::libXpertMassCore::IndexRange &other)

Initializes this instance using other. The parent of this instance is unchanged.

The values are sorted in ascending order upon initialization.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

See also sortAscending() and sortDescending().

### `[invokable]` bool IndexRange::isValid() const

Returns true if this instance is valid.

The IndexRange intance is considered valid if m_start and m_stop contain valid values, that is, not the default-assigned values.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### QString IndexRange::positionsAsText() const

Returns a string representing this IndexRange instance in the form "[start-stop]".

Note: The start and stop values are positions (not indices). This means that the returned values correspond to m_start and m_stop both incremented by one unit.

See also indicesAsText().

### `[invokable]` void IndexRange::reset()

Resets the member data to default values.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` void IndexRange::sortAscending()

Makes sure that m_start is <= to m_stop.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` void IndexRange::sortDescending()

Makes sure that m_start is >= to m_stop.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` bool IndexRange::operator!=(const MsXpS::libXpertMassCore::IndexRange &other) const

Returns true if this and other IndexRange instances are different.

The parent is not checked.

Return the negation of operator==().

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

### `[invokable]` bool IndexRange::operator==(const MsXpS::libXpertMassCore::IndexRange &other) const

Returns true if this and other IndexRange instances are identical.

The parent is not checked.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

## Member Variable Documentation

### qsizetype IndexRange::m_start

Index that marks the start of the index range.

### qsizetype IndexRange::m_stop

Index that marks the stop of the index range.