SYS : Add a Edn:VectorType eraseLen and an erase ==> normalisation with std::vector
This commit is contained in:
@@ -233,7 +233,7 @@ void Highlight::Parse(int32_t start,
|
||||
if (metaData[kkk].beginStart <= resultat.endStop) {
|
||||
// Remove element
|
||||
//EDN_INFO("Erase element=" << kkk);
|
||||
metaData.Erase(kkk, kkk+1);
|
||||
metaData.EraseLen(kkk, kkk+1);
|
||||
// Increase the end of search
|
||||
if (kkk < metaData.Size()) {
|
||||
// just befor the end of the next element
|
||||
|
@@ -170,7 +170,7 @@ void CTagsManager::AddToHistory(int32_t bufferID)
|
||||
for(int32_t iii= m_historyPos; iii < m_historyList.Size(); iii++) {
|
||||
delete(m_historyList[iii]);
|
||||
}
|
||||
m_historyList.Erase(m_historyPos, m_historyList.Size() - m_historyPos);
|
||||
m_historyList.EraseLen(m_historyPos, m_historyList.Size() - m_historyPos);
|
||||
}
|
||||
// add the current element
|
||||
BufferManager *myBufferManager = BufferManager::getInstance();
|
||||
|
@@ -90,17 +90,17 @@ void EdnBuf::RegenerateHighLightAt(int32_t pos, int32_t nbDeleted, int32_t nbAdd
|
||||
m_HLDataPass1.Erase(0);
|
||||
//EDN_DEBUG("1 * Erase 0");
|
||||
} else {
|
||||
m_HLDataPass1.Erase(0,stopId);
|
||||
m_HLDataPass1.EraseLen(0,stopId);
|
||||
//EDN_DEBUG("2 * Erase 0->" << stopId);
|
||||
}
|
||||
} else if(-1 == stopId) {
|
||||
//EDN_DEBUG("3 * Erase " << startId+1 << "-> end");
|
||||
m_HLDataPass1.Erase(startId+1, m_HLDataPass1.Size() - startId);
|
||||
m_HLDataPass1.EraseLen(startId+1, m_HLDataPass1.Size() - startId);
|
||||
stopId = -1;
|
||||
} else {
|
||||
int32_t currentSize = m_HLDataPass1.Size();
|
||||
//EDN_DEBUG("4 * Erase " << startId+1 << "->" << stopId << " in " << currentSize << " elements" );
|
||||
m_HLDataPass1.Erase(startId+1, stopId - startId);
|
||||
m_HLDataPass1.EraseLen(startId+1, stopId - startId);
|
||||
if (stopId == currentSize-1) {
|
||||
stopId = -1;
|
||||
}
|
||||
|
@@ -471,7 +471,7 @@ void Edn::String::Remove(int32_t currentID, int32_t len)
|
||||
return;
|
||||
}
|
||||
// TODO : check the size of the data
|
||||
m_data.Erase(currentID, len);
|
||||
m_data.EraseLen(currentID, len);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -474,7 +474,33 @@ template<typename MY_TYPE=int32_t> class VectorType
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Remove one element
|
||||
* @brief Remove N elements
|
||||
*
|
||||
* @param[in] pos Position to remove the data
|
||||
* @param[in] posEnd Last position number
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void Erase(int32_t pos, int32_t posEnd)
|
||||
{
|
||||
if (pos>m_size) {
|
||||
EDN_ERROR(" can not Erase Element at this position : " << pos << " > " << m_size);
|
||||
return;
|
||||
}
|
||||
if (posEnd>m_size) {
|
||||
posEnd = m_size;
|
||||
}
|
||||
int32_t nbElement = m_size - pos;
|
||||
int32_t tmpSize = m_size;
|
||||
// move curent data
|
||||
memmove((m_data + pos), (m_data + pos + nbElement), (tmpSize - (pos+nbElement))*sizeof(MY_TYPE) );
|
||||
// Request resize of the current buffer
|
||||
Resize(m_size-nbElement);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Remove N element
|
||||
*
|
||||
* @param[in] pos Position to remove the data
|
||||
* @param[in] nbElement number of element to remove
|
||||
@@ -482,10 +508,10 @@ template<typename MY_TYPE=int32_t> class VectorType
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void Erase(int32_t pos, int32_t nbElement)
|
||||
void EraseLen(int32_t pos, int32_t nbElement)
|
||||
{
|
||||
if (pos>m_size) {
|
||||
EDN_ERROR(" can not Erase Element at this position : " << pos << " > " << m_size);
|
||||
EDN_ERROR(" can not Erase Len Element at this position : " << pos << " > " << m_size);
|
||||
return;
|
||||
}
|
||||
if (pos+nbElement>m_size) {
|
||||
|
Reference in New Issue
Block a user