Exemplo n.º 1
0
void QSplitter::moveBefore( int pos, int id, bool upLeft )
{
    QSplitterLayoutStruct *s = data->list.at(id);
    if ( !s )
	return;
    QWidget *w = s->wid;
    if ( w->isHidden() ) {
	moveBefore( pos, id-1, upLeft );
    } else if ( s->isSplitter ) {
	int dd = s->sizer;
	if ( upLeft ) {
	    setG( w, pos-dd+1, dd );
	    moveBefore( pos-dd, id-1, upLeft );
	} else {
	    moveBefore( pos-dd, id-1, upLeft );
	    setG( w, pos-dd+1, dd );
	}
    } else {
	int left = pick( w->pos() );
	int dd = pos - left + 1;
	dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
	int newLeft = pos-dd+1;
	setG( w, newLeft, dd );
	if ( left != newLeft )
	    moveBefore( newLeft-1, id-1, upLeft );
    }
}
Exemplo n.º 2
0
  // 2006-08-24 AF, changed so the function returns a boolean value, true if
  // the cursor is moved.
  bool CellCursor::moveUp()
  {
    // 2006-08-24 AF,
        bool moved( false );

    // 2006-04-27 AF,
    cursorIsMoved();

    if( !hasPrevious() )
    {
      if( parentCell()->hasParentCell() )
      {
        moveBefore( parentCell() );
        moved = true;
      }
    }
    else
    {
      //previous() exists.
      if(previous()->hasChilds())
      {
        if(!previous()->isClosed())
        {
          moveToLastChild(previous());
          moved = true;
        }
        else
        {
          moveBefore(previous());
          moved = true;
        }
      }
      else
      {
        moveBefore(previous());
        moved = true;
      }
    }
    emit positionChanged(x(), y(), 5,5);

    // TMP EMIT
    emit changedPosition();
    return moved;
  }
Exemplo n.º 3
0
/*!
  Moves the left/top edge of the splitter handle with id \a id as
  close as possible to \a p which is the distance from the left (or
  top) edge of the widget.

  \sa idAfter()
*/
void QSplitter::moveSplitter( QCOORD p, int id )
{
    p = adjustPos( p, id );

    QSplitterLayoutStruct *s = data->list.at(id);
    int oldP = orient == Horizontal? s->wid->x() : s->wid->y();
    bool upLeft = p < oldP;

    moveAfter( p, id, upLeft );
    moveBefore( p-1, id-1, upLeft );

    storeSizes();
}
Exemplo n.º 4
0
void bubblePassL(Config &config,SiftMatrix &matrix,Rank *r,Switchable &switchable,Compare &compare) {
	NodeV::reverse_iterator ri;
	for(ri = r->order.rbegin(); ri<r->order.rend()-1; ++ri) {
		if(!compare.comparable(*ri))
			continue;
		for(NodeV::reverse_iterator li = ri+1;li!=r->order.rend(); ++li)
			if(!switchable.canSwitch(*li,*ri))
				break;
			else if(compare.comparable(*li)) {
				if(compare.shouldSwitch(*li,*ri)) {
					moveBefore(config,matrix,*ri,*li);
					ri = li-1;
				}
				break;
			}
	}
}
Exemplo n.º 5
0
void bubblePassR(Config &config,SiftMatrix &matrix,Rank *r,Switchable &switchable,Compare &compare) {
	NodeV::iterator li;
	for(li = r->order.begin(); li<r->order.end()-1; ++li) {
		if(!compare.comparable(*li))
			continue;
		// search to right: if you find something you can't switch, go on to next li
		// if you find something to switch, jump to place it's been put
		for(NodeV::iterator ri = li+1;ri!=r->order.end(); ++ri)
			if(!switchable.canSwitch(*li,*ri))
				break;
			else if(compare.comparable(*ri)) {
				if(compare.shouldSwitch(*li,*ri)) {
					moveBefore(config,matrix,*li,(ri==r->order.end()-1)?0:*(ri+1));
					li = ri;
				}
				break;
			}
	}
}
bool SpeculativeExecutionPass::considerHoistingFromTo(
    BasicBlock &FromBlock, BasicBlock &ToBlock) {
  SmallSet<const Instruction *, 8> NotHoisted;
  const auto AllPrecedingUsesFromBlockHoisted = [&NotHoisted](User *U) {
    for (Value* V : U->operand_values()) {
      if (Instruction *I = dyn_cast<Instruction>(V)) {
        if (NotHoisted.count(I) > 0)
          return false;
      }
    }
    return true;
  };

  unsigned TotalSpeculationCost = 0;
  for (auto& I : FromBlock) {
    const unsigned Cost = ComputeSpeculationCost(&I, *TTI);
    if (Cost != UINT_MAX && isSafeToSpeculativelyExecute(&I) &&
        AllPrecedingUsesFromBlockHoisted(&I)) {
      TotalSpeculationCost += Cost;
      if (TotalSpeculationCost > SpecExecMaxSpeculationCost)
        return false;  // too much to hoist
    } else {
      NotHoisted.insert(&I);
      if (NotHoisted.size() > SpecExecMaxNotHoisted)
        return false; // too much left behind
    }
  }

  if (TotalSpeculationCost == 0)
    return false; // nothing to hoist

  for (auto I = FromBlock.begin(); I != FromBlock.end();) {
    // We have to increment I before moving Current as moving Current
    // changes the list that I is iterating through.
    auto Current = I;
    ++I;
    if (!NotHoisted.count(&*Current)) {
      Current->moveBefore(ToBlock.getTerminator());
    }
  }
  return true;
}
Exemplo n.º 7
0
  /*! Insert this cell as first child of parent.
  *
  * \bug This does not seem to work correctly.
  */
  void CellCursor::moveToFirstChild(Cell *parent)
  {
    // 2006-04-27 AF,
    cursorIsMoved();

    if(parent->hasChilds())
    {
      parent->removeCellWidgets();
      moveBefore(parent->child());
      parent->addCellWidgets();
    }
    else //No child.
    {
      //Become first child.
      parent->removeCellWidgets();
      parent->setChild(this);
      parent->setLast(this);
      parent->addCellWidgets();
    }

    // TMP EMIT
    emit changedPosition();
  }
