Beispiel #1
0
double CBaseSimCtrl::GetParticlePotentialEnergy_const(size_t ptIndex) const {
    return particles_old[ptIndex].GetPotentialEnergy1D(particles_old[GetNext(ptIndex)],
                                                       particles_old[GetNext(ptIndex)].GetDistanceLeft(particles_old[ptIndex],
                                                                                                       SimulationParameters.SystemSize))
           + particles_old[ptIndex].GetPotentialEnergy1D(particles_old[GetPrevious(ptIndex)],
                                                         particles_old[GetPrevious(ptIndex)].GetDistanceRight(particles_old[ptIndex],
                                                                                                              SimulationParameters.SystemSize));

}
Beispiel #2
0
CPathTrack *CPathTrack::GetNextInDir( bool bForward )
{
	if ( bForward )
		return GetNext();
	
	return GetPrevious();
}
Beispiel #3
0
static int ReplaceWithIterator(Iterator *it, void *data,int direction) 
{
    struct strCollectionIterator *ali = (struct strCollectionIterator *)it;
    int result;
    size_t pos;
    
    if (it == NULL) {
        return NullPtrError("Replace");
    }
    if (ali->SC->count == 0)
        return 0;
    if (ali->timestamp != ali->SC->timestamp) {
        ali->SC->RaiseError("Replace",CONTAINER_ERROR_OBJECT_CHANGED);
        return CONTAINER_ERROR_OBJECT_CHANGED;
    }
    if (ali->SC->Flags & CONTAINER_READONLY) {
        ali->SC->RaiseError("Replace",CONTAINER_ERROR_READONLY);
        return CONTAINER_ERROR_READONLY;
    }    
    pos = ali->index;
    if (direction)
        GetNext(it);
    else
        GetPrevious(it);
    if (data == NULL)
        result = RemoveAt(ali->SC,pos);
    else {
        result = ReplaceAt(ali->SC,pos,data);
    }
    if (result >= 0) {
        ali->timestamp = ali->SC->timestamp;
    }
    return result;
}
Beispiel #4
0
Datei: Test.c Projekt: wugsh/wgs
main()
{
	DList *plist = NULL;
	PNode p = NULL;
	
	plist = InitList();
	p = InsFirst(plist,MakeNode(1));
	InsBefore(plist,p,MakeNode(2));
	InsAfter(plist,p,MakeNode(3));

	printf("p前驱位置的值为%d\n",GetItem(GetPrevious(p)));
	printf("p位置的值为%d\n",GetItem(p));
	printf("p后继位置的值为%d\n",GetItem(GetNext(p)));
	
	
	printf("遍历输出各节点数据项:\n");
	ListTraverse(plist,print);
	printf("除了头节点该链表共有%d个节点\n",GetSize(plist));
	FreeNode(DelFirst(plist));
	printf("删除第一个节点后重新遍历输出为:\n");
	ListTraverse(plist,print);
	printf("除了头节点该链表共有%d个节点\n",GetSize(plist));
	DestroyList(plist);
	printf("链表已被销毁\n");
}
Beispiel #5
0
void
AATPoint::SetTarget(const fixed range, const fixed radial,
                    const TaskProjection &proj)
{
  fixed oldrange = fixed_zero;
  fixed oldradial = fixed_zero;
  GetTargetRangeRadial(oldrange, oldradial);

  const FlatPoint fprev =
    proj.ProjectFloat(GetPrevious()->GetLocationRemaining());
  const FlatPoint floc = proj.ProjectFloat(GetLocation());
  const FlatLine flb (fprev,floc);
  const FlatLine fradius (floc,proj.ProjectFloat(GetLocationMin()));
  const fixed bearing = fixed_minus_one * flb.angle().Degrees();
  const fixed radius = fradius.d();

  fixed swapquadrants = fixed_zero;
  if (positive(range) != positive(oldrange))
    swapquadrants = fixed(180);
  const FlatPoint ftarget1 (fabs(range) * radius *
        cos((bearing + radial + swapquadrants)
            / fixed(360) * fixed_two_pi),
      fabs(range) * radius *
        sin( fixed_minus_one * (bearing + radial + swapquadrants)
            / fixed(360) * fixed_two_pi));

  const FlatPoint ftarget2 = floc + ftarget1;
  const GeoPoint targetG = proj.Unproject(ftarget2);

  SetTarget(targetG, true);
}
void LineEditWithHistory::keyPressEvent(QKeyEvent *event)
{
    if(event->key() == Qt::Key_Up)
    {
        GetPrevious();
        emit UpPressed();
        return;
    }

    if(event->key() == Qt::Key_Down)
    {
        GetNext();
        emit DownPressed();
        return;
    }

    if(event->key() == Qt::Key_Escape)
    {
        setText(m_sEditBuffer.c_str());
        m_nCurrentCommand = m_history.size();
        return;
    }

    QLineEdit::keyPressEvent(event);

    m_sEditBuffer = text().toStdString();
}
Beispiel #7
0
struct ParseTreeNode * Add_PSh(struct ParseTree *__ParseTree,struct ParseTreeNode *__Node, void *__newValue){

