Пример #1
0
char* PathBuffer::Set( const char* path )
{
	Clear();

	if ( !currentFsParam ) { return p.data(); }

	if ( currentFsParam->server[0] )
	{
		if ( currentFsParam->user[0] )
		{
			Cut( const_cast<char*>( currentFsParam->user ) );
			Cut( "@" );
		}

		Cut( const_cast<char*>( currentFsParam->server ) );
		Cut( "/" );
	}

	if ( path )
	{
		if ( path[0] == '/' ) { path++; }

		Cut( path );
	}

	return p.data();
}
void TectonicPlateSimulation::randomCut(int n = 1) {
    for(int i = 0; i < n; i++) {
        if(drand48() < 0.5) {
            b2Vec2 v1(-20, drand48() * 40);
            b2Vec2 v2(20, drand48() * 40);
            Cut(v1, v2);
        } else {
            b2Vec2 v1(drand48() * 40 - 20, 0);
            b2Vec2 v2(drand48() * 40 - 20, 40);
            Cut(v1, v2);
        }
    }
}
Пример #3
0
int main()
{
    int n, m, op;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", K + i);
    for (int i = 0; i < n; i++) Link(&T[i], &T[min(i + K[i], n)]);
    scanf("%d", &m);
    while (m--)
    {
        scanf("%d", &op);
        if (op == 1)
        {
            int x;
            scanf("%d", &x);
            makeRoot(&T[n]);
            access(&T[x]), splay(&T[x]);
            printf("%d\n", T[x].ch[0] ? T[x].ch[0]->sz : 0);
        }
        if (op == 2)
        {
            int x, y;
            scanf("%d%d", &x, &y);
            Cut(&T[x], &T[min(x + K[x], n)]);
            K[x] = y;
            Link(&T[x], &T[min(x + K[x], n)]);
        }
    }
    return 0;
}
Пример #4
0
void SkimFlatCat::Loop()
{

   if (fChain == 0) return;
   

   TFile *skimfile = new TFile("Skim.root","recreate"); 
   fChain->LoadTree(0); 
   
   TTree *newtree = fChain->CloneTree(0);
 
   
   Long64_t nentries = fChain->GetEntriesFast();
   Int_t nselected = 0;
   Long64_t nbytes = 0, nb = 0;
   for (Long64_t jentry=0; jentry<nentries;jentry++) {
     if(!(jentry%10000)) std::cout << jentry << " :  "<<  fChain->GetEntries() << std::endl; 
     Long64_t ientry = LoadTree(jentry);
   
     if (ientry < 0) break;
     nb = fChain->GetEntry(jentry);   nbytes += nb;
     
     if (Cut(ientry) < 0) continue;
     nselected++;
     
     newtree->Fill();
   }
   std::cout << "Selected " << nselected << " out of " << fChain->GetEntries() << std::endl; 
   newtree->Write();
   skimfile->Close();
}
Пример #5
0
vi_rc Yank( range *r )
{
    vi_rc       rc;

    if( r->line_based ) {
        rc = YankLineRange( r->start.line, r->end.line );
    } else if( r->start.line == r->end.line ) {
        assert( CurrentPos.line == r->start.line );
        AddLineToSavebuf( CurrentLine->data, r->start.column, r->end.column );
#ifdef __WIN__
        if( LastSavebuf == 0 ) {
            Message1( "%d characters copied into the clipboard",
                      r->end.column - r->start.column + 1 );
        } else {
#endif
            Message1( "%d %s yanked into buffer %c",
                      r->end.column - r->start.column + 1,
                      MSG_CHARACTERS, LastSavebuf );
#ifdef __WIN__
        }
#endif
        rc = DO_NOT_CLEAR_MESSAGE_WINDOW;
    } else {
        rc = Cut( r->start.line, r->start.column, r->end.line, r->end.column, false );
    }
    if( rc != ERR_NO_ERR ) {
        rc = DO_NOT_CLEAR_MESSAGE_WINDOW;
    }
    return( rc );

} /* Yank */
Пример #6
0
void wxTextCtrl::OnKeyDown(wxKeyEvent& event)
{
    if ( event.GetModifiers() == wxMOD_CONTROL )
    {
        switch( event.GetKeyCode() )
        {
            case 'A':
                SelectAll();
                return;
            case 'C':
                if ( CanCopy() )
                    Copy() ;
                return;
            case 'V':
                if ( CanPaste() )
                    Paste() ;
                return;
            case 'X':
                if ( CanCut() )
                    Cut() ;
                return;
            default:
                break;
        }
    }
    // no, we didn't process it
    event.Skip();
}
Пример #7
0
vi_rc Delete( range *r )
{
    vi_rc       rc;

    // need to perform the actual delete
    if( r->line_based ) {
        rc = DeleteLineRange( r->start.line, r->end.line, SAVEBUF_FLAG );
        DCDisplayAllLines();
        LineDeleteMessage( r->start.line, r->end.line );
    } else if( r->start.line != r->end.line ) {
        rc = Cut( r->start.line, r->start.column, r->end.line, r->end.column, true );
        DCDisplayAllLines();
    } else {
        GoToLineNoRelCurs( r->start.line );
        rc = DeleteRangeOnCurrentLine( r->start.column, r->end.column, true );
    }
    // move cursor to tl corner of region
    if( rc == ERR_NO_ERR ) {
        GoToLineNoRelCurs( r->start.line );
        r->start.column += 1;
        if( r->start.column > CurrentLine->len ) {
            if( EditFlags.Modeless ) {
                r->start.column = CurrentLine->len + 1;
            } else {
                r->start.column = CurrentLine->len;
            }
        }
        GoToColumnOnCurrentLine( r->start.column );
        EditFlags.Dotable = true;
    } else {
        rc = DO_NOT_CLEAR_MESSAGE_WINDOW;
    }
    return( rc );

} /* Delete */
void cut_input (char *DICT_PATH, char *HMM_PATH, char *USER_DICT) {
  char *s;

  Jieba handle = NewJieba (DICT_PATH, HMM_PATH, USER_DICT);
  setlocale (LC_ALL, "");
  printf ("Chinese word segmentation\n=========================\n\n");

  while (s = getstr ()) {
    if (strcmp (s, "EOF") == 0) {
      free (s);
      printf ("bye\n");
      break;
    } else {
      size_t len = strlen (s);
      CJiebaWord* words = Cut (handle, s, len);
      CJiebaWord* x;
      for (x = words; x && x->word; x++) {
        /* printf ("%*.*s/", x->len, x->len, x->word); */
        printf ("%d ", x->len / CJIEBA_WCHAR_SIZE);
      }
      printf ("\n");
      free (s);
      FreeWords (words);
    }
  }
  FreeJieba (handle);
}
Пример #9
0
 void Cut(const string& sentence,
       vector<string>& words,
       size_t max_word_len) const {
   vector<Word> tmp;
   Cut(sentence, tmp, max_word_len);
   GetStringsFromWords(tmp, words);
 }
