Skip to content
Permalink
Browse files

IncAt

  • Loading branch information...
gmoromisato committed Dec 23, 2018
1 parent f97c3c2 commit 6e6e19059e8030b0a161792810c83fc2bd5ac4c5
Showing with 24 additions and 0 deletions.
  1. +24 −0 Include/TMap.h
@@ -371,6 +371,30 @@ template <class KEY, class VALUE> class TSortMap
m_Index.GrowToFit(iCount);
}

const VALUE &IncAt (const KEY &key, const VALUE &incValue)
{
int iIndex;

if (FindPos(key, &iIndex))
{
m_Array[m_Index[iIndex]].theValue += incValue;
return m_Array[m_Index[iIndex]].theValue;
}
else
{
int iPos;
SEntry *pEntry = InsertEntry(&iPos);

// Do it

m_Index.Insert(iPos, iIndex);
pEntry->theKey = key;
pEntry->theValue = incValue;

return pEntry->theValue;
}
}

VALUE *Insert (const KEY &newKey)
{
return atom_Insert(newKey);

0 comments on commit 6e6e190

Please sign in to comment.
You can’t perform that action at this time.