Beispiel #1
0
static INT4 Partition(MAP_INT4 *tmp,       /* read-write index map */
                      const MAP_REAL8 *in, /* input map */
                      INT4 left,           /* first element */
                      INT4 right)          /* last element */
{
    INT4 i = left;
    INT4 j = right;
    REAL8 pe;

    /* choose middle element as partition element 
     */
    Exchange(tmp, (i + j) / 2, j);

    pe = Gett(tmp, in, j); /* move pivot to right end */

    while (i < j) {
        while (i < j && Gett(tmp, in, i) <= pe)
            i++;
        while (i < j && Gett(tmp, in, j) >= pe)
            j--;
        if (i < j)
            Exchange(tmp, i, j);
    }
    if (i != right)
        Exchange(tmp, i, right); /* pe to partition location */

    return i; /* return index of partition element */
}
void FTransaction::FObjectRecord::Restore( FTransaction* Owner )
{
	if( !bRestored )
	{
		bRestored = true;
		TArray<uint8> FlipData;
		TArray<FReferencedObject> FlipReferencedObjects;
		TArray<FName> FlipReferencedNames;
		TSharedPtr<ITransactionObjectAnnotation> FlipObjectAnnotation;
		if( Owner->bFlip )
		{
			FlipObjectAnnotation = Object->GetTransactionAnnotation();
			FWriter Writer( FlipData, FlipReferencedObjects, FlipReferencedNames, bWantsBinarySerialization );
			SerializeContents( Writer, -Oper );
		}
		FTransaction::FObjectRecord::FReader Reader( Owner, Data, ReferencedObjects, ReferencedNames, bWantsBinarySerialization );
		SerializeContents( Reader, Oper );
		if( Owner->bFlip )
		{
			Exchange( ObjectAnnotation, FlipObjectAnnotation );
			Exchange( Data, FlipData );
			Exchange( ReferencedObjects, FlipReferencedObjects );
			Exchange( ReferencedNames, FlipReferencedNames );
			Oper *= -1;
		}
	}
}
Beispiel #3
0
void iteration1(void){
  double E=0,M=0,accept=0;

  Exchange(phi,psi,NMAX,LMAX,&E,&M,&accept);
  Exchange(psi,phi,NMAX,LMAX,&E,&M,&accept);
  TotalSpin(phi,psi,rho);

  check_unstable();
}
Beispiel #4
0
float LittleFloat(float f)
{
	union {
		float	f;
		byte	b[4];
	} d;
	d.f = f;
	Exchange(b[0], b[3]);
	Exchange(b[1], b[2]);
	return d.f;
}
Beispiel #5
0
int LittieLong(int l)
{
	union {
		int		i;
		byte	b[4];
	} d;
	d.i = l;
	Exchange(b[0], b[3]);
	Exchange(b[1], b[2]);
	return d.i;
}
Beispiel #6
0
void CMoon::MoveToBlendingTarget( void )
{
	CMoon* pTarget = dynamic_cast<CMoon*>(m_pBlendingTarget);
	if( pTarget )
	{
		Exchange( m_bActive, pTarget->m_bActive );
		Exchange( m_vTranslation, pTarget->m_vTranslation );
		Exchange( m_fRisingRate, pTarget->m_fRisingRate );
		Exchange( m_fFillRate, pTarget->m_fFillRate );
		Super::MoveToBlendingTarget();
	}
}
Beispiel #7
0
/*static*/ void vector_sort<Item>::insertion2(_vector<Item>* pVector)
{
	if(!pVector || 0 == pVector->size())
		return;

	Item itTemp = (*pVector)[0];
	int nPos = 0;
	int i=0;

	for(i=1; i<pVector->size();++i)
		if((*pVector)[i] < (*pVector)[nPos])
			nPos = i;

	if(nPos!=0)
		Exchange((*pVector)[0], (*pVector)[nPos]);

	for(i=2; i<pVector->size(); ++i)
	{
		if((*pVector)[i] >= (*pVector)[i-1])
			continue;

		itTemp = (*pVector)[i];
		nPos = i-1;
		while((*pVector)[nPos]>itTemp)
		{
			(*pVector)[nPos+1] =  (*pVector)[nPos];
			--nPos;
		}
		
		(*pVector)[nPos+1] = itTemp;
	}
};
//Also resets the data in the animation.//
WSL::Components::Algorithimic::SubBase::AllAnimationData WSL::Components::Algorithimic::Animation::GatherData()
{
	WSL::Components::Algorithimic::SubBase::AllAnimationData temp;
	temp = Exchange( temp );
	Restore();
	return temp;
}
Beispiel #9
0
CNetStorageObject SNetStorageRPC::Create(TNetStorageFlags flags)
{
    switch (m_Config.default_storage) {
    /* TConfig::eUndefined is overridden in the constructor */

    case TConfig::eNetStorage:
        break; // This case is handled below the switch.

    case TConfig::eNetCache:
        x_InitNetCacheAPI();
        return CDNCNetStorage::Create(m_NetCacheAPI);

    default: /* TConfig::eNoCreate */
        NCBI_THROW_FMT(CNetStorageException, eAuthError,
                "Object creation is disabled.");
    }

    m_UseNextSubHitID.ProperCommand();
    CJsonNode request(MkStdRequest("CREATE"));

    x_SetStorageFlags(request, flags);

    CNetServerConnection conn;

    string object_loc = Exchange(m_Service,
            request, &conn).GetString("ObjectLoc");

    return new SNetStorageObjectRPC(this, request, conn,
            SNetStorageObjectRPC::eByGeneratedID,
            object_loc, flags, SNetStorageObjectRPC::eWriting);
}
void FTransaction::FObjectRecord::Load(FTransaction* Owner)
{
	// common undo/redo path, we apply the saved state and then swap it for the state we cached in ::Save above
	check(Owner->bFlip);
	if (!bRestored)
	{
		bRestored = true;
		FTransaction::FObjectRecord::FReader Reader(Owner, Data, ReferencedObjects, ReferencedNames, bWantsBinarySerialization);
		SerializeContents(Reader, Oper);
		Exchange(ObjectAnnotation, FlipObjectAnnotation);
		Exchange(Data, FlipData);
		Exchange(ReferencedObjects, FlipReferencedObjects);
		Exchange(ReferencedNames, FlipReferencedNames);
		Oper *= -1;
	}
}
Beispiel #11
0
    virtual bool onPhaseChange(ServerPlayer *shenzhuge) const{
        if(shenzhuge->getPhase() == Player::Draw){
            Exchange(shenzhuge);
        }

        return false;
    }
