Aggiunto TContainer
git-svn-id: svn://10.65.10.50/trunk@2189 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
b162971038
commit
3b4b9ae254
@ -50,6 +50,68 @@ void TAssoc_array::destroy()
|
|||||||
_cnt = _row = _col = 0;
|
_cnt = _row = _col = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TObject* TAssoc_array::first_item( )
|
||||||
|
{
|
||||||
|
_rowitem = 0;
|
||||||
|
_colitem = 0;
|
||||||
|
return succ_item( );
|
||||||
|
}
|
||||||
|
|
||||||
|
TObject* TAssoc_array::last_item( )
|
||||||
|
{
|
||||||
|
_rowitem = HASH_SIZE - 1;
|
||||||
|
while( _rowitem >= 0 && _data[ _rowitem ].items() == 0 )
|
||||||
|
_rowitem --;
|
||||||
|
if( _rowitem < 0 )
|
||||||
|
return NULL;
|
||||||
|
const TArray* arr = &_data[_rowitem];
|
||||||
|
_colitem = arr->items( ) - 1;
|
||||||
|
return pred_item( );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TObject* TAssoc_array::succ_item( )
|
||||||
|
{
|
||||||
|
const TArray* arr = &_data[_rowitem];
|
||||||
|
|
||||||
|
for(;_rowitem < HASH_SIZE;)
|
||||||
|
{
|
||||||
|
if ((int)_colitem < arr->items())
|
||||||
|
break;
|
||||||
|
arr = &_data[++_rowitem];
|
||||||
|
_colitem = 0;
|
||||||
|
}
|
||||||
|
if (_rowitem == HASH_SIZE)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
THash_object* o = (THash_object*)arr->objptr(_colitem++);
|
||||||
|
return (o == NULL || o->_obj == NULL) ? NULL : o->_obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TObject* TAssoc_array::pred_item( )
|
||||||
|
{
|
||||||
|
const TArray* arr = &_data[_rowitem];
|
||||||
|
|
||||||
|
for(;_rowitem >= 0;)
|
||||||
|
{
|
||||||
|
if ((int)_colitem >= 0 )
|
||||||
|
break;
|
||||||
|
_rowitem --;
|
||||||
|
while( _rowitem >= 0 && _data[ _rowitem ].items( ) == 0 )
|
||||||
|
_rowitem --;
|
||||||
|
if (_rowitem < 0 )
|
||||||
|
return NULL;
|
||||||
|
arr = &_data[ _rowitem ];
|
||||||
|
_colitem = arr->items( ) - 1;
|
||||||
|
}
|
||||||
|
if (_rowitem < 0 )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
THash_object* o = (THash_object*)arr->objptr(_colitem--);
|
||||||
|
return (o == NULL || o->_obj == NULL) ? NULL : o->_obj;
|
||||||
|
}
|
||||||
|
|
||||||
// @mfunc Aggiunge un oggetto all'array.
|
// @mfunc Aggiunge un oggetto all'array.
|
||||||
bool TAssoc_array::add(
|
bool TAssoc_array::add(
|
||||||
const char* key, // @parm Chiave d'ordinamento
|
const char* key, // @parm Chiave d'ordinamento
|
||||||
|
@ -44,7 +44,7 @@ public:
|
|||||||
// @class TAssoc_array | Tabella hash di oggetti generici
|
// @class TAssoc_array | Tabella hash di oggetti generici
|
||||||
//
|
//
|
||||||
// @base public |TObject
|
// @base public |TObject
|
||||||
class TAssoc_array : public TObject
|
class TAssoc_array : public TContainer
|
||||||
{
|
{
|
||||||
|
|
||||||
//@access Private Member
|
//@access Private Member
|
||||||
@ -57,6 +57,10 @@ class TAssoc_array : public TObject
|
|||||||
word _row;
|
word _row;
|
||||||
// @cmember Numero di colonne della tabella hash
|
// @cmember Numero di colonne della tabella hash
|
||||||
word _col;
|
word _col;
|
||||||
|
// @cmember Numero di righe della tabella hash per i metodi _item
|
||||||
|
int _rowitem;
|
||||||
|
// @cmember Numero di colonne della tabella hash per i metodi _item
|
||||||
|
int _colitem;
|
||||||
// @cmember Array contenente i dati veri e propri
|
// @cmember Array contenente i dati veri e propri
|
||||||
TArray _data[HASH_SIZE];
|
TArray _data[HASH_SIZE];
|
||||||
|
|
||||||
@ -73,6 +77,18 @@ public:
|
|||||||
int items() const
|
int items() const
|
||||||
{ return _cnt; }
|
{ return _cnt; }
|
||||||
|
|
||||||
|
// @cmember Ritorna l'indice del primo oggetto
|
||||||
|
virtual TObject* first_item( );
|
||||||
|
// @cmember Ritorna l'indice dell'ultimo oggetto
|
||||||
|
virtual TObject* last_item( );
|
||||||
|
// @cmember Ritorna l'indice del primo oggetto dopo i
|
||||||
|
virtual TObject* succ_item( );
|
||||||
|
// @cmember Ritorna l'indice del primo oggetto che precede i
|
||||||
|
virtual TObject* pred_item( );
|
||||||
|
// @cmember Ritorna il numero di elementi presenti come long
|
||||||
|
long objects( )
|
||||||
|
{ return _cnt; }
|
||||||
|
|
||||||
// @cmember Cancella tutti gli elementi
|
// @cmember Cancella tutti gli elementi
|
||||||
virtual void destroy();
|
virtual void destroy();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user