예제 #1
0
파일: sparselib.c 프로젝트: bremond/siconos
void dswapVector3(sparseVector *sparse1, sparseVector *sparse2, int indexStart, int indexEnd)
{

  REAL *dense1, *dense2;

  if(indexStart<=0)
    indexStart = 1;
  if(indexEnd<=0)
    indexEnd = MAX(lastIndex(sparse1), lastIndex(sparse2));

  if(indexStart <= firstIndex(sparse1) && indexStart <= firstIndex(sparse2) && 
     indexEnd >= lastIndex(sparse1) && indexEnd >= lastIndex(sparse2)) {
    swapVector(sparse1, sparse2);
  }
  else {

    CALLOC(dense1, (indexEnd+1));
    CALLOC(dense2, (indexEnd+1));
    getVector(sparse1, dense1, indexStart, indexEnd, TRUE);
    getVector(sparse2, dense2, indexStart, indexEnd, TRUE);
    clearVector(sparse1, indexStart, indexEnd);
    clearVector(sparse2, indexStart, indexEnd);
    putVector(sparse1, dense2, indexStart, indexEnd);
    putVector(sparse2, dense1, indexStart, indexEnd);
    MEMFREE(dense1);
    MEMFREE(dense2);
  }
}
예제 #2
0
void Loop::reset()
{
	mGui.clear();
	initializeGui();

	mDataStructure.deleteBoids();
	mDataStructure.createRandBoid(PREGEN_BOIDS);
	clearVector(mBlocks);
	clearVector(mTriangles);
	clearVector(mPathVertices);
	mNeighborhoodGraph.clear();

	mTimeScale = 1.0f;
	mIsLeaderOn = false;
	mLeader = 0;
	mIsBoidVectorRendered = false;
	mIsDelaunayRendered = true;
	mIsDelaunayUpToDate = false;
	mFood.setPosition(-10, -10);
	mBoidRules.resetRules();
	mPathFinish = Vector2(GUI_WIDTH + 30.0f, 30.0f);

	updateBoidCounter();
	mGui.updateElementContent(1, mBoidRules.setParameter(mBoidRules.SEPARATION, SEPARATION_DISTANCE));
	mGui.updateElementContent(2, mBoidRules.setParameter(mBoidRules.COHESION, COHESION_DIVISOR));
	mGui.updateElementContent(3, mBoidRules.setParameter(mBoidRules.ALIGNMENT, ALIGNMENT_DIVISOR));
	mGui.updateElementContent(4, mTimeScale * 100);
	mGui.print("");
}
예제 #3
0
status
unlinkVector(Vector v)
{ if ( v->elements != NULL )
    return clearVector(v);

  succeed;
}
예제 #4
0
static status
lowIndexVector(Vector v, Int low)
{ int l  = valInt(low);
  int ol = valInt(v->offset) + 1;

  if ( l > ol )				/* too long */
  { int size = valInt(v->size) + valInt(v->offset) - l;
    if ( size > 0 )
    { Any *elms = alloc(size * sizeof(Any));

      fillVector(v, NIL, toInt(l), toInt(ol-1)); /* dereference */
      cpdata(elms, &v->elements[l-ol], Any, size);
      unalloc(valInt(v->allocated)*sizeof(Any), v->elements);
      v->elements = elms;
      assign(v, size, toInt(size));
      assign(v, allocated, v->size);

      succeed;
    } else
    { return clearVector(v);
    }
  } else if ( l < ol )			/* too, short */
  { return fillVector(v, NIL, toInt(l), toInt(ol-1));
  }

  succeed;
}
예제 #5
0
static status
highIndexVector(Vector v, Int high)
{ int h  = valInt(high);
  int oh = valInt(v->offset) + valInt(v->size);

  if ( oh > h )				/* too long */
  { int size = h - valInt(v->offset);
    if ( size > 0 )
    { Any *elms = alloc(size * sizeof(Any));

      fillVector(v, NIL, inc(high), DEFAULT); /* dereference */
      cpdata(elms, v->elements, Any, size);
      unalloc(valInt(v->allocated)*sizeof(Any), v->elements);
      v->elements = elms;
      assign(v,	size,	   toInt(size));
      assign(v,	allocated, v->size);

      succeed;
    } else
    { return clearVector(v);
    }
  } else if ( oh < h )			/* too, short */
  { return fillVector(v, NIL, toInt(oh+1), inc(high));
  }

  succeed;
}
예제 #6
0
파일: sparselib.c 프로젝트: bremond/siconos
void dswapVector1(sparseVector *sparse, REAL *dense, int indexStart, int indexEnd)
{
  int i, d, n;
  REAL *x;

  if(indexStart <= 0)
    indexStart = 1;
  n = lastIndex(sparse);
  if(indexEnd <= 0) 
    indexEnd = n;
  CALLOC(x, (MAX(indexEnd,n)+1));

  getVector(sparse, x, indexStart, n, FALSE);
  d = getDiagonalIndex(sparse);
  clearVector(sparse, indexStart, n);
  for(i = indexStart; i<=indexEnd; i++) {
    if(dense[i] != 0)
      putItem(sparse, i, dense[i]);
  }
  for(i = indexEnd+1; i<=n; i++) {
    if(x[i] != 0)
      putItem(sparse, i, x[i]);
  }
  MEMCOPY(&dense[indexStart], &x[indexStart], (indexEnd-indexStart+1));

#ifdef DEBUG_SPARSELIB
  verifyVector(sparse);
#endif
  
  MEMFREE(x);
}
예제 #7
0
 vector<vector<int> > combinationSum(vector<int> &candidates, int target) {
     // Start typing your C/C++ solution below
     // DO NOT write int main() function
     std::sort(candidates.begin(),candidates.end());
     vector<int>tmp;clearVector(rs);this->candidates=candidates;
     this->target=target;
     dfs(tmp,0,0);
     return rs;
 }
