コード例 #1
0
ファイル: BinaryNodeTree.cpp プロジェクト: kylienic/CTP-250
BinaryNode<ItemType>* BinaryNodeTree<ItemType>::removeValue(BinaryNode<ItemType>* subTreePtr,
                                                            const ItemType target,
                                                            bool& success)
{
   if(subTreePtr == nullptr) // not found here
      return nullptr;

   if (subTreePtr->getItem() == target) // found it
   {
      subTreePtr = moveValuesUpTree(subTreePtr);
      success = true;
      return subTreePtr;
   }
   else 
   {
      BinaryNode<ItemType>* targetNodePtr = removeValue(subTreePtr->getLeftChildPtr(), target, success);
      subTreePtr->setLeftChildPtr(targetNodePtr);
      if (!success) // no need to search right subTree
      {
         targetNodePtr = removeValue(subTreePtr->getRightChildPtr(), target, success);
         subTreePtr->setRightChildPtr(targetNodePtr);
      }  // end if
      
      return subTreePtr;
   }  // end if
}  // end removeValue
コード例 #2
0
// Reduce the complexity of a configuration request to ask for less
// because the previous request did not result in success.  Returns
// true if the complexity was reduced, or false if no further
// reductions in complexity are possible.
bool QEglProperties::reduceConfiguration()
{
    // EGL chooses configs with the highest color depth over
    // those with smaller (but faster) lower color depths. One
    // way around this is to set EGL_BUFFER_SIZE to 16, which
    // trumps the others. Of course, there may not be a 16-bit
    // config avaliable, so it's the first restraint we remove.
    if (value(EGL_BUFFER_SIZE) == 16) {
        removeValue(EGL_BUFFER_SIZE);
        return true;
    }
    if (removeValue(EGL_SAMPLE_BUFFERS)) {
        removeValue(EGL_SAMPLES);
        return true;
    }
    if (removeValue(EGL_ALPHA_SIZE)) {
#if defined(EGL_BIND_TO_TEXTURE_RGBA) && defined(EGL_BIND_TO_TEXTURE_RGB)
        if (removeValue(EGL_BIND_TO_TEXTURE_RGBA))
            setValue(EGL_BIND_TO_TEXTURE_RGB, TRUE);
#endif
        return true;
    }
    if (removeValue(EGL_STENCIL_SIZE))
        return true;
    if (removeValue(EGL_DEPTH_SIZE))
        return true;
#if defined(EGL_BIND_TO_TEXTURE_RGB)
    if (removeValue(EGL_BIND_TO_TEXTURE_RGB))
        return true;
#endif
    return false;
}
コード例 #3
0
// Reduce the complexity of a configuration request to ask for less
// because the previous request did not result in success.  Returns
// true if the complexity was reduced, or false if no further
// reductions in complexity are possible.
bool QEglProperties::reduceConfiguration()
{
    if (removeValue(EGL_SAMPLE_BUFFERS)) {
        removeValue(EGL_SAMPLES);
        return true;
    }
    if (removeValue(EGL_ALPHA_SIZE))
        return true;
    if (removeValue(EGL_STENCIL_SIZE))
        return true;
    if (removeValue(EGL_DEPTH_SIZE))
        return true;
    return false;
}
コード例 #4
0
ファイル: account-shared.cpp プロジェクト: partition/kadu
void AccountShared::store()
{
	if (!isValidStorage())
		return;

	Shared::store();

	storeValue("Identity", AccountIdentity.uuid().toString());

	storeValue("Protocol", ProtocolName);
	storeValue("Id", id());

	storeValue("RememberPassword", RememberPassword);
	if (RememberPassword && HasPassword)
		storeValue("Password", pwHash(password()));
	else
		removeValue("Password");

	storeValue("UseProxy", ProxySettings.enabled());
	storeValue("ProxyHost", ProxySettings.address());
	storeValue("ProxyPort", ProxySettings.port());
	storeValue("ProxyRequiresAuthentication", ProxySettings.requiresAuthentication());
	storeValue("ProxyUser", ProxySettings.user());
	storeValue("ProxyPassword", ProxySettings.password());

	storeValue("PrivateStatus", PrivateStatus);
}
コード例 #5
0
ファイル: AutomationPattern.cpp プロジェクト: Cubiicle/lmms
void AutomationPattern::processMidiTime( const MidiTime & time )
{
	if( ! isRecording() )
	{
		if( time >= 0 && hasAutomation() )
		{
			const float val = valueAt( time );
			for( objectVector::iterator it = m_objects.begin();
							it != m_objects.end(); ++it )
			{
				if( *it )
				{
					( *it )->setAutomatedValue( val );
				}

			}	
		}
	}
	else
	{
		if( time >= 0 && ! m_objects.isEmpty() )
		{
			const float value = static_cast<float>( firstObject()->value<float>() );
			if( value != m_lastRecordedValue ) 
			{
				putValue( time, value, true );
				m_lastRecordedValue = value;
			}
			else if( valueAt( time ) != value )
			{
				removeValue( time, false );
			}
		}
	}
}
コード例 #6
0
// Reduce the complexity of a configuration request to ask for less
// because the previous request did not result in success.  Returns
// true if the complexity was reduced, or false if no further
// reductions in complexity are possible.
bool QEglProperties::reduceConfiguration()
{
#ifdef EGL_SWAP_BEHAVIOR
    if (value(EGL_SWAP_BEHAVIOR) != EGL_DONT_CARE)
        removeValue(EGL_SWAP_BEHAVIOR);
#endif

#ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT
    // For OpenVG, we sometimes try to create a surface using a pre-multiplied format. If we can't
    // find a config which supports pre-multiplied formats, remove the flag on the surface type:
    EGLint surfaceType = value(EGL_SURFACE_TYPE);
    if (surfaceType & EGL_VG_ALPHA_FORMAT_PRE_BIT) {
        surfaceType ^= EGL_VG_ALPHA_FORMAT_PRE_BIT;
        setValue(EGL_SURFACE_TYPE, surfaceType);
        return true;
    }
#endif
    // EGL chooses configs with the highest color depth over
    // those with smaller (but faster) lower color depths. One
    // way around this is to set EGL_BUFFER_SIZE to 16, which
    // trumps the others. Of course, there may not be a 16-bit
    // config available, so it's the first restraint we remove.
    if (value(EGL_BUFFER_SIZE) == 16) {
        removeValue(EGL_BUFFER_SIZE);
        return true;
    }
    if (removeValue(EGL_SAMPLE_BUFFERS)) {
        removeValue(EGL_SAMPLES);
        return true;
    }
    if (removeValue(EGL_ALPHA_SIZE)) {
#if defined(EGL_BIND_TO_TEXTURE_RGBA) && defined(EGL_BIND_TO_TEXTURE_RGB)
        if (removeValue(EGL_BIND_TO_TEXTURE_RGBA))
            setValue(EGL_BIND_TO_TEXTURE_RGB, TRUE);
#endif
        return true;
    }
    if (removeValue(EGL_STENCIL_SIZE))
        return true;
    if (removeValue(EGL_DEPTH_SIZE))
        return true;
#ifdef EGL_BIND_TO_TEXTURE_RGB
    if (removeValue(EGL_BIND_TO_TEXTURE_RGB))
        return true;
#endif
    return false;
}
コード例 #7
0
ファイル: qpresence.cpp プロジェクト: muromec/qtopia-ezx
/*!
    Called from server implementations to update the monitoring \a status
    of \a uri.  This function will update the global state as seen by
    monitoredUriStatus() and then emits monitoredPresence().

    \sa monitoredPresence(), startMonitoring(), stopMonitoring()
*/
void QPresence::updateMonitoredPresence
        ( const QString& uri, QPresence::Status status )
{
    if ( mode() != Server )
        return;
    if ( status == Unavailable )
        removeValue( makeSafe( uri ) );
    else
        setValue( makeSafe( uri ), (int)status );
    emit monitoredPresence( uri, status );
}
コード例 #8
0
ファイル: AutomationPattern.cpp プロジェクト: Lukas-W/lmms
void AutomationPattern::recordValue(MidiTime time, float value)
{
	if( value != m_lastRecordedValue )
	{
		putValue( time, value, true );
		m_lastRecordedValue = value;
	}
	else if( valueAt( time ) != value )
	{
		removeValue( time );
	}
}
コード例 #9
0
ファイル: contact-shared.cpp プロジェクト: vogel/kadu
void ContactShared::store()
{
    if (!isValidStorage())
        return;

    ensureLoaded();

    Shared::store();

    storeValue("Id", Id);
    storeValue("Priority", Priority);

    storeValue("Dirty", RosterEntryState::Synchronized != Entry->state());
    // Detached property needs to be always stored, see the load() method.
    storeValue("Detached", RosterEntryState::Detached == Entry->state());

    storeValue("Account", ContactAccount->uuid().toString());
    storeValue("Buddy", !isAnonymous() ? OwnerBuddy->uuid().toString() : QString());
    removeValue("Avatar");
    removeValue("Contact");
}
コード例 #10
0
ファイル: qusbstoragegadget.cpp プロジェクト: Camelek/qtmoko
/*!
    Initialize the gadget from settings in the configuration file.
*/
void QUsbStorageGadgetProvider::initFromConfig()
{
    QSettings settings("Trolltech", "Usb");

    settings.beginGroup(GADGET_NAME);

    QVariant v = settings.value("Vendor");
    if (v.isValid())
        setVendor(v.toByteArray());
    else
        removeValue("vendor");

    v = settings.value("VendorId");
    if (v.isValid())
        setVendorId(v.toUInt());
    else
        removeValue("vendorId");

    v = settings.value("Product");
    if (v.isValid())
        setProduct(v.toByteArray());
    else
        removeValue("product");

    v = settings.value("ProductId");
    if (v.isValid())
        setProductId(v.toUInt());
    else
        removeValue("productId");

    v = settings.value("BackingStore");
    if (v.isValid())
        setBackingStore(v.toStringList());
    else
        removeValue("backingStore");

    settings.endGroup();

    setValue("active", false);
}
コード例 #11
0
void MusicConnectionPool::removeValue(const QObject *object)
{
    QMapIterator<QString, QObject*> i(m_para);
    while(i.hasNext())
    {
        i.next();
        if(i.value() == object)
        {
            removeValue(i.key());
            break;
        }
    }
}
コード例 #12
0
int TraceDialog::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDialog::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: addValue(); break;
        case 1: removeValue(); break;
        case 2: cleanAllValue(); break;
        case 3: toDefault(); break;
        case 4: getList(); break;
        }
        _id -= 5;
    }
    return _id;
}
コード例 #13
0
ファイル: ValueManager.cpp プロジェクト: nerd-toolkit/nerd
/**
 * Remove all occurences of value from the ValueManager. Thus if the Value was registered with
 * different names, then all names are released.
 *
 * @param value the value to remove.
 * @return true if successful, otherwise false.
 */
