Ejemplo n.º 1
0
int CLogGraph::getWndQueLastPos()
{
	int en = m_nCurrentPos + getWndQueLength();
//	if (en > lib->mque_reclast(m_hQue))
//		en = lib->mque_reclast(m_hQue);
	if (en > getLast())
		en = getLast();
	return en;
}
Ejemplo n.º 2
0
DataSet::DataSet(bool classAtStart, string file, double ratio)
{
  name = file;
  uniqueClasses=0;
  //int classC=0;
  classes = new vector<string>;
  data = new vector< vector<double>* >;
  ifstream ifs(file.c_str());
  if(!ifs.good())
    return;
  char buf[4096];
  string strBuf;
  string * tmpStr;
  while(!ifs.eof()){
    ifs.getline(buf,sizeof buf);
    strBuf = buf;
    if(strBuf.length()==0)
      break;
    if(classAtStart){
      if(!isIn(classes,*getNext(strBuf)))
	uniqueClasses++;
      classes->push_back(*getNext(strBuf));
      strBuf = getRest(strBuf);
    }else{
      if(!isIn(classes,*getLast(strBuf)))
	uniqueClasses++;
      classes->push_back(*getLast(strBuf));
      strBuf = getRestEnd(strBuf);
    }
    vector<double> * intvector = new vector<double>;
    while((tmpStr = getNext(strBuf)) != 0){
      intvector->push_back(atof(tmpStr->c_str()));
      strBuf = getRest(strBuf);
    }
    data->push_back(intvector);
  }
  ifs.close();
  cerr << "read "<<data->size()<<" datapoints, with "<<data->at(0)->size()<<" paramaters  classes: "<<classes->size()<<" unique:"<<uniqueClasses<<"\n";
  tests = (int)(data->size()*ratio);
  trainings = data->size()-tests;
  Dummy myDummy;
  int ** tmpCoord = myDummy.randomCoords(data->size(),0);
  trainCoords = new int [trainings];
  testCoords = new int [tests];
  int c = 0;
  for(;c<tests;c++)
    testCoords[c] = tmpCoord[c][0];
	
  for(;c<(tests+trainings);c++)
    trainCoords[(c-tests)] = tmpCoord[c][0];

  cerr << "tests: "<<tests<<" trainings: "<<trainings<<endl;
}
Ejemplo n.º 3
0
void CLogGraph::goLast()
{
	int en = getWndQueLastPos();
// 	if (lib->mque_reclast(m_hQue) > en)
// 		en = lib->mque_reclast(m_hQue);
	if (getLast() > en)
		en = getLast();
	m_nCurrentPos = en - getWndQueLength();
	
 	if (m_nCurrentPos < getLast())
 		m_nCurrentPos = getLast();

	TRACE("goLast: current=%d, last=%d\n", m_nCurrentPos, en);
	setScrollBar();
}
Ejemplo n.º 4
0
static void solveMaze(void)
{
    int x, y, offset;


    for (y = 0; y < height; y ++)
	for (x = 0; x < width; x ++)
	    maze[y][x].visited = false;

    y = 0;
    x = 0;

    while (y != height - 1 || x != width - 1) {
	draw(x, y, true);
	maze[y][x].visited = true;

	if (!maze[y][x].right && !maze[y][x + 1].visited) {
	    addLast(dp, offset(x + 1, y));
	    maze[y][x + 1].from = 1;
	}

	if (!maze[y][x].bottom && !maze[y + 1][x].visited) {
	    addLast(dp, offset(x, y + 1));
	    maze[y + 1][x].from = width;
	}

	if (x > 0 && !maze[y][x - 1].right && !maze[y][x - 1].visited) {
	    addLast(dp, offset(x - 1, y));
	    maze[y][x - 1].from = -1;
	}

	if (y > 0 && !maze[y - 1][x].bottom && !maze[y - 1][x].visited) {
	    addLast(dp, offset(x, y - 1));
	    maze[y - 1][x].from = -width;
	}

	if (getLast(dp) == offset(x, y)) {
	    draw(x, y, false);
	    removeLast(dp);
	}

	offset = getLast(dp);
	x = xcoord(offset);
	y = ycoord(offset);
    }

    draw(width - 1, height - 1, true);
}
Ejemplo n.º 5
0
int main(){
	/*make list and output file*/
    ListHndl TheList = newList();
    FILE *out = fopen("out.out", "w");
    
    /*test empty in empty case*/
    if(isEmpty(TheList)) printf("Empty\n");
    else printf("not Empty\n");
    printf("testing insert one number\n");
    insertAtFront(TheList,(unsigned long*)25728);
    printf("%lu\n",(unsigned long)getFirst(TheList));
    printf("%lu\n",(unsigned long)getLast(TheList));
    /*should have same value*/
    
    printf("testing list with three numbers\n");
    insertAtFront(TheList,(unsigned long*)1589458);
    insertAtBack(TheList,(unsigned long*)35762111234);
    printf("%lu\n",(unsigned long)getFirst(TheList));
    
    /*test empty in full case*/
    if(isEmpty(TheList)) printf("Empty\n");
    else printf("not Empty\n");
    
	/*test moving the current pointer around*/
    moveFirst(TheList);
    moveNext(TheList);
    printf("%lu\n",(unsigned long)getCurrent(TheList));
    moveLast(TheList);
    movePrev(TheList);
    printf("%lu\n",(unsigned long)getCurrent(TheList));
    
	/*test printList*/
    printList(out, TheList);
    
	/*test makeEmpty*/
    makeEmpty(TheList);
    if(isEmpty(TheList)) printf("Empty\n");
    else printf("not Empty\n");
    
	/*test inserting functions*/
    insertAtFront(TheList,(unsigned long*)2);
    insertAtFront(TheList,(unsigned long*)1);
    insertAtFront(TheList,(unsigned long*)4);
    insertAtBack(TheList,(unsigned long*)4);
    moveLast(TheList);
    insertBeforeCurrent(TheList,(unsigned long*)3);
    printList(out,TheList);
    deleteFirst(TheList);
    deleteCurrent(TheList);
    deleteLast(TheList);
    printList(out,TheList);
    
    makeEmpty(TheList);
    printList(out,TheList);
    
	/*free list and close output file*/
    freeList(&TheList);
    fclose(out);
    return 0;
}
Ejemplo n.º 6
0
KeyPageAddr KeyFile::fetchNewPage(bool leafPage) {
  KeyPageAddr addr;

  KeyPage page(m_pageInfo);
  KeyPageAddr freeList = getFreeList();
  if(freeList == DB_NULLADDR) {
    try {
      addr = getLast() + 1;
      page.init(leafPage);
      writePage(addr, page);
      setLast(addr);
    } catch(sqlca) {
      return DB_NULLADDR;
    }
  } else {
    try {
      addr = freeList;
      readPage(freeList, page);
      logPage( freeList, page);
      freeList = page.getNextFree();
      setFreeList(freeList,-1);
      page.init(leafPage);
      writePage(addr, page);
    } catch(sqlca) {
      return DB_NULLADDR;
    }
  }
  return addr;
}
/**
 * Function name    StringPosRange::getLength
 * Description      returns the length of the object
 * @return          StringPos
 * @exception       -
 * @see             -
*/
StringPos StringPosRange::getLength() 
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState( ));

    return ( isValid() ? getLast() - getFirst() + 1
                       : string::npos ); 
}
Ejemplo n.º 8
0
void QFFrameRangeEdit::spinValueChanged()
{
    int nv=qMax(spinFirst->value(), spinLast->value());
    if (spinLast->value()!=nv) spinLast->setValue(nv);
    emit valueChanged(getFirst(), getLast());

}
Ejemplo n.º 9
0
RotoRegion::RotoRegion(const PathV& v)
{
    for (PathV::const_iterator c = v.begin(); c != v.end(); ++c)
        _rotoPaths.push_back(*c);
    assert(_rotoPaths.size() > 1);

    _sides.push_back(RR_RIGHT); // we start first curve 0->1
    const RotoPath* last = _rotoPaths.front();
    _rotoPaths.front()->setRegion(this, RR_RIGHT);

    int i = 1;
    PathV::const_iterator c = _rotoPaths.begin();
    ++c; // move one up
    float d0, d1;
    for (; c != _rotoPaths.end(); ++c, ++i)
    {
        const Vec2f endPt = (*c)->getEnd(getLast(i - 1));
        d0 = (*c)->_bez->distanceToEnd2(endPt, 0);
        d1 = (*c)->_bez->distanceToEnd2(endPt, 1);
        if (d0 < d1)
            _sides.push_back(RR_RIGHT);
        else
            _sides.push_back(RR_LEFT);
        (*c)->setRegion(this, _sides[i]);

        last = *c;
    }
    assert(_sides.size() == _rotoPaths.size());

    createMask();
}
Ejemplo n.º 10
0
void showCalendar(int year,int month)
{
	printf("    %d / %d\n",year,month);
	printf("==============================\n");
	printf(" Sun Mon Tue Wed Thu Fri Sat\n");
	printf("==============================\n");
	int dayNum=1,firstWeek,lastDay;
	
	firstWeek=getFirst(year,month);
	lastDay=getLast(year,month);
	for(int i=0;i<6;i++)
	{
		for(int j=0;j<7;j++)
		{
			if(i==0&&j<firstWeek)
				printf("    ");
			else
			{
				printf("%4d",dayNum);
				dayNum++;
			}
			if(dayNum>lastDay)
				break;
		
		}
		printf("\n");
		if(dayNum>lastDay)
			break;	
	
	}
}
Ejemplo n.º 11
0
void moveOnes(listad *q){

    listad *tmpNodeNext, * LastPtr, * cursor;

    LastPtr = getLast(q);
    cursor = q;
    int act = 0, tot = getSize(q);

    while(cursor->next != NULL)
    {

	tmpNodeNext = cursor->next;

	if(cursor->inf == 1)
	{
	  if(cursor->prev != NULL)
	    cursor->prev->next = cursor->next;

	  cursor->next->prev = cursor->prev;

	  LastPtr->next = cursor;
	  cursor->next = NULL;
	  cursor->prev = LastPtr;
	  LastPtr = cursor;
	}

	if( ++act >= tot)
	  break;

	cursor = tmpNodeNext;
    }

    return;
}
Ejemplo n.º 12
0
int meshOperation::getPrevious_bc( int center_index, int v, mesh& m )
{
	int prev = getPrevious(center_index,v,m);
	if(prev < 0){
		return getLast(center_index,v,m);
	}
	return prev;
}
Ejemplo n.º 13
0
FileInfo &Files::getLastByExtension(const std::string &t_ext) 
{
  try {
    return getLast(boost::bind(&Files::extensionCompare, t_ext, _1));
  } catch (const std::runtime_error &e) {
    throw std::runtime_error("getLastByExtension: " + std::string(e.what()) + ": " + t_ext);
  }
}
Ejemplo n.º 14
0
FileInfo &Files::getLastByRegex(const std::string &t_regex)
{
  try {
    return getLast(boost::bind(&Files::regexCompare, QRegExp(toQString(t_regex), Qt::CaseInsensitive), _1));
  } catch (const std::runtime_error &e) {
    throw std::runtime_error("getLastByRegex: " + std::string(e.what()) + ": " + t_regex);
  }
}
Ejemplo n.º 15
0
FileInfo &Files::getLastByFilename(const std::string &t_filename)
{
  try {
    return getLast(boost::bind(&Files::filenameCompare, t_filename, _1));
  } catch (const std::runtime_error &e) {
    throw std::runtime_error("getLastByFilename: " + std::string(e.what()) + ": " + t_filename);
  }
}
Ejemplo n.º 16
0
FileInfo &Files::getLastByKey(const std::string &t_key) 
{
  try {
    return getLast(boost::bind(&Files::keyCompare, t_key, _1));
  } catch (const std::runtime_error &e) {
    throw std::runtime_error("getLastByKey: " + std::string(e.what()) + ": " + t_key);
  }
}
Ejemplo n.º 17
0
void CLogGraph::setZoomFit()
{
	double l = getLast();//lib->mque_reclast(m_hQue);
	double fz = l / m_rectGraph.Width();
	m_nCurrentPos = 0;

//	TRACE("%s : cpos %d\n", __FUNCTION__, m_nCurrentPos);
	if (fz < 1.0) fz = 1.0;
	setZoom(fz); 
}
Ejemplo n.º 18
0
const FileInfo &Files::getLastByKey(const std::string &t_key) const
{
  // we're going to try and work around what seems to be a bug in the stdlib used
  // by apple. We're going to save the error, then
  try {
    return getLast(boost::bind(&Files::keyCompare, t_key, _1));
  } catch (const std::runtime_error &e) {
    throw std::runtime_error("getLastByKey: " + std::string(e.what()) + ": " + t_key);
  }
}
Ejemplo n.º 19
0
void
nsFrameIterator::Next()
{
  // recursive-oid method to get next frame
  nsIFrame *result = nsnull;
  nsIFrame *parent = getCurrent();
  if (!parent)
    parent = getLast();

  if (mType == eLeaf) {
    // Drill down to first leaf
    while ((result = GetFirstChild(parent))) {
      parent = result;
    }
  } else if (mType == ePreOrder) {
    result = GetFirstChild(parent);
    if (result)
      parent = result;
  }

  if (parent != getCurrent()) {
    result = parent;
  } else {
    while (parent) {
      result = GetNextSibling(parent);
      if (result) {
        if (mType != ePreOrder) {
          parent = result;
          while ((result = GetFirstChild(parent))) {
            parent = result;
          }
          result = parent;
        }
        break;
      }
      else {
        result = GetParentFrameNotPopup(parent);
        if (!result || IsRootFrame(result) ||
            (mLockScroll && result->GetType() == nsGkAtoms::scrollFrame)) {
          result = nsnull;
          break;
        }
        if (mType == ePostOrder)
          break;
        parent = result;
      }
    }
  }

  setCurrent(result);
  if (!result) {
    setOffEdge(1);
    setLast(parent);
  }
}
Ejemplo n.º 20
0
int meshOperation::getPrevious_bc( int center_index, int v, mesh& m , bool * trueNeighbor)
{
	int prev = getPrevious(center_index,v,m);
	if(trueNeighbor != NULL){
		*trueNeighbor = prev >= 0;
	}
	if(prev < 0){
		return getLast(center_index,v,m);
	}
	return prev;
}
Ejemplo n.º 21
0
EditOperList* EditOperList::addOper(HE_OPER* op) {
	EditOperList *last;
	EditOperList *newop;

	newop = new EditOperList();
	newop->oper = op;

	last = getLast();
	last->next = newop;
	newop->prev = last;
	return newop;
}
Ejemplo n.º 22
0
void
FileSource::getConfig()
{
    std::vector<vespalib::string> lines(readConfigFile(_fileName));
    int64_t last = getLast(_fileName);

    if (last > _lastLoaded) {
        _holder->handle(ConfigUpdate::UP(new ConfigUpdate(ConfigValue(lines, calculateContentMd5(lines)), true, _generation)));
        _lastLoaded = last;
    } else {
        _holder->handle(ConfigUpdate::UP(new ConfigUpdate(ConfigValue(lines, calculateContentMd5(lines)), false, _generation)));
    }
}
Ejemplo n.º 23
0
void List<T>::pushLast(const T& data) {
  Node<T>* newLast = new Node<T>(data);

  if (debug) {
    std::cout << "DEBUG: "
      << "Pushing "
      << newLast
      << " to last"
      << std::endl;
  }

  if (hasLast()) {
    getLast()->setNext(newLast);
    newLast->setPrev(getLast());
  }

  if (!hasFirst()) {
    setFirst(newLast);
  }

  setLast(newLast);
}
Ejemplo n.º 24
0
void pushBack(songs song)
{
	Node *last = getLast(addHead);
	Node *tmp = (Node*)malloc(sizeof(Node));

	tmp->song = song;
	tmp->next = NULL;
	if (last == NULL)
		addHead = tmp;
	else
		last->next = tmp;
	state.addN++;
}
Ejemplo n.º 25
0
/* no set proc fbc_id */
void eFBCTunerManager::connectLinkNoSimulate(eDVBRegisteredFrontend *link_fe, eDVBRegisteredFrontend *top_fe)
{
	eDVBRegisteredFrontend *last_fe = getLast(top_fe);

	last_fe->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, (long)link_fe);
	link_fe->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, (long)last_fe);

	/* enable linked fe */
	link_fe->m_frontend->setEnabled(true);

	/* add slot mask*/
	updateLNBSlotMask(FE_SLOT_ID(link_fe), FE_SLOT_ID(top_fe), false);
}
Ejemplo n.º 26
0
Node<T> List<T>::popLast() {
  if (hasLast()) {
    Node<T> oldLast = *getLast();

    if (getFirst() == getLast()) {
      setFirst(NULL);
    }

    delete getLast();

    if (oldLast.hasPrev()) {
      oldLast.getPrev()->setNext(NULL);
      setLast(oldLast.getPrev());
    } else {
      setLast(NULL);
    }

    return oldLast;
  }

  return NULL;
}
Ejemplo n.º 27
0
void CLogGraph::setZoom(double zf)
{
	m_fZoomFactor = zf;

	// zoom factor가 바뀌면 m_nCurrentPos 다시 계산
	
	int mqlast = getLast();
	if (mqlast < getWndQueLastPos()) 
		m_nCurrentPos = mqlast - getWndQueLength();
	if (m_nCurrentPos < 0)
		m_nCurrentPos = 0;
//	TRACE("%s : cpos %d\n", __FUNCTION__, m_nCurrentPos);
	m_bDragSel = false;
	setScrollBar();
}
Ejemplo n.º 28
0
	void TraceSchedule::trace( const Tree::StmList* l )
	{
		for( ;; ) {
			const Tree::LABEL* lab = dynamic_cast<const Tree::LABEL*>(l->getTop());
			table[lab->getLabel()] = 0;
			const Tree::StmList* last = getLast( l );
			const Tree::IStm* s = last->getTail()->getTop();
			if( dynamic_cast<const Tree::JUMP*>(s) != 0 ) {
				const Tree::JUMP* j = dynamic_cast<const Tree::JUMP*>(s);
				const Tree::StmList* target = dynamic_cast<const Tree::StmList*>(table[j->getTgList()->getTop()]);
				if( j->getTgList()->getTail() == 0 && target != 0 ) {
					// cнимем константность
					const_cast<Tree::StmList*>(last->getTail())->setTail( const_cast<Tree::StmList*>(target) );
					l = target;
				} else {
					const_cast<Tree::StmList*>(last->getTail())->setTail( const_cast<Tree::StmList*>(getNext()) );
					return;
				}
			} else if( dynamic_cast<const Tree::CJUMP*>(s) != 0 ) {
				const Tree::CJUMP* j = dynamic_cast<const Tree::CJUMP*>(s);
				const Tree::StmList* t = dynamic_cast<const Tree::StmList*>(table[j->getTrueLabel()]);
				const Tree::StmList* f = dynamic_cast<const Tree::StmList*>(table[j->getFalseLabel()]);
				if( f != 0 ) {
					// cнимем константность
					const_cast<Tree::StmList*>(last->getTail())->setTail( const_cast<Tree::StmList*>(f) );
					l = f;
				} else if( t != 0 ) {
					// cнимем константность
					const_cast<Tree::StmList*>(last->getTail())->setTop( new Tree::CJUMP( Tree::CJUMP::reverseRelOp( j->getRelOp() ),
						j->getLeftExp(), j->getRightExp(),
						j->getFalseLabel(), j->getTrueLabel() ) );
					const_cast<Tree::StmList*>(last->getTail())->setTail( const_cast<Tree::StmList*>(t) );
					l = t;
				} else {
					Temp::CLabel* ff = new Temp::CLabel();
					const_cast<Tree::StmList*>(last->getTail())->setTop( new Tree::CJUMP( j->getRelOp(), j->getLeftExp(), j->getRightExp(),
						j->getTrueLabel(), ff ) );
					const_cast<Tree::StmList*>(last->getTail())->setTail( new Tree::StmList( new Tree::LABEL( ff ),
						new Tree::StmList( new Tree::JUMP( j->getFalseLabel() ),
						getNext() ) ) );
					return;
				}
			} else {
				assert( false );
			}
		}
	}
Ejemplo n.º 29
0
void ErrorController::newWarning(ErrorData & newWarn)
{
    // se repetiu o mesmo erro em um intervalo muito pequeno, ignora-o
    ErrorData &last = getLast();
    if (last.getType() == newWarn.getType() &&
        last.getCode() == newWarn.getCode() &&
        last.getLocation() == newWarn.getLocation() &&
        newWarn.getTimestamp() <= last.getTimestamp() + Seconds(ERROR_SUPRESS_SECS)
        ) {
        push(last);
    } else {
        push(newWarn);
        LogData log;
        log << newWarn << endl;
        log.push();
    }
}
Ejemplo n.º 30
0
void* LinkedList::removeLast()
{
  void** new_ptr = static_cast<void**>(calloc(reserve_size - 1, PTR_SIZE));

  void* ret_val = getLast();

  for ( int i = 0; i < reserve_size - 1; ++i )
    {
      new_ptr[i] = ptr[i];
    }

  free(ptr);

  ptr = new_ptr;

  --reserve_size;

  return ret_val;
}