Aggiunto costruttore TArray(TArray&) che duplica tutto il contenuto

git-svn-id: svn://10.65.10.50/trunk@217 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1994-09-12 08:02:05 +00:00
parent 2b1c61fb33
commit 946f6a4514
2 changed files with 530 additions and 521 deletions

View File

@ -1,9 +1,9 @@
#include <ctype.h> #include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
#include <array.h> #include <array.h>
#include <strings.h> #include <strings.h>
void TArray::resize(int arraysize) void TArray::resize(int arraysize)
{ {
@ -47,7 +47,6 @@ bool TArray::destroy(int index, bool pack)
} }
TArray::TArray(int arraysize) : _size(0), _items(0), _data(NULL) TArray::TArray(int arraysize) : _size(0), _items(0), _data(NULL)
{ {
@ -58,6 +57,14 @@ TArray::TArray() : _size(0), _items(0), _data(NULL)
{ {
} }
TArray::TArray(const TArray& a)
{
if (a.size()) resize(a.size());
for (_items = 0; _items < a.items(); _items++)
_data[_items] = a[_items].dup();
}
TArray::~TArray() TArray::~TArray()
{ {

View File

@ -22,13 +22,15 @@ class TArray : public TObject
int _items; // Number of items in the array int _items; // Number of items in the array
protected: protected:
// @FPROT // @FPROT
void resize(int newdim); // Estende l'array void resize(int newdim); // Estende l'array
public: public:
// @FPUB // @FPUB
TArray(int arraysize); // Crea un array (chiama resize) TArray(int arraysize); // Crea un array (chiama resize)
TArray(); // Crea un array (non chiama resize) TArray(); // Crea un array (non chiama resize)
TArray(const TArray&); // copia tutto e duplica gli elementi
// (casino se non hanno dup() definita)
virtual ~TArray() ; virtual ~TArray() ;
virtual const char* class_name() const ; // Ritorna il nome della classe virtual const char* class_name() const ; // Ritorna il nome della classe
virtual word class_id() const ; // Ritorna il class-id virtual word class_id() const ; // Ritorna il class-id
@ -106,7 +108,7 @@ public:
TBit_array& operator=(const TBit_array& ba); TBit_array& operator=(const TBit_array& ba);
bool operator[] (long n) const; bool operator[] (long n) const;
TBit_array& operator |=(const TBit_array& b); TBit_array& operator |=(const TBit_array& b);
// TBit operator[] (long n) { return TBit(this, n); } // TBit operator[] (long n) { return TBit(this, n); }
long first_one() const; long first_one() const;
long last_one() const; long last_one() const;
long ones() const; long ones() const;