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

- libXpertMassCore
- IndexRangeCollection

# MsXpS::libXpertMassCore::IndexRangeCollection Class

class MsXpS::libXpertMassCore::IndexRangeCollection

The IndexRangeCollection class provides a collection of IndexRange instances that enable delimiting Sequence regions of interest in a given Polymer instance. More...

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

- List of all members, including inherited members

## Properties

- comment : QString

## Public Functions

| IndexRangeCollection(QObject *parent = nullptr)
| IndexRangeCollection(const QString &index_ranges_string, MsXpS::libXpertMassCore::Enums::LocationType location_type = Enums::LocationType::INDEX, QObject *parent = nullptr)
| IndexRangeCollection(qsizetype index_start, qsizetype index_stop, QObject *parent = nullptr)
| IndexRangeCollection(const MsXpS::libXpertMassCore::IndexRangeCollection &other, QObject *parent = nullptr)
virtual | ~IndexRangeCollection()
void | appendIndexRange(const MsXpS::libXpertMassCore::IndexRange &index_range)
void | appendIndexRange(qsizetype start, qsizetype stop)
void | appendIndexRanges(const MsXpS::libXpertMassCore::IndexRangeCollection &index_ranges)
void | appendIndexRanges(const QList<MsXpS::libXpertMassCore::IndexRange *> &index_ranges)
void | clear()
MsXpS::libXpertMassCore::IndexRangeCollection * | clone(QObject *parent = nullptr)
bool | encompassIndex(qsizetype index, bool globally = false) const
QString | getComment() const
MsXpS::libXpertMassCore::IndexRange * | getRangeAt(qsizetype index)
const QList<MsXpS::libXpertMassCore::IndexRange *>::const_iterator | getRangeCstIteratorAt(qsizetype index) const
const MsXpS::libXpertMassCore::IndexRange & | getRangeCstRefAt(qsizetype index) const
const QList<MsXpS::libXpertMassCore::IndexRange *>::iterator | getRangeIteratorAt(qsizetype index)
MsXpS::libXpertMassCore::IndexRange & | getRangeRefAt(qsizetype index)
const QList<MsXpS::libXpertMassCore::IndexRange *> & | getRangesCstRef() const
QList<MsXpS::libXpertMassCore::IndexRange *> & | getRangesRef()
QString | indicesAsText() const
QList<qsizetype> | indicesOfLeftMostIndexRanges() const
QList<qsizetype> | indicesOfRightMostIndexRanges() const
MsXpS::libXpertMassCore::IndexRangeCollection & | initialize(const MsXpS::libXpertMassCore::IndexRangeCollection &other)
bool | isLeftMostIndexRange(const MsXpS::libXpertMassCore::IndexRange &index_range) const
bool | isRightMostIndexRange(const MsXpS::libXpertMassCore::IndexRange &index_range) const
qsizetype | leftMostIndexRangeStart() const
MsXpS::libXpertMassCore::IndexRange * | mostInclusiveLeftRightIndexRange() const
bool | overlap() const
QString | positionsAsText() const
qsizetype | rightMostIndexRangeStop() const
void | setComment(const QString &comment)
void | setIndexRange(const MsXpS::libXpertMassCore::IndexRange &index_range)
void | setIndexRange(qsizetype start, qsizetype stop)
void | setIndexRanges(const MsXpS::libXpertMassCore::IndexRangeCollection &index_ranges)
void | setIndexRanges(const QList<MsXpS::libXpertMassCore::IndexRange *> &index_ranges)
qsizetype | setIndexRanges(const QString &index_ranges_string, MsXpS::libXpertMassCore::Enums::LocationType location_type)
qsizetype | size() const
bool | operator!=(const MsXpS::libXpertMassCore::IndexRangeCollection &other) const
bool | operator==(const MsXpS::libXpertMassCore::IndexRangeCollection &other) const

## Static Public Members

MsXpS::libXpertMassCore::IndexRangeCollection * | clone(const MsXpS::libXpertMassCore::IndexRangeCollection &other, QObject *parent = nullptr)
QList<MsXpS::libXpertMassCore::IndexRange *> | parseIndexRanges(const QString &index_ranges_string, MsXpS::libXpertMassCore::Enums::LocationType location_type, QObject *parent = nullptr)

## Protected Variables

QString | m_comment
QList<MsXpS::libXpertMassCore::IndexRange *> | m_ranges

## Detailed Description

See also IndexRange.

## Property Documentation

### comment : QString

This property holds a comment that can be associated to this IndexRangeCollection instance.

Access functions:

QString | getComment() const
void | setComment(const QString &comment)

## Member Function Documentation

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

Constructs an empty IndexRangeCollection instance.

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

### `[explicit invokable]` IndexRangeCollection::IndexRangeCollection(const QString &index_ranges_string, MsXpS::libXpertMassCore::Enums::LocationType location_type = Enums::LocationType::INDEX, QObject *parent = nullptr)

Constructs an IndexRangeCollection instance using index_ranges_string

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

See also parseIndexRanges().

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