bool ValueManager::removeValue(Value *value) {
    if(value == 0) {
        return false;
    }
    QMutexLocker guard(&mMutex);

    QList<QString> names = mValues.keys(value);

    if(names.empty()) {
        return false;
    }
    for(int i = 0; i < names.size(); ++i) {
        removeValue(names.at(i));
    }

    return true;
}
コード例 #14
0
ファイル: Task3.cpp プロジェクト: MrKuznetsov/hw-cpp
int _tmain(int argc, _TCHAR* argv[])
{
	printf("0 - exit\n");
    printf("1 - add value to sorted list\n");
    printf("2 - remove value from list\n");
    printf("3 - print list\n");

	IntList *head = newList(-1);

	while(true)
	{
		printf("Input command:\n");
		int command = 0;
		scanf("%d", &command);
		int val = 0;
		switch (command)
		{
			case 0:
				deleteList(head);
				return 0;
			case 1:
				printf("Input value:\n");
				
				scanf("%d", &val);
				addToSortedList(head, val);
				break;
			case 2:
				printf("Input value:\n");
				
				scanf("%d", &val);
				removeValue(head, val);
				break;
			case 3:
				printList(head);
				break;
		};

	}
	
	deleteList(head);

	scanf("%*s");
	return 0;
}
コード例 #15
0
bool MemoryMappedDevice::writeBlock(qint32 key, const QByteArray& block)
{
    Q_D(MemoryMappedDevice);
    if (!d->m_device)
        return false;
    if (!d->m_device->isOpen()) {
        if (!d->m_device->open(QIODevice::ReadWrite))
            return false;
    }
    if (!d->m_device->isWritable())
        return false;
    d->m_device->setTextModeEnabled(false);
    auto itemIter = d->m_itemsMap.find(key);
    if (itemIter != d->m_itemsMap.end()) {
        removeValue(key);
    }
    d->m_itemsMap.insert(key, writeInMap(block));
    return true;
}
コード例 #16
0
ファイル: qpresence.cpp プロジェクト: muromec/qtopia-ezx
/*!
    Stop monitoring \a uri for presence changes.  Returns false if \a uri
    was not currently being monitored by this object, or there are still
    remaining references to \a uri in the system.  Monitoring will be
    implicitly stopped when this object is destroyed.

    Server implementations that inherit from QPresence should call this
    base implementation before performing any other action.

    \sa monitoredPresence(), startMonitoring()
*/
bool QPresence::stopMonitoring( const QString& uri )
{
    if ( d->monitored.contains( uri ) ) {
        if ( --( d->monitored[uri] ) == 0 ) {
            d->monitored.remove( uri );
            if ( mode() == Client ) {
                invoke( SLOT(stopMonitoring(QString)), uri );
            } else {
                setValue( "allMonitoredUris",
                          QStringList( d->monitored.keys() ), Delayed );
                removeValue( makeSafe( uri ) );
            }
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
コード例 #17
0
bool filter(bool induced, Tdomain* D, Tgraph* Gp, Tgraph* Gt){
	// filter domains of all vertices in D->toFilter wrt LAD and ensure GAC(allDiff)
	// return false if some domain becomes empty; true otherwise
	int u, v, i, oldNbVal;
	while (!toFilterEmpty(D)){
		while (!toFilterEmpty(D)){
			u=nextToFilter(D,Gp->nbVertices); 
			oldNbVal = D->nbVal[u];
			i=D->firstVal[u]; 
			while (i<D->firstVal[u]+D->nbVal[u]){
				// for every target node v in D(u), check if G_(u,v) has a covering matching
				v=D->val[i]; 
				if (checkLAD(induced,u,v,D,Gp,Gt)) i++;
				else if (!removeValue(u,v,D,Gp,Gt)) return false;
			}
			if ((D->nbVal[u]==1) && (oldNbVal>1) && (!matchVertex(u,induced,D,Gp,Gt))) return false;
			if (D->nbVal[u]==0) return false;
		}
		if (!ensureGACallDiff(induced,Gp,Gt,D)) return false;
	}
	return true;
}
コード例 #18
0
void test_remove_using_integer_key(){
	CustomerInteger *checkout;
 	CustomerInteger newCustomerInteger1 = {"Ajit",{"Ascendas Road","Chennai","Tamil Nadu"},{91,999125}};
 	CustomerInteger newCustomerInteger2 = {"Baljit",{"Barwala Road","Hisar", "Haryana"},{92,92948}};
 	CustomerInteger newCustomerInteger3 = {"Kuldeep",{"Barwala Road","Hisar", "Haryana"},{91,82948}};
 	CustomerInteger newCustomerInteger4 = {"Mohan",{"Hansi Road","Hansi", "Haryana"},{93,72941}};
 	PhoneNumberInteger number1 = {91,999125};
 	PhoneNumberInteger number2 = {92,92948};
 	PhoneNumberInteger number3 = {91,82948};
 	PhoneNumberInteger number4 = {93,72941};
 	PhoneNumberInteger key1 = {93,72941};

	put(map2, &number1, &newCustomerInteger1);
	put(map2, &number2, &newCustomerInteger2);
	put(map2, &number3, &newCustomerInteger3);
	put(map2, &number4, &newCustomerInteger4);

	removeValue(map2, &key1);

	checkout = get(map2, &key1);

	ASSERT(checkout == NULL);
}
コード例 #19
0
void test_remove_key(){
	Customer *checkout;
 	Customer newCustomer1 = {"Ajit",{"Ascendas Road","Chennai","Tamil Nadu"},{"+91","9991250770"}};
 	Customer newCustomer2 = {"Baljit",{"Barwala Road","Hisar", "Haryana"},{"+92","9294856534"}};
 	Customer newCustomer3 = {"Kuldeep",{"Barwala Road","Hisar", "Haryana"},{"+91","8294856534"}};
 	Customer newCustomer4 = {"Mohan",{"Hansi Road","Hansi", "Haryana"},{"+93","7294124343"}};
 	PhoneNumber number1 = {"+91","9991250770"};
 	PhoneNumber number2 = {"+92","9294856534"};
 	PhoneNumber number3 = {"+91","8294856534"};
 	PhoneNumber number4 = {"+93","7294124343"};
 	PhoneNumber key1 = {"+93","7294124343"};

	put(map, &number1, &newCustomer1);
	put(map, &number2, &newCustomer2);
	put(map, &number3, &newCustomer3);
	put(map, &number4, &newCustomer4);

	removeValue(map, &key1);

	checkout = get(map, &key1);

	ASSERT(checkout == NULL);
}
コード例 #20
0
ファイル: WizXmlRpc.cpp プロジェクト: JamesLinus/WizQTClient
/* ------------------------- CWizXmlRpcStructValue ------------------------- */
void WizXmlRpcStructValue::addValue(const QString& strName, WizXmlRpcValue* pValue)
{
    removeValue(strName);
    m_map[strName] = pValue;
}
コード例 #21
0
void SynopsisMD2::merge(int parent_lvl, int left_idx, int parent_idx)
{
  int lvl = parent_lvl;

  bool updateClock = false;

  if(lvl+1 == prev_victim.lvl && (prev_victim.idx == left_idx || prev_victim.idx == left_idx+1))
	updateClock = true;
  int right_idx = left_idx + 1;

  assert(isLeaf(lvl+1,left_idx) && isLeaf(lvl+1,right_idx));

  int leaf_idx;
  bool left = getLeaf(lvl+1,left_idx,leaf_idx,true);
  int right_leaf = leaf_idx + 1;
  bool right = getLeaf(lvl+1,left_idx+1);
  bool merged_val = left | right;
  int used_val = getUsed(lvl+1,leaf_idx) + getUsed(lvl+1,right_leaf);

/*#if defined(DOTRACE) && defined(TRACEMERGE)
	vector<pair<int,int> > special_nodes;
				pair<int,int> p,l,r;
				p.first =parent_lvl;
				p.second = parent_idx;
				r.first = parent_lvl +1;
				r.second = right_idx;
				l.first = parent_lvl +1;
				l.second = left_idx;
				special_nodes.push_back(p);
				special_nodes.push_back(l);
				special_nodes.push_back(r);
				takeSnapshot(special_nodes,TRACEMERGE);

#endif*/


  removeValue(lvl+1,left_idx);
  removeValue(lvl+1,left_idx); //this is not a mistake
  for(int i=0;i<dim_bits;i++)
	  removeValue(lvl+1,left_idx); //removing dimension bits :)

  removeLeafValue(lvl+1,leaf_idx);
  removeLeafValue(lvl+1,leaf_idx);//this is not a mistake
  setValue(lvl,parent_idx,false); //parent is turned into a leaf node
#ifdef SYNDEBUG
  assert(isLeaf(lvl,parent_idx));
#endif
  int leaf_offset = getLeafOffset(lvl,parent_idx);
  insertLeafValue(lvl,leaf_offset ,merged_val); //used will initially be zero or N/A

 // if(!merged_val) //if it is an empty leaf, adjust its used counter
  {
	  setUsed(lvl,leaf_offset,used_val);
  }


	num_bits = num_bits - (3+dim_bits) - (used_bit_size*1);


  //if we merged a prev.victim -> the prev victim is the parent
  if(updateClock)
  {
	prev_victim.lvl = lvl;
	prev_victim.idx = parent_idx;

  }

}
コード例 #22
0
ファイル: BinaryNodeTree.cpp プロジェクト: kylienic/CTP-250
bool BinaryNodeTree<ItemType>::remove(const ItemType& target)
{
   bool isSuccessful = false;
   rootPtr = removeValue(rootPtr, target, isSuccessful);
   return isSuccessful; 
}  // end remove