예제 #1
0
void InitBitMask(bitmask *obj, int n)
{
	int i = 0;
	if(!VerifyConsistency(obj)) return;
	obj->mask = (int*)alloc(n, sizeof(int));
	obj->size = n;
	obj->numBits = 0;
	
	for(i = 0; i < n; i++) obj->mask[i] = 0;
}
예제 #2
0
void TDBAccountsPrivate::Load() noexcept
   {
      Q_Q(TDBAccounts);
      VerifyConsistency();
      ASSERT(!Accounts)

      const TAccounts::TStrAccHash &StrAccAccounts = LoadAccounts();
      Accounts = std::unique_ptr<TAccounts>(new TAccounts(StrAccAccounts));

      Connect(ad, Accounts.get(), &TAccounts::on_AccountAdded, [this](const TAccount &Acc) { _q_on_AccountAdded(Acc);});
      Connect(ad, Accounts.get(), &TAccounts::on_AccountDeleted, [this](const QString &Str) { _q_on_AccountDeleted(Str);});
      Connect(ad, Accounts->AccountsWatcher(), &TAccountsWatcher::PasswordChanged,
              [this](const QString &User, const QString &Pass) { _q_on_PasswordChanged(User, Pass); });
      Connect(ad, Accounts->AccountsWatcher(), &TAccountsWatcher::SinceChanged,
              [this](const QString &User, const QDateTime &Since) { _q_on_SinceChanged(User, Since); });
      Connect(ad, Accounts->AccountsWatcher(), &TAccountsWatcher::FriendshipStatusChanged,
                           [this](const QString &User, const Core::TUserHostPort &Friend, const TFriendshipStatus &Status)
                                                                { _q_on_FriendshipStatusChanged(User, Friend, Status); });

      emit q->LoadingFinished();
   }
예제 #3
0
/* Função que adiciona um no bitmask e retorna se o bitmask tem todas as posições setadas. */
int AddBitMask(bitmask *obj)
{
	if(!VerifyConsistency(obj)) return;
	
	int i = 0;
	int surplus = 1;
	
	for(i = obj->size-1; i >= 0; i--)
		if(surplus+obj->mask[i] == 2)
		{
			if(obj->mask[i]) obj->numBits -= 1;
			obj->mask[i] = 0;
		}
		else
		{
			if(!obj->mask[i]) obj->numBits +=1 ;
			obj->mask[i] = 1;
			break;
		}
	
	return obj->numBits == obj->size;
}
예제 #4
0
void ClearBitMask(bitmask *obj)
{
	if(!VerifyConsistency(obj)) return;
	free(obj->mask);
	obj->size = 0;
}