Patch level : 12.0 no patch
Files correlati : Commento Bit array Aggiunte funzioni insert e pack ai Bit array
This commit is contained in:
parent
fd0b2b3299
commit
732003b79f
@ -837,6 +837,31 @@ TBit_array::~TBit_array()
|
||||
delete _bit;
|
||||
}
|
||||
|
||||
void TBit_array::insert(long n, bool on)
|
||||
{
|
||||
if (n < 0)
|
||||
n = 0;
|
||||
|
||||
const int last = last_one();
|
||||
|
||||
if (last >= n)
|
||||
for (word i = last_one(); i >= n; i--)
|
||||
set(i + 1, operator [](i));
|
||||
set(n, on);
|
||||
}
|
||||
|
||||
void TBit_array::pack(long n)
|
||||
{
|
||||
if (n < 0)
|
||||
n = 0;
|
||||
|
||||
const int last = last_one();
|
||||
|
||||
if (last > n)
|
||||
for (word i = n; i < last; i++)
|
||||
set(i, operator [](i + 1));
|
||||
reset(last);
|
||||
}
|
||||
// Certified 100%
|
||||
void TBit_array::set()
|
||||
{
|
||||
|
@ -396,6 +396,10 @@ public:
|
||||
// @cmember Not logico del bit n-esimo dell'array
|
||||
void neg(long n);
|
||||
|
||||
// @cmember inserisce e setta il bit n-esimo a seconda del valore passato come secondo elemento
|
||||
void insert(long n, bool on = false);
|
||||
// @cmember elimina il bit n-esimo
|
||||
void pack(long n);
|
||||
// @cmember Setta il bit n-esimo a seconda del valore passato come secondo elemento
|
||||
void set(long n, bool on) { on ? set(n) : reset(n); }
|
||||
// @cmember Setta ad 1 tutti i bit dell'array
|
||||
|
Loading…
x
Reference in New Issue
Block a user