void main(){
	int input;  // 사용자 입력 코드
	Dlist D = createDlist(); // 사용자 입력으로 아이템이 입력되는 리스트
    
	Dlist D2 = createDlist();   // join용 리스트
	insertHead(D2,10);
	insertHead(D2,13);
	insertHead(D2,17);
	insertHead(D2,19);
	insertHead(D2,21);
	insertHead(D2,26);

	Dlist newList = createDlist();
	printf("==============140529 201100646 김영태 과제==============\n\n");
	printf("주의!! : movebefore시 기준 노드의 유일성을 보장하기 위하여 중복된 값 입력은 허용되지 않습니다. \n");
	printf("주의!! : Join시 합칠 리스트는 코드상에 미리 정의되어있습니다. \n");
	printf("주의!! : 때문에 Join은 한번밖에 실행되지 않습니다.(그 이상 실행할시 에러)\n\n");
	printf("=====================================================\n\n");

	while(1){
		int val;    // 사용자입력에 따른 변수들
		int node_val;
		dnode d;
		dnode d1;
		dnode d2;
		Dlist splitD;
		Dlist temp;
		char* result = "결과 리스트";

		printf("원하시는 동작에 따라서 숫자를 입력해주세요\n");    // 사용자 인터페이스
		printf("(1: insert Head, 2: insert After, 3: insert before, 4: move before, ");
		printf("5: search, 6: split, 7:join) \n");
		scanf("%d", &input);

		switch(input){
			case 1 :    //  insert Head
				printf("삽입을 원하시는 값을 입력해주세요 : ");
				scanf("%d", &val);
				if(search(D,val)){
					printf("중복된 값입니다\n");
					break;
				}
				insertHead(D,val);
				printList(D,result);
				break;
				
				
			case 2 :  // insert After
				printf("삽입을 원하시는 값을 입력해주세요 : ");
				scanf("%d", &val);
				if(search(D,val)){
					printf("중복된 값입니다\n");
					break;
				}
				printf("어느 값의 노드 다음에 삽입을 원하시는지 말씀해주세요\n");
				d = findNode(D);
				if(d == NULL){
					printf("찾으시는 값이 없습니다\n");
					break;
				}else{
					insertAfter(D,d,val);
					printList(D,result);
					break;
				}
			case 3 :    // insert Before
				printf("삽입을 원하시는 값을 입력해주세요 : ");
				scanf("%d", &val);
				if(search(D,val)){
					printf("중복된 값입니다\n");
					break;
				}
				printf("어느 값의 노드 이전에 삽입을 원하시는지 말씀해주세요\n");
				d = findNode(D);
				if(d == NULL){
					printf("찾으시는 값이 없습니다\n");
					break;
				}else{
					insertBefore(D,d,val);
					printList(D,result);
					break;
				}
			case 4 :    //move Before
				printList(D,"현재 리스트");
				printf("옮길 첫번째 노드를 선택해 주세요 \n");
				d1 = findNode(D);
				if(d1 == NULL){
					printf("찾으시는 값이 없습니다\n");
					break;
				}
				printf("옮길 마지막 노드를 선택해 주세요 \n");
				d2 = findNode(D);
				if(d2 == NULL){
					printf("찾으시는 값이 없습니다\n");
					break;
				}
				printf("어느 노드 전으로 옮기실 건가요?(겹치지 않게 주의해주세요.) \n");
				d = findNode(D);
				if(d == NULL){
					printf("찾으시는 값이 없습니다\n");
					break;
				}
				moveBefore(D,d1,d2,d);
				printList(D,result);
				break;

			case 5 :    // search
				if(findNode(D)){
					printList(D,"현재 리스트");
					printf("찾으신 값이 리스트내에 존재합니다.\n");
					break;
				}else{
					printList(D,"현재 리스트");
					printf("찾으신 값이 리스트내에 존재하지 않습니다.\n");
					break;
				}
			case 6 :    // split
				printList(D,"현재 리스트");
				printf("나눌 기준이 되는 노드의 값을 입력하세요 : ");
				scanf("%d",&val);
				d = search(D,val);
				if(d==NULL){
					printf("찾으시는 값이 없습니다\n");
					break;
				}

				splitD = split(D,d);

				printList(D,"기존리스트");
				printList(splitD,"나눠진 리스트");
				break;

			case 7 :    //join
				printList(D,"현재 리스트");
				while(1){

				}
				printList(D2,"조인할 리스트");
				join(D,D2);
				printList(D,"결과");
				break;
			default :   // default input
				printf("잘못된 입력입니다.\n");
				break;
		}

	}

}