Пример #10
0
void CColorEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	// TODO: Add your message handler code here and/or call default
	switch (nChar)
	{
	case 0x01:// Ctrl-A => handle SELECT_ALL
		SetSel(0, -1);
		return;
	case 0x03:// Ctrl-C => handle WM_COPY
		Copy();
		return;
	case 0x16:// Ctrl-V => handle WM_PASTE
		Paste();
		return;
	case 0x18:// Ctrl-X => handle WM_CUT
		Cut();
		return;
	case 0x1A:// Ctrl-Z => handle ID_EDIT_UNDO (EM_UNDO)
		if(CanUndo())
			Undo();
		return;
	}

	CEdit::OnChar(nChar, nRepCnt, nFlags);
}
Пример #11
0
bool Track::SyncLockAdjust(double oldT1, double newT1)
{
   if (newT1 > oldT1) {
      // Insert space within the track

      if (oldT1 > GetEndTime())
         return true;

      Track *tmp;
      bool ret;

      ret = Cut(oldT1, GetEndTime(), &tmp);
      if (!ret) return false;

      ret = Paste(newT1, tmp);
      wxASSERT(ret);

      delete tmp;
      return ret;
   }
   else if (newT1 < oldT1) {
      // Remove from the track
      return Clear(newT1, oldT1);
   }

   // fall-through: no change
   return true;
}
Пример #12
0
static void
dfs(Agraph_t * g, Agnode_t * u, bcstate * stp, Agnode_t * parent)
{
    Agnode_t *v;
    Agedge_t *e;
    Agedge_t *ep;
    Agraph_t *sg;

    stp->count++;
    Low(u) = N(u) = stp->count;
    for (e = agfstedge(g, u); e; e = agnxtedge(g, e, u)) {
	if ((v = aghead(e)) == u)
	    v = agtail(e);
	if (v == u)
	    continue;
	if (N(v) == 0) {
	    push(&stp->stk, e);
	    dfs(g, v, stp, u);
	    Low(u) = min(Low(u), Low(v));
	    if (Low(v) >= N(u)) {	/* u is an articulation point */
		Cut(u) = 1;
		sg = mkBlock(g, stp);
		do {
		    ep = pop(&stp->stk);
		    agsubnode(sg, aghead(ep), 1);
		    agsubnode(sg, agtail(ep), 1);
		} while (ep != e);
	    }
	} else if (parent != v) {
	    Low(u) = min(Low(u), N(v));
	    if (N(v) < N(u))
		push(&stp->stk, e);
	}
    }
}
Пример #13
0
STDMETHODIMP CECR::MoveCash(BSTR FirmID, LONG Money, LONG DirectionIn, LONG* ErrorCode)
{
    DWORD dwDocType;
    DirectionIn ? dwDocType = CashInDocument : dwDocType = CashOutDocument;

    // открыть документ
    OpenDocument(FirmID, DEP_NO, ErrorCode, dwDocType);
    if (*ErrorCode == E_SUCCESS)
    {
        PrintBuffer(FirmID, ErrorCode);
        if (*ErrorCode == E_SUCCESS)
        {
            InitCmd();
            // команда
            to_numeric(214, m_Cmd, 3, m_Len);   //SETTENDER
            // пароль
            to_char(OPERATOR_PASSWD, m_Cmd + m_Len, 4, m_Len);
            // тип оплаты
            to_numeric(0, m_Cmd + m_Len, 2, m_Len);   
            // сумма
            to_smoney(Money, m_Cmd + m_Len, 10, m_Len);   

            m_RspLen = 11;
            m_ECRList.PassCmd(FirmID, m_Cmd, m_Len, m_Rsp, m_RspLen, ErrorCode);

            if (*ErrorCode == E_SUCCESS)
                Cut(FirmID, 1, ErrorCode);
        }
    }
    return S_OK;
}
Пример #14
0
BOOL CMyComboBox::PreTranslateMessage(MSG* pMsg)
{
	bool	ctrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
	if ( pMsg->message == WM_KEYDOWN){
		switch( pMsg->wParam ){
		case 'C':
			if ( ctrl ){
				Copy();
				return TRUE;
			}
			break;
		case 'X':
			if ( ctrl ) {
				Cut();
				return TRUE;
			}
			break;
		case 'V':
			if ( ctrl ) {
				Paste();
				return TRUE;
			}
			break;
		case VK_DOWN:
			if ( GetDroppedState() == FALSE ){
				ShowDropDown( TRUE );
			}
			break;
		}
	}

	return CComboBox::PreTranslateMessage(pMsg);
}
void CPlainTextEditor::CutLine(CChars* pszDest)
{
	int		iCount;
	int		iStart;
	int		iEnd;

	if (!IsSelected())
	{
		iCount = GetCharCountAlongLine(miEditPos);
		iStart = FindStartOfLine(miEditPos);
		iEnd = FindEndOfLine(miEditPos);

		if (CanGoRight(iEnd))
		{
			iEnd++;
		}

		pszDest->AppendSubString(mszText, iStart, iEnd);
		mszText.Remove(iStart, iEnd);
		ResetUpDown();

		miEditPos = FindPositionAlongLine(iStart, iCount);
	}
	else
	{
		Cut(pszDest);
	}
}
Пример #16
0
void CSimpleReport::RowDownMulti()
{
	CXTPReportSelectedRows* pRows = GetSelectedRows();
	if (!pRows)
		return;

	int total = GetRows()->GetCount() - 1;
	int cnt = pRows->GetCount();

	CXTPReportRow* pRow = pRows->GetAt(cnt-1);	// 선택 영역의 마지막 row
	if (!pRow)
		return;
	int n = pRow->GetIndex();
	if (n >= total)					// 더이상 내려갈 수 없음
		return;

	// 마지막 row 뒤에 paste하기 위해 m_bAdd를 true로 만듬.
	// 그럼 cut후 add가 됨

	if (n+1 >= total)
		m_bAdd = true;

	// focus는 cut된 시점에서 첫번째로 잡음.
	pRow = pRows->GetAt(0);
	n = pRow->GetIndex();

	Cut();			// 컷하면 선택된 갯수는 제거되므로 total-cnt가 
	RowSetFocused(n+1);
	Paste();
	SetFocus();
}
Пример #17
0
void fbtTextFile::cutEvent(wxCommandEvent& evt)
{
	if (GetReadOnly()  || GetSelectionEnd() - GetSelectionStart() <= 0)
		return;
	Cut();

}
Пример #18
0
	void solve(void) {
		Input();
		Cut();
		Bfs(vs[1][0], vs[1][1]);
		Work(vs[0][0], vs[0][1]);
		int t1 = tim[vt[0]][vt[1]];
		puts(t1?"YES":"NO");
	}