예제 #8
0
파일: sparselib.c 프로젝트: bremond/siconos
void fillVector(sparseVector *sparse, int count, REAL value)
{
  int i;

  if(sparse->count > 0) 
    clearVector(sparse, 0, 0);
  for(i = 1; i<=count; i++)
    putItem(sparse, i, value);
}
예제 #9
0
void Loop::findPath()
{
	//Run triangulation if topology changed
	if (!mIsDelaunayUpToDate)
	{
		clearVector(mVertices);

		for (std::vector<Block>::const_iterator it = mBlocks.begin(); it != mBlocks.end(); ++it)
		{
			mVertices.push_back(it->getPosition());
		}

		//Screen corners
		mVertices.push_back(Vector2(GUI_WIDTH - 1.0f, -1.0f));
		mVertices.push_back(Vector2(SCREEN_WIDTH, -1.0f));
		mVertices.push_back(Vector2(SCREEN_WIDTH, SCREEN_HEIGHT));
		mVertices.push_back(Vector2(GUI_WIDTH - 1.0f, SCREEN_HEIGHT));

		clearVector(mTriangles);

		triangulate(mVertices, mTriangles, mNeighborhoodGraph);
		mIsDelaunayUpToDate = true;
	}

	//If no leader found, only Delaunay triangles drawn
	if (mLeader != 0)
	{
		float xMin = GUI_WIDTH - 1.0f;
		float xMax = SCREEN_WIDTH;
		float yMin = -1.0f;
		float yMax = SCREEN_HEIGHT;
		const float screenBoundaries[] = { xMin, xMax, yMin, yMax };

		clearVector(mPathVertices);
		if (aStar(mPathVertices, mLeader->getPosition(), mPathFinish, mTriangles, mNeighborhoodGraph, mBlocks, screenBoundaries))
		{
			mGui.print("Path found to target.");
		}
		else
		{
			mGui.print("No accessible path to target.");
		}
	}
}
예제 #10
0
/*****************************************************************************
* Function Name: ReadyToAcquireData()
******************************************************************************
* Summary:
*   Operations to indicate that we are ready to acquire the Capsense data.
*
* Parameters:
*   None.
*
* Return:
*   None.
*
* Note:
*
*****************************************************************************/
void ReadyToAcquireData(void)
{
    // Set flags.
    Status_Acquiring = FALSE;
    Status_NoMoreSpace = FALSE;
    Status_Sending = FALSE;
    Status_NoMoreData = FALSE;
    Status_Ready = TRUE;
    
    // Clear previous data.
    clearVector();
}
예제 #11
0
파일: HUD.cpp 프로젝트: bla-rs/Experimental
violet::HUD::~HUD() {
	reset();
	clearMap<PlayerBonusType, StaticObject*> (&m_bonusImg);
	clearVector(&m_inventoryImg);
}
예제 #12
0
CVisualContainer::~CVisualContainer() {
    clearVector();
}
void TrackDisplay::clearMap() {
	std::map<int, std::vector<ogre_tools::BillboardLine*> >::iterator it;
	for (it = lines.begin(); it != lines.end(); it++) {
		clearVector(it->second);
	}
}
예제 #14
0
void SymbolicMX::evaluateSX(const SXMatrixPtrV& input, SXMatrixPtrV& output, const SXMatrixPtrVV& fwdSeed, SXMatrixPtrVV& fwdSens, const SXMatrixPtrVV& adjSeed, SXMatrixPtrVV& adjSens){
  clearVector(adjSeed);
}
예제 #15
0
HitBoxVector::~HitBoxVector()
{
	clearVector();
}
예제 #16
0
AnimatedGif::~AnimatedGif()
{
	clearVector(frames);
}
예제 #17
0
/*****************************************************************************
* Function Name: SendData()
******************************************************************************
* Summary:
*   Operations to send the Capsense data.
*
* Parameters:
*   None.
*
* Return:
*   None.
*
* Note:
*
*****************************************************************************/
void SendData(void)
{
    // Set flags.
    Status_DataAcquired = FALSE;
    Status_Sending = TRUE;
    
    #if LOWPOWERMODE_ENABLED
        // Delay between each send command.
        if (numConnInterval == CONN_INTERVAL_DELAY) {
            numConnInterval = 0u;

    #else
        // Delay so the Event stack doesn't get overloaded.
        TimerDelay_Start();
        if (_Timer_DelayDone) {
            TimerDelay_Stop();
            _Timer_DelayDone = FALSE;
    #endif
    
        // Send as many sets of values as possible (for all sensors).
        if(NO_MORE_DATA == _BLE_sendCapSenseData())
            Status_NoMoreData = TRUE;
        else
            Status_NoMoreData = FALSE;
    }
    
    #if LOWPOWERMODE_ENABLED
        else
            numConnInterval++;
    #endif

}


/*****************************************************************************
* Function Name: ResetSystem()
******************************************************************************
* Summary:
*   Reset everything here.
*
* Parameters:
*   None.
*
* Return:
*   None.
*
* Note:
*
*****************************************************************************/
void ResetSystem(void)
{
    // Clear previous data.
    clearVector();
    
    // Reset status flags.
    Status_Ready = TRUE;
    Status_Acquiring = FALSE;
    Status_NoMoreSpace = FALSE;
    Status_DataAcquired = FALSE;
    Status_Sending = FALSE;
    Status_NoMoreData = FALSE;
    
    // Reset the BLE module.
    _BLE_Reset();
}
예제 #18
0
WhatsappChat::~WhatsappChat()
{
	clearVector(messages);
}
void BuildMessagesThread::run()
{
	if (!lock.tryLockWhile(running))
	{
		return;
	}

	clearVector(messages);

	if (chat != NULL)
	{
		std::vector<WhatsappMessage *> &messages = chat->getMessages(running);
		for (std::vector<WhatsappMessage *>::iterator it = messages.begin(); it != messages.end(); ++it)
		{
			if (!running)
			{
				break;
			}

			WhatsappMessage &message = **it;
			ChatControlMessageFrame *messageFrame = NULL;

			int color;

			if (message.isFromMe())
			{
				color = RGB(190, 240, 150);
			}
			else
			{
				color = RGB(230, 230, 240);
			}

			switch (message.getMediaWhatsappType())
			{
				case MEDIA_WHATSAPP_TEXT:
				{
					messageFrame = new ChatControlMessageFrame(new ChatControlMessageText(message, 0, smileys), 0, color, dateFont);
				} break;
				case MEDIA_WHATSAPP_IMAGE:
				{
					if (message.getRawDataSize() > 0 && message.getRawData() != NULL)
					{
						messageFrame = new ChatControlMessageFrame(new ChatControlMessageImage(message, 0, imageDecoder), 0, color, dateFont);
					}
				} break;
				case MEDIA_WHATSAPP_VIDEO:
				{
					if (message.getRawDataSize() > 0 && message.getRawData() != NULL)
					{
						messageFrame = new ChatControlMessageFrame(new ChatControlMessageVideo(message, 0, imageDecoder), 0, color, dateFont);
					}
				} break;
				case MEDIA_WHATSAPP_LOCATION:
				{
					messageFrame = new ChatControlMessageFrame(new ChatControlMessageLocation(message, 0, imageDecoder), 0, color, dateFont);
				} break;
			}

			if (messageFrame != NULL)
			{
				this->messages.push_back(messageFrame);
			}
		}
	}

	if (running)
	{
		PostMessage(window, WM_CHATCONTROL, CHAT_CONTROL_BUILDING_MESSAGES_FINISHED, 0);
	}

	lock.unlock();
}
ChatControlMessageText::~ChatControlMessageText()
{
	clearVector(elements);
}
예제 #21
0
void BareMesh<GeoShapeType>::clear()
{
    clearVector ( points );
    clearVector ( pointMarkers );
    clearVector ( pointIDs );
    clearVector ( ridges );
    clearVector ( ridgeMarkers );
    clearVector ( ridgeIDs );
    clearVector ( facets );
    clearVector ( facetMarkers );
    clearVector ( facetIDs );
    clearVector ( elements );
    clearVector ( elementMarkers );
    clearVector ( elementIDs );
}