Renamed method get to getAt and changed the get method logic
This commit is contained in:
parent
bfaea9ef9a
commit
c2c95bf339
@ -132,16 +132,16 @@ public:
|
|||||||
return remove(indiceToStr);
|
return remove(indiceToStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean removeAt(unsigned int index)
|
boolean removeAt(unsigned int position)
|
||||||
{
|
{
|
||||||
unsigned int position(0);
|
unsigned int pos(0);
|
||||||
if(_head->_next == NULL) return false;
|
if(_head->_next == NULL) return false;
|
||||||
|
|
||||||
Dictionary *cursor = _head, *toDelete(NULL);
|
Dictionary *cursor = _head, *toDelete(NULL);
|
||||||
|
|
||||||
while(!isListEmpty(cursor->_next))
|
while(!isListEmpty(cursor->_next))
|
||||||
{
|
{
|
||||||
if(position++ == index)
|
if(pos++ == position)
|
||||||
{
|
{
|
||||||
toDelete = cursor->_next;
|
toDelete = cursor->_next;
|
||||||
cursor->_next = cursor->_next->_next;
|
cursor->_next = cursor->_next->_next;
|
||||||
@ -176,16 +176,32 @@ public:
|
|||||||
return get(parameter);
|
return get(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
T* get(const unsigned int index)
|
T* get(const unsigned int id)
|
||||||
{
|
{
|
||||||
unsigned int position(0);
|
char indiceToStr[10];
|
||||||
|
sprintf(indiceToStr,"%d", id);
|
||||||
|
|
||||||
|
return get(indiceToStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
T* operator()(const unsigned int id)
|
||||||
|
{
|
||||||
|
char indiceToStr[10];
|
||||||
|
sprintf(indiceToStr,"%d", id);
|
||||||
|
|
||||||
|
return get(indiceToStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
T* getAt(const unsigned int position)
|
||||||
|
{
|
||||||
|
unsigned int pos(0);
|
||||||
if(isListEmpty(_head->_next))return NULL;
|
if(isListEmpty(_head->_next))return NULL;
|
||||||
|
|
||||||
Dictionary *cursor = _head->_next;
|
Dictionary *cursor = _head->_next;
|
||||||
|
|
||||||
while(!isListEmpty(cursor))
|
while(!isListEmpty(cursor))
|
||||||
{
|
{
|
||||||
if(position++ == index)
|
if(pos++ == position)
|
||||||
return cursor->_value;
|
return cursor->_value;
|
||||||
cursor = cursor->_next;
|
cursor = cursor->_next;
|
||||||
}
|
}
|
||||||
@ -193,11 +209,6 @@ public:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
T* operator()(const unsigned int index)
|
|
||||||
{
|
|
||||||
return get(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int count()
|
unsigned int count()
|
||||||
{
|
{
|
||||||
unsigned int counter(0);
|
unsigned int counter(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user