Ejemplo n.º 1
0
struct RandomListNode *copyRandomList(struct RandomListNode *head) {
    if(!head){
        return head;
    }
    appendNew(head);
    setRandom(head);
    struct RandomListNode* ans = head->next;
    restore(head);
    return ans;
}
Ejemplo n.º 2
0
void QFSPenMatch::addStroke( QIMPenStroke *st )
{
    qLog(Input) << "QFSPenMatch:: addStroke";
    if(!mCharSet){
        qWarning("CharSet not set in QFSPenMatch::addStroke( QIMPenStroke *st )");
        qWarning("QFSPenMatch::setCharSet() must be called before addStroke()");
        return;
    }


    mCanvasHeight = 0; // reset
    mMatchList.clear();
    mMatchCount = 0;

    /* want to test for current longest multi stroke
       and for each shorter..  then for low 
       thresholds, drop them from the list of max lenght
       matches.
       */

    // add 1 stroke test char to test chars that matched last time.
    QIMPenChar c;
    mTestChars.append(c);
    // and test current test chars for matches.
    uint minerror = UINT_MAX;
    int matched_height = 0;
    int input_height = 0;
    QMutableListIterator<QIMPenChar> it(mTestChars);
    while (it.hasNext()) {
	QIMPenChar c = it.next();
	c.addStroke(st);
	it.setValue(c);
	QIMPenCharMatchList ml = mCharSet->match( &c );
	// if ml is 0, drop this char...
	if (ml.count() > 0) {
	    // later just append, for now, bias towards more stroke and
	    // compare errors.
	    appendNew(mMatchList, ml, c.strokeCount());

	    // if lowest error, up date height of matched char and height
	    // of test char.
	    QIMPenChar *ch = ml.first().penChar;
	    if (ch && (uint)ml.first().error < minerror) {
		matched_height = ch->boundingRect().height();
		input_height = c.boundingRect().height();
	    }
	} else {
	    it.remove();
	}
    }

    if (input_height && matched_height)
	mCanvasHeight = int(float(input_height * 75) / float(matched_height));
}
Ejemplo n.º 3
0
void appendNew(struct RandomListNode* head){
    if(!head){
        return;
    }
    struct RandomListNode* current = (struct RandomListNode*)malloc(sizeof(struct RandomListNode));
    struct RandomListNode* head_nxt = head->next;
    current->label = head->label;
    current->next = head_nxt;
    current->random = NULL;
    head->next = current;
    appendNew(head_nxt);
}
 void append(const KoColor& data) {
     int pos = findPos(data);
     if (pos > -1) updateKey(pos);
     else appendNew(data);
 }