	struct ParseTreeNode *_ptrTemp;
	struct ParseTreeNode *_ptrNew;
	struct internals *_ptrInternals = (struct internals *)__ParseTree->internals;

	_ptrNew = (struct ParseTreeNode*)malloc(sizeof(struct ParseTreeNode));
		
	_ptrNew->Value = (void*)malloc(sizeof(_ptrInternals->size));
	_ptrNew->FirstChild =__Node;
	_ptrNew->Next = NULL;
	memcpy(_ptrNew->Value, __newValue,_ptrInternals->size);
	_ptrNew->Parent = __Node->Parent;
	if (__Node->Parent->FirstChild == __Node){
		__Node->Parent->FirstChild =_ptrNew;
		_ptrNew->FirstChild = __Node;
		__Node->Parent = _ptrNew;
		_ptrTemp = __Node;
		while (_ptrTemp->Next !=NULL){
			_ptrTemp->Parent = __Node->Parent;
			_ptrTemp=_ptrTemp->Next;
		}
	}
	else{
		GetPrevious(__Node)->Next =_ptrNew;
		_ptrNew->FirstChild = __Node;
		__Node->Parent = _ptrNew;
	}

		return _ptrNew;
}
Beispiel #8
0
fixed 
OrderedTaskPoint::DoubleLegDistance(const GeoPoint &ref) const
{
  assert(tp_previous);
  assert(tp_next);

  return ::DoubleDistance(GetPrevious()->GetLocationRemaining(),
                          ref, GetNext()->GetLocationRemaining());
}
Beispiel #9
0
/*!	\brief Returns the previous item belonging to the object.

	This version finds only items of the specified type.

	\param foundItem Pointer to a pre-allocated Item that shall be set
		   to the found item.
	\param type The type the found item must have.
	\return \c B_OK, if everything went fine, \c B_ENTRY_NOT_FOUND, if we're
			through.
*/
status_t
ObjectItemIterator::GetPrevious(Item *foundItem, uint32 type)
{
	status_t error = B_OK;
	do {
		error = GetPrevious(foundItem);
	} while (error == B_OK && foundItem->GetType() != type);
	return error;
}
Beispiel #10
0
bool
OrderedTaskPoint::ScanActive(const OrderedTaskPoint &atp)
{
  if (&atp == this)
    active_state = CURRENT_ACTIVE;
  else if (tp_previous &&
           (GetPrevious()->GetActiveState() == CURRENT_ACTIVE ||
            GetPrevious()->GetActiveState() == AFTER_ACTIVE))
    active_state = AFTER_ACTIVE;
  else
    active_state = BEFORE_ACTIVE;

  SetPast(IsPast());

  if (tp_next)
    // propagate to remainder of task
    return GetNext()->ScanActive(atp);

  return !IsPast();
}
Beispiel #11
0
void InternalAllocator::ReleaseAllMemory()
{
	std::lock_guard<std::mutex> l(m_PagesMutex);
	// walk all pages backwards and kill them
	Page* next = m_Tail;
	while(next) {
		auto current = next;
		next = current->GetPrevious();
		current->~Page();
		m_ExternalAllocator->Deallocate(current->GetMemory());
	}
}
Beispiel #12
0
bool
OrderedTaskPoint::ScanActive(const OrderedTaskPoint &atp)
{
  // reset
  active_state = NOTFOUND_ACTIVE;

  if (&atp == this)
    active_state = CURRENT_ACTIVE;
  else if (tp_previous &&
           (GetPrevious()->GetActiveState() == CURRENT_ACTIVE ||
            GetPrevious()->GetActiveState() == AFTER_ACTIVE))
    active_state = AFTER_ACTIVE;
  else
    active_state = BEFORE_ACTIVE;

  if (tp_next)
    // propagate to remainder of task
    return GetNext()->ScanActive(atp);

  return active_state != BEFORE_ACTIVE && active_state != NOTFOUND_ACTIVE;
}
BOOL CDownloads::CheckActive(CDownload* pDownload, int nScope) const
{
	for ( POSITION pos = GetReverseIterator() ; pos && nScope > 0 ; )
	{
		CDownload* pTest = GetPrevious( pos );
		BOOL bActive = pTest->IsPaused() == FALSE && pTest->IsCompleted() == FALSE;
		
		if ( pDownload == pTest ) return bActive;
		if ( bActive ) nScope--;
	}
	
	return FALSE;
}
Beispiel #14
0
Datei: DList.c Projekt: wugsh/wgs
/*将一个链表置为空表,释放原链表节点空间*/
void ClearList(DList *plist)
{
	PNode temp,p;
	p = GetTail(plist);
	while(!IsEmpty(plist))
	{	
		temp = GetPrevious(p);
		FreeNode(p);
		p = temp;
		plist->tail = temp;
		plist->size--;
	}
}
Beispiel #15
0
Buffer LogIterator::GetPrevious() {
  if (!record_iterator.GetPrevious()) {
    if (!current_section->GetPrevious()) {
      return Buffer::Deleted();
    } else {
      record_iterator = (**current_section)->Last();
      return GetPrevious();
    }
  } else {
    ASSERT_TRUE(record_iterator.IsValid());
    return record_iterator.AsData();
  }
}
Beispiel #16
0
double CBaseSimCtrl::GetParticlePotentialEnergy(size_t ptIndex) {
    auto& next = particles_old[GetNext(ptIndex)];
    auto& prev = particles_old[GetPrevious(ptIndex)];

    if(prev.Moved || next.Moved || particles_old[ptIndex].Moved) {
        particles_old[ptIndex].NewPotentialEnergy =
                particles_old[ptIndex].GetPotentialEnergy1D(next, next.GetDistanceLeft(particles_old[ptIndex], SimulationParameters.SystemSize))
                + particles_old[ptIndex].GetPotentialEnergy1D(prev, prev.GetDistanceRight(particles_old[ptIndex], SimulationParameters.SystemSize));

        return particles_old[ptIndex].NewPotentialEnergy;
    } else {
        return particles_old[ptIndex].PotentialEnergy;
    }
}
SCH_ITEM* SCH_SHEET_LIST::FindPreviousItem( KICAD_T aType, SCH_SHEET_PATH** aSheetFoundIn,
                                            SCH_ITEM* aLastItem, bool aWrap )
{
    bool hasWrapped = false;
    bool firstItemFound = false;
    SCH_ITEM* drawItem = NULL;
    SCH_SHEET_PATH* sheet = GetLast();

    while( sheet )
    {
        drawItem = sheet->FirstDrawList();

        while( drawItem )
        {
            if( drawItem->Type() == aType )
            {
                if( aLastItem == NULL || firstItemFound )
                {
                    if( aSheetFoundIn )
                        *aSheetFoundIn = sheet;

                    return drawItem;
                }
                else if( !firstItemFound && drawItem == aLastItem )
                {
                    firstItemFound = true;
                }
            }

            drawItem = drawItem->Back();
        }

        sheet = GetPrevious();

        if( sheet == NULL && aLastItem && aWrap && !hasWrapped )
        {
            hasWrapped = true;
            sheet = GetLast();
        }
    }

    return NULL;
}
Beispiel #18
0
void
AATPoint::GetTargetRangeRadial(fixed &range, fixed &radial) const
{
  const fixed oldrange = range;

  const GeoPoint fprev = GetPrevious()->GetLocationRemaining();
  const GeoPoint floc = GetLocation();
  const Angle radialraw = (floc.Bearing(GetTargetLocation()) -
      fprev.Bearing(floc)).AsBearing();

  const fixed d = floc.Distance(GetTargetLocation());
  const fixed radius = floc.Distance(GetLocationMin());
  const fixed rangeraw = min(fixed_one, d / radius);

  radial = radialraw.AsDelta().Degrees();
  const fixed rangesign = (fabs(radial) > fixed(90)) ?
      fixed_minus_one : fixed_one;
  range = rangeraw * rangesign;

  if ((oldrange == fixed_zero) && (range == fixed_zero))
    radial = fixed_zero;
}
Beispiel #19
0
RangeAndRadial
AATPoint::GetTargetRangeRadial(fixed oldrange) const
{
  const auto fprev = GetPrevious()->GetLocationRemaining();
  const auto floc = GetLocation();
  const auto radialraw = (floc.Bearing(GetTargetLocation()) -
      fprev.Bearing(floc)).AsBearing();
  auto radial = radialraw.AsDelta();

  auto d = floc.Distance(GetTargetLocation());
  if (radial < -Angle::QuarterCircle() || radial > Angle::QuarterCircle())
    d = -d;

  const auto radius = negative(d)
    ? floc.Distance(GetLocationMin())
    : floc.Distance(GetLocationMax());
  const auto range = Clamp(d / radius, fixed(-1), fixed(1));

  if (oldrange == fixed(0) && range == fixed(0))
    radial = Angle::Zero();

  return RangeAndRadial{ range, radial };
}
Beispiel #20
0
void
AATPoint::SetTarget(RangeAndRadial rar, const FlatProjection &proj)
{
  const auto fprev =
    proj.ProjectFloat(GetPrevious()->GetLocationRemaining());
  const auto floc = proj.ProjectFloat(GetLocation());
  const FlatLine flb (fprev,floc);
  const FlatLine fradius(floc,
                         proj.ProjectFloat(negative(rar.range)
                                           ? GetLocationMin()
                                           : GetLocationMax()));
  const auto radius = fradius.d() * fabs(rar.range);

  const auto angle = rar.radial - flb.angle();

  const FlatPoint ftarget1(radius * angle.cos(),
                           radius * -(angle).sin());

  const auto ftarget2 = floc + ftarget1;
  const auto targetG = proj.Unproject(ftarget2);

  SetTarget(targetG, true);
}
Beispiel #21
0
 gcc_pure
 bool valid() const {
   return GetPrevious() != NULL && GetNext() != NULL;
 }
Beispiel #22
0
CVector CLangevinSimCtrl::GetTorqueNew(size_t ptIndex) {
    return particles_new[ptIndex].GetTorqueFromOther(particles_new[GetPrevious(ptIndex)],
                                                              particles_new[GetNext(ptIndex)]);

}
Beispiel #23
0
double CLangevinSimCtrl::GetForceNew(size_t ptIndex) {
    return particles_new[ptIndex].GetForceFromOther(particles_old[GetPrevious(ptIndex)],
                                                             particles_old[GetNext(ptIndex)]);

}
Beispiel #24
0
bool
FinishPoint::EntryPrecondition() const
{
  return GetPrevious() != NULL && GetPrevious()->HasEntered();
}