Beispiel #12
0
void UEditorEngine::mapSendToSwap(UWorld* InWorld)
{
	int32			Count	= 0;
	ULevel*		Level	= InWorld->GetCurrentLevel();
	AActor**	Actors[2];

	// Fire ULevel::LevelDirtiedEvent when falling out of scope.
	FScopedLevelDirtied		LevelDirtyCallback;

	//@todo locked levels - skip for locked levels?
	for( int32 i=2; i<Level->Actors.Num() && Count < 2; i++ )
	{
		AActor*& Actor = Level->Actors[i];
		if( Actor && Actor->IsSelected() )
		{
			Actors[Count] = &Actor;
			Count++;
			Actor->MarkPackageDirty();
			LevelDirtyCallback.Request();
		}
	}

	if( Count == 2 )
	{
		InWorld->GetCurrentLevel()->Actors.ModifyAllItems();
		Exchange( *Actors[0], *Actors[1] );
	}
}
Beispiel #13
0
void FStatsThreadState::AddMessages( TArray<FStatMessage>& InMessages )
{
	bWasLoaded = true;
	TArray<FStatMessage> Messages;
	for( int32 Index = 0; Index < InMessages.Num(); ++Index )
	{
		if( InMessages[Index].NameAndInfo.GetField<EStatOperation>() == EStatOperation::AdvanceFrameEventGameThread )
		{
			ProcessMetaDataForLoad( Messages );
			if( !CondensedStackHistory.Contains( CurrentGameFrame ) && Messages.Num() )
			{
				TArray<FStatMessage>* Save = new TArray<FStatMessage>();
				Exchange( *Save, Messages );
				if( CondensedStackHistory.Num() >= HistoryFrames )
				{
					for( auto It = CondensedStackHistory.CreateIterator(); It; ++It )
					{
						delete It.Value();
					}
					CondensedStackHistory.Reset();
				}
				CondensedStackHistory.Add( CurrentGameFrame, Save );
				GoodFrames.Add( CurrentGameFrame );
			}
		}

		new (Messages)FStatMessage( InMessages[Index] );
	}
	bWasLoaded = false;
}
int randomized_partition(double *Address, int start, int end)
{
	int random_position;

	random_position=random_num(start,end);
	Exchange(&Address[random_position],&Address[end]);
	return partition(Address,start,end);
}
Beispiel #15
0
int NomeCanonico(char *A, bool *simm)
    {
    char Sort[32] = "QRBNPEFGHIJZUVWXqrbnpefghij";
    int j, n, i, SO[MaxNum];
    if (A[0] == 'K' || A[0] == 'k')
        return canonico_windows(A, simm);
    A[MaxNum] = 0;
    for (i = 0; i < MaxNum; i++)
        if (A[i] == '0')
            A[i] = 0;
    for (i = 0; i < MaxNum; i++)
        if (A[i] == 0)
            for (j = i; j < 4; j++)
                A[j] = 0;
    for (i = 0; i < MaxNum; i++)
        if (!strchr(Sort, A[i]))
            A[i] = 0;
    for (n = 0; A[n]; n++);
    for (i = 0; i < n; i++)
        for (j = 0; j < strlen(Sort); j++)
            if (Sort[j] == A[i])
                SO[i] = j;
    for (i = n - 1; i >= 0; i--)
        for (j = i + 1; j < n && SO[j - 1] > SO[j]; j++)
            {
            Exchange(A[j - 1], A[j]);
            Exchange(SO[j - 1], SO[j]);
            }
    if (n == 0)
        *simm = true;
    if (n == 1 && IsUVWXZ(Sort[SO[0]]))
        *simm = true;
    if (n == 2 && Sort[SO[0]] == (Sort[SO[1]] ^ 32))
        *simm = true;
    if (n == 2 && Sort[SO[0]] == 'Z' && Sort[SO[1]] == 'Z')
        *simm = true;
    if (n == 3 && IsUVWXZ(Sort[SO[1]])
       && ((Sort[SO[0]] == 'Z' && Sort[SO[2]] == 'Z') || Sort[SO[0]] == (Sort[SO[2]] ^ 32)))
        *simm = true;
    if (n == 4 && Sort[SO[1]] == 'Z' && Sort[SO[2]] == 'Z'
       && ((Sort[SO[0]] == 'Z' && Sort[SO[3]] == 'Z') || Sort[SO[0]] == (Sort[SO[3]] ^ 32)))
        *simm = true;
    if (n == 4 && (Sort[SO[0]] == (Sort[SO[2]] ^ 32)) && (Sort[SO[1]] == (Sort[SO[3]] ^ 32)))
        *simm = true;
    return n;
    }
