1994-09-12 08:02:05 +00:00
|
|
|
#ifndef __ARRAY_H
|
|
|
|
#define __ARRAY_H
|
|
|
|
|
|
|
|
#ifndef __OBJECT_H
|
|
|
|
#include <object.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef NULL
|
|
|
|
#define NULL 0L
|
|
|
|
#endif
|
|
|
|
|
1995-04-21 17:10:19 +00:00
|
|
|
// @doc EXTERNAL
|
|
|
|
//
|
|
|
|
// @type COMPARE_FUNCTION | Prototipo funzione di confronto tra elementi della
|
1996-01-31 17:19:02 +00:00
|
|
|
// classe <c TObject> da passare al metodo sort dei <c TArray>
|
1998-07-20 13:00:14 +00:00
|
|
|
typedef int (*COMPARE_FUNCTION)(const TObject**, const TObject**);
|
1994-09-12 08:02:05 +00:00
|
|
|
|
1995-11-22 13:35:49 +00:00
|
|
|
// @doc EXTERNAL
|
1996-02-05 19:00:53 +00:00
|
|
|
|
1995-11-22 13:35:49 +00:00
|
|
|
// @type CONDITION_FUNCTION | Prototipo funzione di ricerca/filtro
|
|
|
|
// per i derivati di <c TObject> da passare ai metodi dei <c TContainer>
|
|
|
|
typedef bool (*CONDITION_FUNCTION) ( const TObject& );
|
|
|
|
|
|
|
|
// @doc EXTERNAL
|
1996-02-05 19:00:53 +00:00
|
|
|
|
1995-11-22 13:35:49 +00:00
|
|
|
// @type OPERATION_FUNCTION | Prototipo funzione attuatore
|
|
|
|
// da passare ai metodi sort dei <c TContainer>
|
|
|
|
typedef void (*OPERATION_FUNCTION) ( const TObject& );
|
|
|
|
|
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @doc EXTERNAL
|
|
|
|
|
1995-12-29 12:09:48 +00:00
|
|
|
// @class TContainer | Generico contenitore ad accesso casuale (con indice)
|
1995-11-22 13:35:49 +00:00
|
|
|
// @base public | TObject
|
|
|
|
class TContainer : public TObject
|
|
|
|
{
|
1996-02-05 19:00:53 +00:00
|
|
|
|
|
|
|
// @author:(INTERNAL) Matteo
|
1995-11-22 13:35:49 +00:00
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @access:(INTERNAL) Private Member
|
1995-11-22 13:35:49 +00:00
|
|
|
private:
|
1996-09-04 10:54:14 +00:00
|
|
|
// @cmember:(INTERNAL) Ultima condizione di ricerca/filtro (vedi <t CONDITION_FUNCTION>)
|
1995-11-22 13:35:49 +00:00
|
|
|
CONDITION_FUNCTION _last_condition;
|
|
|
|
|
|
|
|
// @access Public Member
|
|
|
|
public:
|
|
|
|
|
1996-09-04 10:54:14 +00:00
|
|
|
// @cmember Ritorna un puntatore al primo oggetto del contenitore
|
1995-11-22 13:35:49 +00:00
|
|
|
virtual TObject* first_item( ) pure;
|
1996-09-04 10:54:14 +00:00
|
|
|
// @cmember Ritorna un puntatore all'ultimo oggetto del contenitore
|
1995-11-22 13:35:49 +00:00
|
|
|
virtual TObject* last_item( ) pure;
|
1996-09-04 10:54:14 +00:00
|
|
|
// @cmember Ritorna un puntatore all'oggetto successivo all'oggetto corrente
|
1995-11-22 13:35:49 +00:00
|
|
|
virtual TObject* succ_item( ) pure;
|
1996-09-04 10:54:14 +00:00
|
|
|
// @cmember Ritorna un puntatore all'oggetto che precede l'oggetto corrente
|
1995-11-22 13:35:49 +00:00
|
|
|
virtual TObject* pred_item( ) pure;
|
1996-09-04 10:54:14 +00:00
|
|
|
// @cmember Ritorna il numero di oggetti nel contenitore
|
2005-05-17 15:37:43 +00:00
|
|
|
virtual long objects( ) const pure;
|
|
|
|
// @cmember Ritorna true se il contenitore e' vuoto
|
|
|
|
virtual bool empty() const
|
|
|
|
{ return objects( ) == 0; }
|
1995-11-22 13:35:49 +00:00
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @cmember Cerca il successivo elemento che soddisfa la <t OPERATION_FUNCTION>
|
1995-11-22 13:35:49 +00:00
|
|
|
virtual void for_each( OPERATION_FUNCTION );
|
1996-02-05 19:00:53 +00:00
|
|
|
// @cmember Cerca il successivo elemento che soddisfa la <t OPERATION_FUNCTION>
|
1996-04-12 08:24:51 +00:00
|
|
|
// per ogni elemento di <t CONDITION_FUNCTION>
|
1995-11-22 13:35:49 +00:00
|
|
|
virtual void for_each_that( OPERATION_FUNCTION, CONDITION_FUNCTION = NULL );
|
|
|
|
|
|
|
|
// @cmember Ritorna il puntatore al primo oggetto che soddisfa la condizione
|
|
|
|
virtual TObject* first_that( CONDITION_FUNCTION = NULL );
|
|
|
|
// @cmember Ritorna il puntatore all'ultimo oggetto che soddisfa la condizione
|
|
|
|
virtual TObject* last_that( CONDITION_FUNCTION = NULL );
|
|
|
|
// @cmember Ritorna il prossimo oggetto che soddisfa la condizione. Va usata con first_that per scandire il container
|
|
|
|
virtual TObject* succ_that( );
|
|
|
|
// @cmember Ritorna il precedente oggetto che soddisfa la condizione. Va usata con last_that per scandire il container all'indietro
|
|
|
|
virtual TObject* pred_that( );
|
|
|
|
// @cmember Ritorna il numero di elementi che soddisfano la condizione
|
|
|
|
virtual long count( CONDITION_FUNCTION = NULL );
|
1996-09-04 10:54:14 +00:00
|
|
|
// @cmember Ritorna l'oggetto successivo a quello corrente
|
1996-02-05 19:00:53 +00:00
|
|
|
TObject* operator++ ()
|
|
|
|
{ return succ_item( ); };
|
1996-09-04 10:54:14 +00:00
|
|
|
// @cmember Ritorna l'oggetto che precede quello corrente
|
1996-02-05 19:00:53 +00:00
|
|
|
TObject* operator-- ()
|
|
|
|
{ return pred_item( ); };
|
2004-11-30 22:02:59 +00:00
|
|
|
|
|
|
|
virtual ~TContainer() { }
|
1995-11-22 13:35:49 +00:00
|
|
|
};
|
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @doc EXTERNAL
|
1995-11-22 13:35:49 +00:00
|
|
|
|
1995-04-21 17:10:19 +00:00
|
|
|
// @class TArray | Classe per la definizione degli array
|
|
|
|
//
|
1997-03-19 08:08:39 +00:00
|
|
|
// @base public | TContainer
|
1995-11-22 13:35:49 +00:00
|
|
|
class TArray : public TContainer
|
1995-04-21 17:10:19 +00:00
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @author:(INTERNAL) Guido
|
1995-04-21 17:10:19 +00:00
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @access:(INTERNAL) Private Member
|
|
|
|
{
|
1998-05-27 10:56:30 +00:00
|
|
|
friend class TPointer_array;
|
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @cmember:(INTERNAL) Array di puntatori ad oggetti
|
1995-05-10 10:40:40 +00:00
|
|
|
TObject** _data;
|
1996-02-05 19:00:53 +00:00
|
|
|
// @cmember:(INTERNAL) Dimensione dell'array
|
1995-05-10 10:40:40 +00:00
|
|
|
int _size;
|
1996-02-05 19:00:53 +00:00
|
|
|
// @cmember:(INTERNAL) Numero di elementi presenti nell'array
|
1995-05-10 10:40:40 +00:00
|
|
|
int _items;
|
1996-02-05 19:00:53 +00:00
|
|
|
// @cmember:(INTERNAL) Prossimo elemento libero nell'array
|
1995-06-21 15:35:44 +00:00
|
|
|
int _next;
|
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @cmember:(INTERNAL) Indice per la scansione sequenziale
|
1995-11-22 13:35:49 +00:00
|
|
|
int _scanindex;
|
|
|
|
|
1995-04-21 17:10:19 +00:00
|
|
|
// @access Protected Member
|
1994-09-12 08:02:05 +00:00
|
|
|
protected:
|
1997-12-17 10:40:18 +00:00
|
|
|
TObject** data() const { return _data; }
|
|
|
|
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Modifica la dimensione dell'array.
|
1995-04-21 17:10:19 +00:00
|
|
|
void resize(int newdim);
|
2004-05-18 13:47:49 +00:00
|
|
|
void copy(const TArray& a);
|
1995-04-21 17:10:19 +00:00
|
|
|
|
1995-05-10 10:40:40 +00:00
|
|
|
// @access Public Member
|
1994-09-12 08:02:05 +00:00
|
|
|
public:
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Costruttore. Crea un array (chiama <mf TArray::resize>)
|
1995-04-21 17:10:19 +00:00
|
|
|
TArray(int arraysize);
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Costruttore. Crea un array (non chiama <mf TArray::resize>)
|
1995-04-21 17:10:19 +00:00
|
|
|
TArray();
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Costruttore. Copia tutto l'array e ne duplica gli elementi
|
1995-04-21 17:10:19 +00:00
|
|
|
TArray(const TArray&);
|
1994-09-14 10:43:51 +00:00
|
|
|
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Distruttore
|
1994-09-12 08:02:05 +00:00
|
|
|
virtual ~TArray() ;
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Ritorna il nome della classe
|
1995-04-21 17:10:19 +00:00
|
|
|
virtual const char* class_name() const ;
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Ritorna l'id della class
|
1995-04-21 17:10:19 +00:00
|
|
|
virtual word class_id() const ;
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Stampa un array
|
1995-04-21 17:10:19 +00:00
|
|
|
virtual void print_on(ostream& out) const ;
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Controlla se si tratta di un oggetto valido
|
1995-04-21 17:10:19 +00:00
|
|
|
virtual bool ok() const ;
|
|
|
|
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Ritorna la grandezza dell'array
|
|
|
|
int size() const
|
|
|
|
{ return _size; }
|
|
|
|
// @cmember Ritorna numero di oggetti nell'array
|
2005-05-17 15:37:43 +00:00
|
|
|
virtual long objects( ) const
|
1995-05-10 10:40:40 +00:00
|
|
|
{ return _items; }
|
1996-02-05 19:00:53 +00:00
|
|
|
|
|
|
|
// @cmember Ritorna numero di oggetti nell'array
|
2005-05-17 15:37:43 +00:00
|
|
|
virtual int items() const
|
1995-11-22 13:35:49 +00:00
|
|
|
{ return _items; }
|
1996-02-05 19:00:53 +00:00
|
|
|
|
|
|
|
// @cmember Ritorna il primo elemento dell'array
|
1995-11-22 13:35:49 +00:00
|
|
|
virtual TObject* first_item( );
|
1996-02-05 19:00:53 +00:00
|
|
|
// @cmember Ritorna l'ultimo elemento dell'array
|
1995-11-22 13:35:49 +00:00
|
|
|
virtual TObject* last_item( );
|
1996-09-04 10:54:14 +00:00
|
|
|
// @cmember Ritorna il successivo elemento dell'array rispetto all'elemento corrente
|
1995-11-22 13:35:49 +00:00
|
|
|
virtual TObject* succ_item( );
|
1996-09-04 10:54:14 +00:00
|
|
|
// @cmember Ritorna il precedente elemento dell'array rispetto all'elemento corrente
|
1995-11-22 13:35:49 +00:00
|
|
|
virtual TObject* pred_item( );
|
|
|
|
|
1995-08-21 07:47:18 +00:00
|
|
|
// @cmember Ritorna l'indice del primo oggetto
|
|
|
|
int first() const;
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Ritorna l'indice dell'ultimo oggetto
|
1995-04-21 17:10:19 +00:00
|
|
|
int last() const;
|
1996-09-04 10:54:14 +00:00
|
|
|
// @cmember Ritorna l'indice del primo oggetto dopo l'i-esimo
|
1995-08-21 07:47:18 +00:00
|
|
|
int succ(int i) const;
|
1996-09-04 10:54:14 +00:00
|
|
|
// @cmember Ritorna l'indice del primo oggetto che precede l'i-esimo
|
1995-08-21 07:47:18 +00:00
|
|
|
int pred(int i) const;
|
|
|
|
|
1996-09-04 10:54:14 +00:00
|
|
|
// @cmember Ritorna l'oggetto nella posizione index
|
1995-04-21 17:10:19 +00:00
|
|
|
TObject& operator[] (int index) const ;
|
1996-09-04 10:54:14 +00:00
|
|
|
// @cmember Ritorna l'oggetto nella posizione index
|
1995-04-21 17:10:19 +00:00
|
|
|
TObject* objptr(int index) const ;
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Assegna all'array l'oggetto passato
|
2004-05-18 13:47:49 +00:00
|
|
|
TArray& operator=(const TArray& a);
|
1995-04-21 17:10:19 +00:00
|
|
|
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Rimuove uno o tutti (default) gli elementi
|
1995-04-21 17:10:19 +00:00
|
|
|
virtual bool destroy(int index = -1, bool pack = FALSE);
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Aggiunge un oggetto ad un array.
|
1995-04-21 17:10:19 +00:00
|
|
|
virtual int add(TObject* obj, int index = -1) ;
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Inserisce un elemento dell'array nella posizione index
|
1997-05-21 14:39:09 +00:00
|
|
|
virtual int insert(TObject* obj, int index = 0, bool force = FALSE);
|
1994-09-12 08:02:05 +00:00
|
|
|
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Aggiunge un oggetto all'array. L'oggetto viene duplicato
|
1997-12-17 10:40:18 +00:00
|
|
|
virtual int add(const TObject& object, int index = -1) ;
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Inserisce un oggetto alla posizione index
|
1997-12-17 10:40:18 +00:00
|
|
|
virtual int insert(const TObject& object, int index = 0, bool force = FALSE);
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Elimina l'elemento nella posizione index dell'array
|
1994-09-12 08:02:05 +00:00
|
|
|
TObject* remove(int index, bool pack = FALSE);
|
1997-03-19 08:08:39 +00:00
|
|
|
// @cmember Elimina l'elemento nella posizione index dell'array
|
|
|
|
TObject* remove_item(bool pack = FALSE) ;
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Scambia di posto due elementi dell'array
|
1994-09-12 08:02:05 +00:00
|
|
|
void swap(int i1, int i2);
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Rende contigui tutti gli elementi non nulli
|
1996-08-09 08:57:53 +00:00
|
|
|
virtual void pack();
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Ordina i TObject secondo il criterio definito in <t COMPARE_FUNCTION>
|
1995-04-21 17:10:19 +00:00
|
|
|
void sort(COMPARE_FUNCTION = NULL);
|
1994-09-12 08:02:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
inline TObject* TArray::objptr(int index) const
|
|
|
|
{
|
|
|
|
return (index < _size && index >= 0) ? _data[index] : NULL;
|
|
|
|
}
|
|
|
|
|
1998-02-24 10:37:28 +00:00
|
|
|
#ifndef DBG
|
1994-09-12 08:02:05 +00:00
|
|
|
inline TObject& TArray::operator[] (int index) const
|
|
|
|
{
|
1998-02-24 10:37:28 +00:00
|
|
|
return *objptr(index);
|
1994-09-12 08:02:05 +00:00
|
|
|
}
|
1998-02-24 10:37:28 +00:00
|
|
|
#endif
|
1996-02-05 19:00:53 +00:00
|
|
|
|
1998-04-30 14:54:04 +00:00
|
|
|
#define FOR_EACH_ARRAY_ITEM(__arr, __r, __obj) \
|
|
|
|
TObject* __obj; \
|
|
|
|
for (int __r = __arr.first(); \
|
2004-03-12 14:52:53 +00:00
|
|
|
(__obj = __arr.objptr(__r)); \
|
1998-04-30 14:54:04 +00:00
|
|
|
__r = __arr.succ(__r))
|
|
|
|
|
|
|
|
#define FOR_EACH_ARRAY_ITEM_BACK(__arr, __r, __obj) \
|
|
|
|
TObject* __obj; \
|
|
|
|
for (int __r = __arr.last(); \
|
2004-04-28 20:54:21 +00:00
|
|
|
(__obj = __arr.objptr(__r)); \
|
1998-04-30 14:54:04 +00:00
|
|
|
__r = __arr.pred(__r))
|
|
|
|
|
|
|
|
|
1997-12-17 10:40:18 +00:00
|
|
|
class TPointer_array : public TArray
|
|
|
|
{
|
1998-05-27 10:56:30 +00:00
|
|
|
protected:
|
|
|
|
void copy(const TArray& a);
|
|
|
|
|
1997-12-17 14:36:43 +00:00
|
|
|
public:
|
1997-12-17 10:40:18 +00:00
|
|
|
virtual bool destroy(int index = -1, bool pack = FALSE);
|
1998-05-13 15:01:03 +00:00
|
|
|
virtual int add(TObject* object, int index = -1);
|
|
|
|
virtual int add(const TObject& object, int index = -1);
|
1997-12-17 10:40:18 +00:00
|
|
|
virtual int insert(const TObject& object, int index = 0, bool force = FALSE);
|
1998-05-27 10:56:30 +00:00
|
|
|
virtual TPointer_array& operator= (const TArray& a) { copy(a); return *this; }
|
|
|
|
virtual TPointer_array& operator= (const TPointer_array& a) { copy(a); return *this; }
|
1997-12-17 10:40:18 +00:00
|
|
|
|
1997-12-24 14:26:25 +00:00
|
|
|
long get_long(int index) const { return (long)objptr(index); }
|
1998-04-30 14:54:04 +00:00
|
|
|
int get_int(int index) const { return (int)get_long(index); }
|
1998-01-28 08:21:11 +00:00
|
|
|
int add_long(long value, int index = -1) { return add((TObject*)value, index); }
|
|
|
|
int insert_long(long value, int index = -1) { return TArray::insert((TObject*)value, index, TRUE); }
|
1997-12-24 14:26:25 +00:00
|
|
|
|
1997-12-17 10:40:18 +00:00
|
|
|
TPointer_array() { }
|
|
|
|
TPointer_array(int size) : TArray(size) { }
|
1998-05-27 10:56:30 +00:00
|
|
|
TPointer_array(const TArray& a) { copy(a); }
|
|
|
|
TPointer_array(const TPointer_array& a) { copy(a); }
|
1997-12-17 14:36:43 +00:00
|
|
|
virtual ~TPointer_array() { destroy(); }
|
1997-12-17 10:40:18 +00:00
|
|
|
};
|
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @doc EXTERNAL
|
|
|
|
|
1995-05-10 10:40:40 +00:00
|
|
|
// @class TBit_array | Come la classe <c TArray> ma i suoi elementi sono bit;
|
|
|
|
// questo permette di costruire array piu' piccoli rispetto
|
|
|
|
// alla classe TArray.
|
|
|
|
//
|
|
|
|
// @base public | TObject
|
1994-09-12 08:02:05 +00:00
|
|
|
class TBit_array : public TObject
|
1995-05-10 10:40:40 +00:00
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @author:(INTERNAL) Guido
|
1995-05-10 10:40:40 +00:00
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @access:(INTERNAL) Private Member
|
|
|
|
{
|
|
|
|
// @cmember:(INTERNAL) dimensione dell'array
|
1994-09-12 08:02:05 +00:00
|
|
|
word _size;
|
1996-02-05 19:00:53 +00:00
|
|
|
// @cmember:(INTERNAL) bit in cui sono contenuti i dati
|
1994-09-12 08:02:05 +00:00
|
|
|
byte* _bit;
|
|
|
|
|
1995-05-10 10:40:40 +00:00
|
|
|
// @access Protected Member
|
1994-09-12 08:02:05 +00:00
|
|
|
protected:
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Controlla se si tratta di un oggetto valido
|
1994-09-12 08:02:05 +00:00
|
|
|
virtual bool ok() const;
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Stampa un array
|
1994-09-12 08:02:05 +00:00
|
|
|
virtual void print_on(ostream& out) const;
|
|
|
|
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Modifica la dimensione dell'array.
|
1994-09-12 08:02:05 +00:00
|
|
|
void resize(word size);
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Copia nell'array l'elemento passato come parametro
|
1994-09-12 08:02:05 +00:00
|
|
|
void copy(const TBit_array& ba);
|
1996-02-05 19:00:53 +00:00
|
|
|
// @cmember Ritorna il numero del byte contenente il bit <p n>
|
|
|
|
word index(long n) const
|
|
|
|
{ return word(n >> 3); }
|
|
|
|
// @cmember Ritorna la posizione del bit <p n> all'interno del byte
|
|
|
|
byte mask(long n) const
|
1998-03-13 10:18:29 +00:00
|
|
|
{ return byte(1 << (n & 0x7)); }
|
1994-09-12 08:02:05 +00:00
|
|
|
|
1995-05-10 10:40:40 +00:00
|
|
|
// @access Public Member
|
1994-09-12 08:02:05 +00:00
|
|
|
public:
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Costruttore. Crea un array di (chiama <mf TBit_array::resize>)
|
1994-09-12 08:02:05 +00:00
|
|
|
TBit_array(long size = 0);
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Costruttore. Crea un array di (chiama <mf TBit_array::copy>)
|
1994-09-12 08:02:05 +00:00
|
|
|
TBit_array(const TBit_array& ba);
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Distruttore
|
1995-01-24 08:52:49 +00:00
|
|
|
virtual ~TBit_array();
|
1994-09-12 08:02:05 +00:00
|
|
|
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Assegna all'array l'oggetto passato
|
1994-09-12 08:02:05 +00:00
|
|
|
TBit_array& operator=(const TBit_array& ba);
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Ritorna l'oggetto puntato da n
|
1994-09-12 08:02:05 +00:00
|
|
|
bool operator[] (long n) const;
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Ritorna l'or logico tra due Bit_array modificando l'oggetto corrente
|
1994-09-12 08:02:05 +00:00
|
|
|
TBit_array& operator |=(const TBit_array& b);
|
1994-11-08 16:51:02 +00:00
|
|
|
|
1996-04-12 08:24:51 +00:00
|
|
|
// @cmember Ritorna il numero di bit nell'array
|
|
|
|
long items() const { return 8L * _size; }
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Ritorna la posizione del primo 1 nell'array (-1 se non lo trova)
|
1994-09-12 08:02:05 +00:00
|
|
|
long first_one() const;
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Ritorna la posizione dell'ultimo 1 nell'array (-1 se non lo trova)
|
1994-09-12 08:02:05 +00:00
|
|
|
long last_one() const;
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Ritorna il numero di 1 presenti nell'array
|
1994-09-12 08:02:05 +00:00
|
|
|
long ones() const;
|
|
|
|
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Setta ad 1 il bit n-esimo dell'array
|
1994-09-12 08:02:05 +00:00
|
|
|
void set(long n);
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Setta a 0 il bit n-esimo dell'array
|
1994-09-12 08:02:05 +00:00
|
|
|
void reset(long n);
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Not logico del bit n-esimo dell'array
|
2004-03-12 14:52:53 +00:00
|
|
|
void neg(long n);
|
1994-09-12 08:02:05 +00:00
|
|
|
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Setta il bit n-esimo a seconda del valore passato come secondo elemento
|
1994-09-12 08:02:05 +00:00
|
|
|
void set(long n, bool on) { on ? set(n) : reset(n); }
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Setta ad 1 tutti i bit dell'array
|
1994-09-12 08:02:05 +00:00
|
|
|
void set();
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Setta a 0 tutti i bit dell'array
|
1994-09-12 08:02:05 +00:00
|
|
|
void reset();
|
1995-05-10 10:40:40 +00:00
|
|
|
// @cmember Data una stringa setta ad 1 gli elementi indicati della stringa
|
1994-09-12 08:02:05 +00:00
|
|
|
void set(const char* numbers);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|