Пример #19
0
void SFileWorker::MoveToTrash(const SFile *srcFolder, const SFileList *fileList)
{
	BEntry entry(TRASH_ENTRY);
	SFile trashFolder(&entry);

	ModifyRestoreAttribute(fileList,true);
	Cut(srcFolder, fileList);
	Paste(&trashFolder);
}
Пример #20
0
void
CSlmBuilder::Build()
{
    CountNr();
    AppendTails();
    Cut();
    Discount();
    CalcBOW();
}
Пример #21
0
void CuttingThread::run()
{
	Error e = Cut(_cuts, _mediawidth, _mediaheight, _media, _speed, _pressure, _trackenhancing,
	              _regmark, _regsearch, _regwidth, _reglength);
	if (e)
		emit success();
	else
		emit error(e.message().c_str());
	exec();
}
Пример #22
0
void Cut(int iBegin,int iTarget)
{
	char cPart[MAX];int i;
	for(i=iBegin+1;i<=iLen;i++)
	{
		memcpy(cPart,cNumber+iBegin,i-iBegin);cPart[i-iBegin]='\0';
		if(Try(i,iTarget-atoi(cPart))==TRUE)
			{cout<<" "<<cPart;Cut(i,iTarget-atoi(cPart));}
	}
}
Пример #23
0
FibonacciHeapNode<Key, Data> * FibonacciHeap<Key, Data>::Delete(FibonacciHeapNode<Key, Data> * node)
{
	FibonacciHeapNode<Key, Data> * parent = node->m_pParent;
	if (parent != NULL) {
		Cut(node, parent);
		CascadingCut(parent);
	}
	m_pMin = node;
	return ExtractMin();
}
Пример #24
0
 void Cut(const string& sentence, vector<string>& words, bool hmm = true) const {
   PreFilter pre_filter(symbols_, sentence);
   PreFilter::Range range;
   vector<Unicode> uwords;
   uwords.reserve(sentence.size());
   while (pre_filter.HasNext()) {
     range = pre_filter.Next();
     Cut(range.begin, range.end, uwords, hmm);
   }
   TransCode::Encode(uwords, words);
 }
