示例#1
0
// The function [[emptyAllPertinentNodes]] has to be called after a reduction
// has been processed. This overloaded function first destroys all full nodes
// by marking them as TO_BE_DELETED and then calling the base class function
// [[emptyAllPertinentNodes]].
void EmbedPQTree::emptyAllPertinentNodes()
{
	ListIterator<PQNode<edge,indInfo*,bool>*> it;

	for (it = m_pertinentNodes->begin(); it.valid(); it++)
	{
		PQNode<edge,indInfo*,bool>* nodePtr = (*it);
		if (nodePtr->status() == FULL)
			destroyNode(nodePtr);
	}
	if (m_pertinentRoot) // Node was kept in the tree. Do not free it.
		m_pertinentRoot->status(FULL);

	PQTree<edge,indInfo*,bool>::emptyAllPertinentNodes();
}
示例#2
0
void TransformNode::render(Pixel* px, Matrix* later, Matrix* zbuffer, Color *ambient, Light *pointLight, Vertex *eye, double attenuation)
{
   //transform passed in from higher in the scene graph
   Matrix* updated = later->multiply(transform);

   ListIterator<Node>* iter = children->iterator();
   while (iter->hasNext())
   {
      Node* node = iter->next();
      node->render(px, updated, zbuffer, ambient, pointLight, eye, attenuation);
   }

   delete iter;
   delete updated;
}
示例#3
0
TransformNode::~TransformNode()
{
	ListIterator<Node>* iter = nodes->iterator();
	printf("\nDeleting transform node - start");
	while(iter->hasNext())
	{		
		printf("\nin loop temp");
		iter->next()->removeRef();
	}

	delete iter;
	delete nodes;

	printf("\nDeleting transform node - end");
}
示例#4
0
PageSelector::~PageSelector()
{
    if (this->page_buttons) {
	// The superclass destructor calls clear() but I'm confused
	// about what the virtual call from the destructor is going
	// to do.  So I'll add the needed statements.
	ListIterator it (*this->page_buttons);
	PageTab* page_button;
	while ( (page_button = (PageTab*)it.getNext()) ) {
	    page_button->unmanage();
	    delete page_button;
	}
	delete this->page_buttons;
	this->page_buttons = NUL(List*);
    }
示例#5
0
/**
*   ~BasicObject
*   Deconstuctor.
*   Preconditions:
*       None.
*   Postconditions:
*       BasicObject object is destroyed.
*/
BasicObject::~BasicObject()
{


    ListIterator<Face>* iter = faces->iterator();
    while ( iter->hasNext() ) {
            delete iter->next();
    }
    delete iter;
    delete faces;
    
    vertices->removeAll();
    delete vertices;

}
示例#6
0
void Hash::reHashRecords(Bucket* bucket, int bucketNumber, Bucket* newBucket)
{
	List<Record*>* recordList = bucket->getRecordList();
	ListIterator<Record*> it = recordList->getIterator();
	Record* auxRecord = NULL;
	int bucketDestinationNumber = 0;
	while(it.hasNext()){
		auxRecord = it.next();
		bucketDestinationNumber = this->hashTable->getBlock(this->hashKey(auxRecord->getKey()));
		if(bucketDestinationNumber != bucketNumber){
			newBucket->insertRecord(auxRecord->clone());
			bucket->deleteRecord(auxRecord->getKey());
		}
	}
}
示例#7
0
//The function takes in an iterator and TokenList and will rewrite numbers at the iterator's
//Pre- The position is located at a number or a parethesis
//Post- It will write to the postFix TokenList and update the iterator
void getValue(ListIterator &iter, TokenList &postFix)
{
	//If parethesis are found this else if will rewrite the parenthesis in postFix
	if (iter.tokenChar() == '(')
	{
		iter.advance();
		getValue(iter, postFix);
		iter.advance();
		assignOp(iter, postFix);
	}
	//If the current position is an integer
	else
	{
		postFix.push_back(iter.token());
	}
}
示例#8
0
string tokenText(ListIterator& infix, TokenList& list)
{
    if (infix != list.end())
        return infix.token().tokenText();
    else
        return "";
}
示例#9
0
UString Debugger::varInfo(const UString &ident)
{
  if (!eng)
    return UString();
  const List *chain = Context::current()->pScopeChain();
  ListIterator scope = chain->begin();
  while (scope != chain->end()) {
    if (scope->hasProperty(ident)) {
      KJSO val = scope->get(ident);
      return UString(val.imp()->typeInfo()->name) + ":" +
	val.toString().value();
    }
    scope++;
  }
  return UString();
}
boolean
MacroParameterNode::canCoerceValue (const char* option, List* types)
{
	ListIterator iter;
	boolean coerced = FALSE;
	DXType* dxtype;
	for (iter.setList(*types) ; (dxtype = (DXType*)iter.getNext()) ; ) {
		char* s = DXValue::CoerceValue (option, dxtype->getType());
		if (s) {
			coerced = TRUE;
			delete s;
			break;
		}
	}
	return coerced;
}
示例#11
0
// evalStep
// Evaluates the current operator
// Parameters:
//     iter  - the iterator for the list of tokens
//     postExpr - the postfix expression we are converting to
// Pre-condition: Next token is an operator (although, it will just advance if it isn't)
// Post-condition: All values related to this operation pushed to postExpr in the order dictated by postfix
//                 Iter is on the last token evaluated in this step (so iter.advance() next time will
//                     bring it to the next thing to be evaluated)
void evalStep(ListIterator& iter, TokenList& postExpr)
{
    iter.advance();
    switch (iter.tokenChar())
    {
    case '*':
    case '/':
    case '%':
        handleMultiplyLevelOperation(iter, postExpr);
        break;
    case '+':
    case '-':
        handleAdditionLevelOperation(iter, postExpr);
        break;
    }
}
示例#12
0
/**
*    render
*    Renders the scene.
*    Preconditions:
*        The pixel object.
*    Postconditions:
*        The scene is rendered when the final render method is reached.
*/
void Scene::render( Pixel* pix )
{
    Matrix* zbuffer = new Matrix( pix->getHeight(), pix->getWidth() );
    for ( int i = 0; i < pix->getHeight(); i++ ) {
         for ( int j = 0; j < pix->getWidth(); j++ ) {
             zbuffer->setElement( i, j, -1 );
         }
    }
    
    ListIterator<Node>* iter = scene->iterator();
    while( iter->hasNext() ) {
        iter->next()->render( pix, wnd, zbuffer );
    }
    delete iter;
    delete zbuffer;
}
示例#13
0
void List<Object>::insert( const Object& data,
 						   const ListIterator<Object> &iter ) {
	if (iter.isValid()) {
		ListNode<Object>* newnode = new ListNode<Object>( data, iter.current->getNext() );
		iter.current->setNext( newnode );
	}
}
示例#14
0
void makeFunction(ListIterator& infix, TokenList& list, FunctionDef& funs)
{
    infix.advance(); //advance past deffn

    string name = tokenText(infix, list);
    funs[name] = FunDef();

    FunDef* function = &funs[name]; //to avoid multiple lookups in this function body

    function->name = name;
    infix.advance(); //advance past function name
    infix.advance(); //advance past '('

    function->locals = new VarTree();

    int paramcount = 0;
    while (tokenText(infix, list) != ")")
    {
        string paramname = tokenText(infix, list);
        function->parameter[paramcount] = paramname;
        function->locals->assign(paramname, 0);
        ++paramcount;
        infix.advance();

        if (tokenText(infix, list) == ",")
            infix.advance();

    } //we are now on a ")"
    infix.advance(); //so advance past ")"

    for (int i = paramcount; i < 10; ++i)
        function->parameter[i] = "";

    function->functionBody = assignmentToTree(infix,list,funs);

#ifdef DEBUG
    cout << "Function:" << endl;
    cout << "    Name: " << function->name << endl;
    for (int i = 0; i < 10 && function->parameter[i] != ""; ++i)
        cout << "    Parameter " << i << ": " << function->parameter[i] << endl;
    cout << "    VarTree: " << function->locals << endl;
    cout << "    VarTree: " << *function->locals << endl;
    cout << "    ExprNode: " << function->functionBody << endl;
    cout << "    ExprNode: " << *function->functionBody << endl;
#endif
}
示例#15
0
文件: t_list.cpp 项目: huokedu/ardb
 int Ardb::RenameList(Context& ctx, DBID srcdb, const std::string& srckey, DBID dstdb, const std::string& dstkey)
 {
     Context tmpctx;
     tmpctx.currentDB = srcdb;
     ValueObject v;
     int err = GetMetaValue(tmpctx, srckey, LIST_META, v);
     CHECK_ARDB_RETURN_VALUE(ctx.reply, err);
     if (0 != err)
     {
         fill_error_reply(ctx.reply, "no such key or some error");
         return 0;
     }
     if (v.meta.Encoding() == COLLECTION_ENCODING_ZIPLIST)
     {
         DelKeyValue(tmpctx, v.key);
         v.key.encode_buf.Clear();
         v.key.db = dstdb;
         v.key.key = dstkey;
         v.meta.expireat = 0;
         SetKeyValue(ctx, v);
     }
     else
     {
         ListIterator iter;
         ListIter(ctx, v, iter, false);
         tmpctx.currentDB = dstdb;
         ValueObject dstmeta;
         dstmeta.key.type = KEY_META;
         dstmeta.key.key = dstkey;
         dstmeta.type = LIST_META;
         dstmeta.meta.SetFlag(COLLECTION_FLAG_SEQLIST);
         dstmeta.meta.SetEncoding(COLLECTION_ENCODING_ZIPLIST);
         BatchWriteGuard guard(GetKeyValueEngine());
         while (iter.Valid())
         {
             std::string tmpstr;
             ListInsert(tmpctx, dstmeta, NULL, iter.Element()->GetDecodeString(tmpstr), false, false);
             iter.Next();
         }
         SetKeyValue(tmpctx, dstmeta);
         tmpctx.currentDB = srcdb;
         DeleteKey(tmpctx, srckey);
     }
     ctx.data_change = true;
     return 0;
 }
示例#16
0
void MaxCPlanarMaster::generateVariablesForFeasibility(const List<ChunkConnection*>& ccons, List<EdgeVar*>& connectVars) {
	List<ChunkConnection*> cpy(ccons);
#if 0
	for(ChunkConnection *cc : cpy) {
		cc->printMe();
	}
#endif

	ArrayBuffer<ListIterator<NodePair> > creationBuffer(ccons.size());
	for (ListIterator<NodePair> npit = m_inactiveVariables.begin(); npit.valid(); ++npit) {
		bool select = false;
#if 0
		(*npit).printMe();
#endif
		ListIterator<ChunkConnection*> ccit = cpy.begin();
		while(ccit.valid()) {
			if((*ccit)->coeff(*npit)) {
				ListIterator<ChunkConnection*> delme = ccit;
				++ccit;
				cpy.del(delme);
				select = true;
			} else
				++ccit;
		}
		if(select) {
#if 0
			Logger::slout() << "<--CREATE";
#endif
			creationBuffer.push(npit);
		}
		if(cpy.size()==0) break;
	}
#if 0
	for(ChunkConnection *cc : cpy) {
		cc->printMe();
	}
#endif
	OGDF_ASSERT(cpy.size()==0);
	Logger::slout() << "Creating " << creationBuffer.size() << " Connect-Variables for feasibility\n";
	m_varsInit = creationBuffer.size();
	// realize creationList
	for(int i = creationBuffer.size(); i-- > 0;) {
		connectVars.pushBack( createVariable( creationBuffer[i] ) );
	}
}
示例#17
0
/**
 * Handle eraser event: "Delete Stroke" and "Standard", Whiteout is not handled here
 */
void EraseHandler::erase(double x, double y) {
	XOJ_CHECK_TYPE(EraseHandler);

	ListIterator<Layer*> it = this->page.layerIterator();

	int selected = page.getSelectedLayerId();

	this->halfEraserSize = this->handler->getThickness();
	GdkRectangle eraserRect = { x - halfEraserSize, y - halfEraserSize, halfEraserSize * 2, halfEraserSize * 2 };

	Range * range = new Range(x, y);

	while (it.hasNext() && selected) {
		Layer * l = it.next();

		ListIterator<Element *> eit = l->elementIterator();
		eit.freeze();
		while (eit.hasNext()) {
			Element * e = eit.next();
			if (e->getType() == ELEMENT_STROKE && e->intersectsArea(&eraserRect)) {
				Stroke * s = (Stroke *) e;

				eraseStroke(l, s, x, y, range);
			}
		}

		selected--;
	}

	this->view->rerenderRange(*range);
	delete range;
}
示例#18
0
BasicObject::~BasicObject()
{
	ListIterator<Face>* iter2 = faces.iterator();
	while(iter2->hasNext())
	{
		delete iter2->next();
	}

	ListIterator<Vertex>* iter = vertices.iterator();
	while(iter->hasNext())
	{
		delete iter->next();
	}	

	delete iter;
	delete iter2;
	printf("\nDeleting\n");
}
示例#19
0
bool Debugger::setVar(const UString &ident, const KJSO &value)
{
  if (!eng)
    return false;
  const List *chain = Context::current()->pScopeChain();
  ListIterator scope = chain->begin();
  while (scope != chain->end()) {
    if (scope->hasProperty(ident)) {
      if (!scope->canPut(ident))
	return false;
      scope->put(ident, value);
      return true;
    }
    scope++;
  }
  // didn't find variable
  return false;
}
示例#20
0
Value StringObjectFuncImp::call(ExecState *exec, Object &/*thisObj*/, const List &args)
{
  UString s;
  if (args.size()) {
    UChar *buf = new UChar[args.size()];
    UChar *p = buf;
    ListIterator it = args.begin();
    while (it != args.end()) {
      unsigned short u = it->toUInt16(exec);
      *p++ = UChar(u);
      it++;
    }
    s = UString(buf, args.size(), false);
  } else
    s = "";

  return String(s);
}
void main() {
    Recipe myRecipe1 =  Recipe("Fish Filets in Hot Chili Oil");
    Recipe myRecipe2 =  Recipe("Boiled Fish with Pickled Cabbage and Chili ");
    Recipe myRecipe3 =  Recipe("Coke Chicken");
    Recipe myRecipe4 =  Recipe("Fish ball soup");
    List<Recipe>* myRecipeList = new List<Recipe>();
    myRecipeList->Append(myRecipe1);
    myRecipeList->Append(myRecipe2);
    myRecipeList->Append(myRecipe3);
    myRecipeList->Append(myRecipe4);
    ListIterator<Recipe> myIterator = ListIterator<Recipe>(myRecipeList);
    for(myIterator.First(); !myIterator.IsDone(); myIterator.Next()) {
        myIterator.CurrentItem().Print();
    }
    while(1) {
        ;
    }
}
void NodePairEnergy::computeEnergy()
{
	int n_num = m_nonIsolated.size();
	double energySum = 0.0;
	Array<node> numNodes(1,n_num);

	ListIterator<node> it;
	for(it = m_nonIsolated.begin(); it.valid(); ++it) {
		numNodes[(*m_nodeNums)[*it]] = *it;
	}
	for(int i = 1; i <= n_num-1 ; i++) {
		for(int j = i+1; j <= n_num; j++) {
			double E = computePairEnergy(numNodes[i],numNodes[j]);
			(*m_pairEnergy)(i,j) = E;
			energySum += E;
		}
	}
	m_energy = energySum;
}
/*---------------------------------------------------------------------*//**
	配置オブジェクトリストへセーブデータを復元する

	@param listPlaceObj 配置オブジェクトリスト
	@retval true 成功
	@retval false 失敗
**//*---------------------------------------------------------------------*/
bool SaveStructure::restorePlacementObjData(List<PlacementObj*>* listPlaceObj) const
{
    for(ListIterator<PlacementObj*> it = listPlaceObj->iterator(); it.has(); it.next())
    {
        PlacementObj* pobj = it.object();

        for(int idx = 0; idx < NUM_POBJ_MAX; idx++)
        {
            const PlacementObj::SaveStructure* pobjsvst = &_pobjsvst[idx];
            if(isSamePlacementObj(pobjsvst, pobj))
            {
                pobj->restoreFromStructure(pobjsvst);	// 復元
                break;
            }
        }
    }

    return true;
}
示例#24
0
// isNextOperatorMultiplication
// Checks if the next operation in the expression has multiplication precedence
// This is used to ensure multiplication is handled before addition
// Parameters:
//     iter - the iterator for the list of tokens - not sent by reference, as in the other
//            functions, so that we can look ahead without having to go back again.
// Pre-condition: Next token is an operator (although, if it's not, I suppose the next operation isn't
//                technically multiplication)
// Return: whether the next operation is multiplication
bool isNextOperatorMultiplication(ListIterator iter)
{
    bool isMultiplication;
    iter.advance();

    switch (iter.tokenChar())
    {
    case '*':
    case '/':
    case '%':
        isMultiplication = true;
        break;
    default:
        isMultiplication = false;
        break;
    }

    return isMultiplication;
}
示例#25
0
void EditSelection::serialize(ObjectOutputStream & out) {
	out.writeObject("EditSelection");

	out.writeDouble(this->x);
	out.writeDouble(this->y);
	out.writeDouble(this->width);
	out.writeDouble(this->height);

	out << this->contents;
	out.endObject();

	ListIterator<Element *> it = this->getElements();
	int count = it.getLength();
	out.writeInt(count);

	while (it.hasNext()) {
		Element * e = it.next();
		out << e;
	}
}
//in ClusterGraph??
//is not yet recursive!!!
node collapseCluster(ClusterGraph& CG, cluster c, Graph& G)
{
	OGDF_ASSERT(c->cCount() == 0)

	ListIterator<node> its;
	SListPure<node> collaps;

	//we should check here if not empty
	node robinson = (*(c->nBegin()));

	for (its = c->nBegin(); its.valid(); its++)
		collaps.pushBack(*its);

	CG.collaps(collaps, G);

	if (c != CG.rootCluster())
		CG.delCluster(c);

	return robinson;
}
示例#27
0
void doFactor(ListIterator &i, TokenList *pf) // Grabs a factor; evaluates if needed; return
{
  int left;
  // factor = int || factor = (int + int)

  if(i.token().tokenChar() == '(')
    {
      i.advance();     
      doSum(i, pf); 
    }
  else
    {
      left = i.token().integerValue(); // grab the factor
      Token t(left);
      pf->push_back(t);    // add it to the list
    }
  if(!i.ended())
    i.advance();

}
示例#28
0
void doProduct(ListIterator & i, ExprNode *&node)
{
  ExprNode *left, *right;
  string oper;

  doFactor(i, node);

  if(!i.ended())
    oper = i.token().tokenChar(); 
  while(oper == "*" || oper == "/" || oper == "%")
    {
      i.advance();
      doFactor(i, right);
      node = new Operation(node, oper, right);
      if(!i.ended())
	oper = i.token().tokenChar();
      else
	oper = "Done";
    }
}
示例#29
0
文件: Scene.cpp 项目: alwalker/TTU
void Scene::render(Pixel* px)
{
	//Create zbuffer
	Matrix *zBuffer = new Matrix(px->getHeight(), px->getWidth());
	for(int i=0 ; i<px->getHeight() ; i++)
	{
		for(int j=0 ; j<px->getWidth() ; j++)
		{
			zBuffer->setElement(i, j, -1);
		}
	}
   //loop over all the Instance instances in the Scene and render them
   ListIterator<TransformNode>* ioIter = transformNodes->iterator();
   while (ioIter->hasNext())
   {
      TransformNode* tn = ioIter->next();
      tn->render(px, sceneTransform, zBuffer);
   }
   delete ioIter;
}
示例#30
0
	// computes energy of layout, stores it and sets the crossingMatrix
	void Planarity::computeEnergy()
	{
		int e_num = m_nonSelfLoops.size();
		int energySum = 0;
		Array<edge> numEdge(1,e_num);
		edge e;
		ListIterator<edge> it;

		for(it = m_nonSelfLoops.begin(); it.valid(); ++it)
			numEdge[(*m_edgeNums)[*it]] = *it;
		for(int i = 1; i < e_num; i++) {
			e = numEdge[i];
			for(int j = i+1; j <= e_num ; j++) {
				bool cross = intersect(e,numEdge[j]);
				(*m_crossingMatrix)(i,j) = cross;
				if(cross) energySum += 1;
			}
		}
		m_energy = energySum;
	}