Constructs an IndexRangeCollection instance with a single IndexRange object using index_start and index_stop.

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

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

Constructs an IndexRangeCollection as a copy of other.

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

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

Destructs this IndexRangeCollection instance.

The IndexRangeCollection instances are freed.

### `[invokable]` void IndexRangeCollection::appendIndexRange(const MsXpS::libXpertMassCore::IndexRange &index_range)

Adds one IndexRange as a copy of index_range.

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

### `[invokable]` void IndexRangeCollection::appendIndexRange(qsizetype start, qsizetype stop)

Adds one IndexRange using start and stop.

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

### `[invokable]` void IndexRangeCollection::appendIndexRanges(const MsXpS::libXpertMassCore::IndexRangeCollection &index_ranges)

Adds IndexRange instances as copies of the instances in index_ranges.

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

### `[invokable]` void IndexRangeCollection::appendIndexRanges(const QList<MsXpS::libXpertMassCore::IndexRange *> &index_ranges)

Adds IndexRange instances as copies of the instances in index_ranges.

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

### void IndexRangeCollection::clear()

Clears all the members of this IndexRangeCollection instance.

### MsXpS::libXpertMassCore::IndexRangeCollection *IndexRangeCollection::clone(QObject *parent = nullptr)

Returns a newly allocated IndexRangeCollection instance with parent set to parent.

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

b*rief Returns a newly allocated IndexRangeCollection instance initialized using other and with parent set to parent.

### `[invokable]` bool IndexRangeCollection::encompassIndex(qsizetype index, bool globally = false) const

Returns true if index is found to be between the start and stop indices of at least one IndexRange instance in this IndexRangeCollection instance, false otherwise.

If globally is set to true, then returns true if index is contained in the interval [smallest - greatest] indices throughout all the IndexRange instances.

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

See also leftMostIndexRangeStart() and rightMostIndexRangeStop().

### QString IndexRangeCollection::getComment() const

Returns the comment.

Note: Getter function for property comment.

### MsXpS::libXpertMassCore::IndexRange *IndexRangeCollection::getRangeAt(qsizetype index)

Returns reference to the IndexRange at index.

An index that is out of bounds is fatal.

### const QList<MsXpS::libXpertMassCore::IndexRange *>::const_iterator IndexRangeCollection::getRangeCstIteratorAt(qsizetype index) const

Returns a constant iterator to the IndexRange at index.

An index that is out of bounds is fatal.

### const MsXpS::libXpertMassCore::IndexRange &IndexRangeCollection::getRangeCstRefAt(qsizetype index) const

Returns a const reference to the IndexRange at index.

An index that is out of bounds is fatal.

### const QList<MsXpS::libXpertMassCore::IndexRange *>::iterator IndexRangeCollection::getRangeIteratorAt(qsizetype index)

Returns an iterator to the IndexRange at index.

An index that is out of bounds is fatal.

### MsXpS::libXpertMassCore::IndexRange &IndexRangeCollection::getRangeRefAt(qsizetype index)

Returns reference to the IndexRange at index.

An index that is out of bounds is fatal.

### `[invokable]` const QList<MsXpS::libXpertMassCore::IndexRange *> &IndexRangeCollection::getRangesCstRef() const

Returns a const reference to the IndexRange container.

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

### `[invokable]` QList<MsXpS::libXpertMassCore::IndexRange *> &IndexRangeCollection::getRangesRef()

Returns a reference to the IndexRange container.

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

### `[invokable]` QString IndexRangeCollection::indicesAsText() const

Returns a string documenting the IndexRange instances in this IndexRanges instance.

Each IndexRange instance is described like the following, with the values being the start and stop index values in the IndexRange:

    [156-350]

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

See also positionsAsText().

### `[invokable]` QList<qsizetype> IndexRangeCollection::indicesOfLeftMostIndexRanges() const

Returns a container with the indices of the IndexRange instances that have the smallest start value.

Searches all the IndexRange instances in this IndexRangeCollection instance that share the same IndexRange::start value that is actually the smallest such start value in the container. Each found IndexRange instance's index in this IndexRangeCollection instance is added to the container.

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

See also indicesOfRightMostIndexRanges(), isLeftMostIndexRange(), and rightMostIndexRangeStop().

### `[invokable]` QList<qsizetype> IndexRangeCollection::indicesOfRightMostIndexRanges() const

Returns a container with the indices of the IndexRange instances that have the greater stop value.

Searches all the IndexRange instances in this IndexRangeCollection instance that share the same IndexRange::stop value that is actually the greatest such stopt value in the container. Each found IndexRange instance's index in this IndexRangeCollection instance is added to the container.

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

See also indicesOfLeftMostIndexRanges(), isLeftMostIndexRange(), and isRightMostIndexRange().

### MsXpS::libXpertMassCore::IndexRangeCollection &IndexRangeCollection::initialize(const MsXpS::libXpertMassCore::IndexRangeCollection &other)

Initializes this IndexRangeCollection instance using other and returns a reference to this instance.

