Added private get function to preserve constness of at()
This commit is contained in:
@@ -131,16 +131,9 @@ public:
|
|||||||
* @param index
|
* @param index
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
auto at(qsizetype index) -> T
|
auto at(qsizetype index) const -> T
|
||||||
{
|
{
|
||||||
QMutexLocker dataLocker(&m_dataMutex);
|
return get(index);
|
||||||
|
|
||||||
if(index < 0 || index >= m_data.count())
|
|
||||||
{
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_data.at(index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -264,6 +257,25 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/**
|
||||||
|
* @brief get
|
||||||
|
* Private thread-safe get operation. This is needed to preserve the constness
|
||||||
|
* of the at function
|
||||||
|
* @param index
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
auto get(qsizetype index) -> T
|
||||||
|
{
|
||||||
|
QMutexLocker dataLocker(&m_dataMutex);
|
||||||
|
|
||||||
|
if(index < 0 || index >= m_data.count())
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_data.at(index);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief m_offset
|
* @brief m_offset
|
||||||
* Current absolute offset. Used in fetch operations
|
* Current absolute offset. Used in fetch operations
|
||||||
|
|||||||
Reference in New Issue
Block a user