Updated Dictionary code
This commit is contained in:
parent
812e891489
commit
563664931e
@ -132,16 +132,16 @@ public:
|
||||
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;
|
||||
|
||||
Dictionary *cursor = _head, *toDelete(NULL);
|
||||
|
||||
while(!isListEmpty(cursor->_next))
|
||||
{
|
||||
if(position++ == index)
|
||||
if(pos++ == position)
|
||||
{
|
||||
toDelete = cursor->_next;
|
||||
cursor->_next = cursor->_next->_next;
|
||||
@ -176,16 +176,32 @@ public:
|
||||
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;
|
||||
|
||||
Dictionary *cursor = _head->_next;
|
||||
|
||||
while(!isListEmpty(cursor))
|
||||
{
|
||||
if(position++ == index)
|
||||
if(pos++ == position)
|
||||
return cursor->_value;
|
||||
cursor = cursor->_next;
|
||||
}
|
||||
@ -193,11 +209,6 @@ public:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
T* operator()(const unsigned int index)
|
||||
{
|
||||
return get(index);
|
||||
}
|
||||
|
||||
unsigned int count()
|
||||
{
|
||||
unsigned int counter(0);
|
||||
|
Loading…
Reference in New Issue
Block a user