### `[invokable]` bool IndexRangeCollection::isLeftMostIndexRange(const MsXpS::libXpertMassCore::IndexRange &index_range) const

Returns true if index_range is the left-most IndexRange instance in this IndexRangeCollection instance, false otherwise.

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

### `[invokable]` bool IndexRangeCollection::isRightMostIndexRange(const MsXpS::libXpertMassCore::IndexRange &index_range) const

Returns true if index_range is the right-most IndexRange instance in this IndexRangeCollection instance, false otherwise.

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

### `[invokable]` qsizetype IndexRangeCollection::leftMostIndexRangeStart() const

Returns the left-most start value throughout all the IndexRange instances.

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

### `[invokable]` MsXpS::libXpertMassCore::IndexRange *IndexRangeCollection::mostInclusiveLeftRightIndexRange() const

Returns an IndexRange containing the leftmost start index and the rightmost stop index, effectively providing the most inclusive index range.

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

### `[invokable]` bool IndexRangeCollection::overlap() const

Returns true if at least two IndexRange instances overlap.

Two IndexRange instances overlap if the second's start value is less than the first's stop value and greater than the first's start value:

|-----------------| |=================|

or

|-----------------| |=================|

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

See also encompassIndex().

### `[static invokable]` QList<MsXpS::libXpertMassCore::IndexRange *> IndexRangeCollection::parseIndexRanges(const QString &index_ranges_string, MsXpS::libXpertMassCore::Enums::LocationType location_type, QObject *parent = nullptr)

Parses index_ranges_string and returns a container with all the IndexRange entities parsed and parentship set to parent.

If location_type is Enums::LocationType::POSITIION, the parsed values are decremented by one unit to convert from Position to Index. The values stored in the `IndexRangeCollection` are always indices.

If location_type is Enums::LocationType::INDEX, the parsed values are stored as is.

The index_ranges_string might contain one or more substrings in the format "[15-220]", like "[0-20][0-30][10-50][15-80][25-100][30-100]".

If an error occurs, an empty container is returned.

A sanity check is performed: the counts of '[' and of ']' must be the same. At the stop of the parse, the size of IndexRangeCollection must be same as the count of '['.

If that check fails, an empty container is returned.

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

### `[invokable]` QString IndexRangeCollection::positionsAsText() const

Returns a string documenting the IndexRangeCollection in this IndexRanges.

Each IndexRange instance is described like the following with the values being the start and stop position values in the IndexRange (start + 1, stop +1):

    [157-351]

Note: The values reported are not indices, but positions.

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

See also indicesAsText().

### `[invokable]` qsizetype IndexRangeCollection::rightMostIndexRangeStop() const

Return the right most stop ordinate throughout all the IndexRanges instances.

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

### void IndexRangeCollection::setComment(const QString &comment)

Sets the comment to comment.

Note: Setter function for property comment.

### `[invokable]` void IndexRangeCollection::setIndexRange(const MsXpS::libXpertMassCore::IndexRange &index_range)

Clears this IndexRangeCollection's container of IndexRange instances and adds one index_range IndexRange.

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

### `[invokable]` void IndexRangeCollection::setIndexRange(qsizetype start, qsizetype stop)

Clears this IndexRangeCollection's container of IndexRange instances and adds one IndexRange using start and stop.

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

### `[invokable]` void IndexRangeCollection::setIndexRanges(const MsXpS::libXpertMassCore::IndexRangeCollection &index_ranges)

Clears this IndexRangeCollection's container of IndexRange and adds the IndexRange instances contained in the index_ranges collection.

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

### `[invokable]` void IndexRangeCollection::setIndexRanges(const QList<MsXpS::libXpertMassCore::IndexRange *> &index_ranges)

Clears this IndexRangeCollection's container of IndexRange instances and adds the IndexRange instances contained in the index_ranges container.

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

### `[invokable]` qsizetype IndexRangeCollection::setIndexRanges(const QString &index_ranges_string, MsXpS::libXpertMassCore::Enums::LocationType location_type)

Creates the IndexRange instances based on index_ranges_string and adds them to this IndexRange container.

Note: The container of IndexRange instances is first emptied.

If there are not multiple regions, the format of the index_ranges_string is:

    "[228-246]"

If there are multiple regions (for example when a cross-link exists), the format changes to account for the multiple regions:

    "[228-246][276-282][247-275]"

Note: It is expected that the values in the index_ranges_string are positions strings and not indices.

Returns the count of added IndexRange instances or -1 if an error occurred.

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

### qsizetype IndexRangeCollection::size() const

Returns the size of the container of IndexRange instances.

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

Returns true if this IndexRangeCollection is different than other, false otherwise.

This funtion returns the negated result of operator==().

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

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

Returns true if this IndexRangeCollection instance is identical to other, false otherwise.

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

## Member Variable Documentation

### QString IndexRangeCollection::m_comment

This variable holds a comment that can be associated to this IndexRangeCollection instance..

### QList<MsXpS::libXpertMassCore::IndexRange *> IndexRangeCollection::m_ranges

This variable holds the container of IndexRange instances.