Пример #25
0
 void fibonacci_heap::CascadingCut(Node* y) {
   Node* z = y->parent;
   if (z != nullptr) {
     if (y->marked == false) {
       y->marked = true;
     } else {
       Cut(y,z);
       CascadingCut(z);
     }
   }
 }
Пример #26
0
void Cascading_Cut (struct heap* H, struct node* y){
	struct node* z = y->p;
	if (z){
		if (y->mark == false){
			y->mark = true;
		} else {
			Cut (H, y, z);
			Cascading_Cut(H,z);
		}
	}
}
Пример #27
0
static int process(Agraph_t * g, int gcnt)
{
    Agnode_t *n;
    bcstate state;
    Agraph_t *blk;
    Agraph_t *tree;
    int bcnt;

    aginit(g, AGNODE, "info", sizeof(Agnodeinfo_t), TRUE);
    aginit(g, AGEDGE, "info", sizeof(Agedgeinfo_t), TRUE);
    aginit(g, AGRAPH, "info", sizeof(Agraphinfo_t), TRUE);

    state.count = 0;
    state.nComp = 0;
    state.stk = 0;
    state.blks = 0;

    for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
	if (N(n) == 0)
	    dfs(g, n, &state, 0);
    }
    for (blk = state.blks; blk; blk = NEXTBLK(blk)) {
	nodeInduce(blk, g);
    }
    if (external) {
	bcnt = 0;
	for (blk = state.blks; blk; blk = NEXTBLK(blk)) {
	    gwrite(blk, gcnt, bcnt++);
	}
    } else
	gwrite(g, gcnt, 0);
    if (doTree) {
	tree = agopen("blkcut_tree", Agstrictundirected, 0);
	for (blk = state.blks; blk; blk = NEXTBLK(blk))
	    addCutPts(tree, blk);
	gwrite(tree, gcnt, -1);
	agclose(tree);
    }
    if (verbose) {
	int cuts = 0;
	bcnt = 0;
	for (blk = state.blks; blk; blk = NEXTBLK(blk))
	    bcnt++;
	for (n = agfstnode(g); n; n = agnxtnode(g, n))
	    if (Cut(n))
		cuts++;
	fprintf(stderr, "%s: %d blocks %d cutpoints\n", agnameof(g), bcnt,
		cuts);
    }
    if (state.blks && NEXTBLK(state.blks))
	return 1;		/* >= 2 blocks */
    else
	return 0;
}
Пример #28
0
static void * ReplaceKeyData(PQueue *h, PQueueElement *x, intptr_t key, void *data)
{
    void *odata;
    int okey;
    PQueueElement *y;
    int r;

    odata = x->Data;
    okey = x->Key;

    /*
     * we can increase a key by deleting and reinserting, that
     * requires O(lgn) time.
     */
    if ((r = comparedata(h, key, data, x)) > 0) {

        /* XXX - bad code! */
        abort();
        DeleteElement(h, x);

        if (data) memcpy(x->Data , data,h->ElementSize);
        x->Key = key;

        insertel(h, x);

        return odata;
    }

    if (data) memcpy(x->Data , data, h->ElementSize);
    x->Key = key;

    /* because they are equal, we don't have to do anything */
    if (r == 0)
        return odata;

    y = x->Parent;

    if (okey == key)
        return odata;

    if (y != NULL && compare(h, x, y) <= 0) {
        Cut(h, x, y);
        CascadingCut(h, y);
    }

    /*
     * the = is so that the call from delete will delete the proper
     * element.
     */
    if (compare(h, x, h->Minimum) <= 0)
        h->Minimum = x;

    return odata;
}
Пример #29
0
void FibonacciHeap<Key, Data>::CascadingCut(FibonacciHeapNode<Key, Data> * node)
{
	FibonacciHeapNode<Key, Data> * parent = node->m_pParent;
	if (parent != NULL) {
		if (!node->m_bMarked)
			node->m_bMarked = true;
		else {
			Cut(node, parent);
			CascadingCut(parent);
		}
	}
}
Пример #30
0
void Snake::CheckCollision() {
	if (_body.size() < 5) { return; }
	auto head = _body.front();
	for (auto itr = _body.begin() + 1; itr != _body.end(); ++itr) {
		if (itr->position == head.position) {
			// current position intersected with head
			int segments = _body.end() - itr;
			Cut(segments);
			break;
		}
	}
}