Beispiel #16
0
int main()
{
    int *pArray;
    pArray=(int *)malloc(sizeof(int ) * NUMBER);
    InputNumber(pArray,NUMBER);
    Exchange(pArray,NUMBER);
    OutputNumber(pArray,NUMBER);
    return 0;
}
void USkeletalMeshComponent::CompleteParallelBlendPhysics()
{
	Exchange(AnimEvaluationContext.LocalAtoms, AnimEvaluationContext.bDoInterpolation ? CachedLocalAtoms : LocalAtoms);
		
	PostBlendPhysics();

	ParallelAnimationEvaluationTask.SafeRelease();
	ParallelBlendPhysicsCompletionTask.SafeRelease();
}
Beispiel #18
0
short LittleShort(short l)
{
	union {
		short	i;
		byte	b[2];
	} d;
	d.i = l;
	Exchange(b[0], b[1]);
	return d.i;
}
int partition(double *Address, int start, int end)
{
	double pivot;
	int i,j;

	i=start-1;
	pivot=Address[end];

	for (j=start;j<end;j++)
	{
		if (Address[j]<=pivot)
		{
			i++;
			Exchange(&Address[i],&Address[j]);
		}
	}
	Exchange(&Address[end],&Address[i+1]);
	return i+1;
}
Beispiel #20
0
void World::Get(Block * const block_to,
		const ushort x_from, const ushort y_from, const ushort z_from,
		const ushort src, const ushort dest, const ushort num)
{
	Block * const block_from=GetBlock(x_from, y_from, z_from);
	Inventory * const inv=block_from->HasInventory();
	if ( inv && inv->Access() )
	{
		Exchange(block_from, block_to, src, dest, num);
	}
}
Beispiel #21
0
/*
 * set the matrix pivoting elements
 * note: matrix pivoting has been verified to work correctly on december 29, 2007
*/
bool Regress::SetPivot(
    unsigned int _r )       // current diagonal position
{
    for ( unsigned i = ( _r + 1 ); i < factor.size(); ++i )
    {
        if ( !( matrix[ Translate( i, _r ) ] > matrix[ Translate( _r, _r ) ] ) )
        {
            continue;
        }   // search the largest value for pivot

        for ( unsigned int j = 0; j < factor.size(); ++j )
        {
            Exchange( matrix[ Translate( i, j ) ], matrix[ Translate( _r, j ) ] );
        }   // swap the elements in the matrix

        Exchange( factor[ i ], factor[ _r ] );
    }   // perform partial pivoting on the matrix

    return( ( fabs( matrix[ Translate( _r, _r ) ] ) > TOLERANCE_LEVEL ) ? true : false );
}   // end of SetPivot()
//Also stores the information from the animation.//
void WSL::Components::Algorithimic::Animation::ReplaceData( WSL::Components::Algorithimic::SubBase::AllAnimationData data )
{
	storage = Exchange( storage );
	animate = data.GetAnimate();
	delay = data.GetDelay();
	type = data.GetType();
	count = data.GetCount();
	frame = data.GetFrame();
	inc = data.GetIncrement();
	init = data.GetInitialized();
}
Beispiel #23
0
bool SNetStorageRPC::Exists(const string& object_loc)
{
    if (x_NetCacheMode(object_loc))
        try {
            return m_NetCacheAPI.HasBlob(object_loc);
        }
        NETSTORAGE_CONVERT_NETCACHEEXCEPTION("on accessing " + object_loc)

    CJsonNode request(MkObjectRequest("EXISTS", object_loc));

    return Exchange(GetServiceFromLocator(object_loc),
            request).GetBoolean("Exists");
}
Beispiel #24
0
void AActor::PostNetReceive()
{
	ExchangeB( bHidden, SavedbHidden );
	Exchange ( Owner, SavedOwner );

	if (bHidden != SavedbHidden)
	{
		SetActorHiddenInGame(SavedbHidden);
	}
	if (Owner != SavedOwner)
	{
		SetOwner(SavedOwner);
	}
}
void FTransaction::FObjectRecord::Restore( FTransaction* Owner )
{
	if( !bRestored )
	{
		bRestored = true;
		TArray<uint8> FlipData;
		TArray<UObject*> FlipReferencedObjects;
		TArray<FName> FlipReferencedNames;
		if( Owner->bFlip )
		{
			FWriter Writer( FlipData, FlipReferencedObjects, FlipReferencedNames, bWantsBinarySerialization );
			SerializeContents( Writer, -Oper );
		}
		FTransaction::FObjectRecord::FReader Reader( Owner, Data, ReferencedObjects, ReferencedNames, bWantsBinarySerialization );
		SerializeContents( Reader, Oper );
		if( Owner->bFlip )
		{
			Exchange( Data, FlipData );
			Exchange( ReferencedObjects, FlipReferencedObjects );
			Exchange( ReferencedNames, FlipReferencedNames );
			Oper *= -1;
		}
	}
}
Beispiel #26
0
// Used for spatializing channels and autosounds
static void S_SpatializeOrigin(const CVec3 &origin, float master_vol, float dist_mult, int *left_vol, int *right_vol)
{
	if (cls.state != ca_active)
	{
		*left_vol = *right_vol = 255;
		return;
	}

	// calculate stereo seperation and distance attenuation
	CVec3 source_vec;
	VectorSubtract(origin, listener_origin, source_vec);

	float dist = source_vec.NormalizeFast();
	dist -= SOUND_FULLVOLUME;
	if (dist < 0)
		dist = 0;			// close enough to be at full volume
	dist *= dist_mult;		// different attenuation levels

	float d = dot(listener_right, source_vec);

	float lscale, rscale;
	if (dma.channels == 1 || !dist_mult)
	{	// no attenuation = no spatialization
		rscale = 1.0f;
		lscale = 1.0f;
	}
	else
	{
		rscale = 0.5f * (1.0f + d);
		lscale = 0.5f * (1.0f - d);
	}

	// swap left and right volumes
	if (s_reverse_stereo->integer)
		Exchange(lscale, rscale);

	float scale;
	// add in distance effect
	scale = (1.0f - dist) * rscale;
	*right_vol = appRound(master_vol * scale);
	if (*right_vol < 0)
		*right_vol = 0;

	scale = (1.0f - dist) * lscale;
	*left_vol = appRound(master_vol * scale);
	if (*left_vol < 0)
		*left_vol = 0;
}
void CPPageExternalFilters::StepDown(CListCtrl& list)
{
    POSITION pos = list.GetFirstSelectedItemPosition();

    if (!pos) {
        return;
    }

    int i = list.GetNextSelectedItem(pos);

    ASSERT(i + 1 < list.GetItemCount());

    Exchange(list, i, i + 1);

    SetModified();
}
Beispiel #28
0
void appReverseBytes(void *Block, int NumItems, int ItemSize)
{
	byte *p1 = (byte*)Block;
	byte *p2 = p1 + ItemSize - 1;
	for (int i = 0; i < NumItems; i++, p1 += ItemSize, p2 += ItemSize)
	{
		byte *p1a = p1;
		byte *p2a = p2;
		while (p1a < p2a)
		{
			Exchange(*p1a, *p2a);
			p1a++;
			p2a--;
		}
	}
}
Beispiel #29
0
void World::Drop(Block * const block_from,
		const ushort x_to, const ushort y_to, const ushort z_to,
		const ushort src, const ushort dest, const ushort num)
{
	Block * block_to=GetBlock(x_to, y_to, z_to);
	if ( AIR==block_to->Sub() ) {
		SetBlock((block_to=NewBlock(PILE, DIFFERENT)),
			x_to, y_to, z_to);
	} else if ( WATER==block_to->Sub() ) {
		Block * const pile = NewBlock(PILE, DIFFERENT);
		SetBlock(pile, x_to, y_to, z_to);
		pile->HasInventory()->Get(block_to);
		block_to = pile;
	}
	Exchange(block_from, block_to, src, dest, num);
	emit Updated(x_to, y_to, z_to);
}
Beispiel #30
0
string SNetStorageRPC::Relocate(const string& object_loc,
        TNetStorageFlags flags)
{
    if (x_NetCacheMode(object_loc))
        NCBI_THROW_FMT(CNetStorageException, eNotSupported, object_loc <<
                ": Relocate for NetCache blobs is not implemented");

    m_UseNextSubHitID.ProperCommand();
    CJsonNode request(MkObjectRequest("RELOCATE", object_loc));

    CJsonNode new_location(CJsonNode::NewObjectNode());

    x_SetStorageFlags(new_location, flags);

    request.SetByKey("NewLocation", new_location);

    return Exchange(GetServiceFromLocator(object_loc),
            request).GetString("ObjectLoc");
}