当前位置: 首页>>代码示例>>C++>>正文


C++ ListNode::head方法代码示例

本文整理汇总了C++中ListNode::head方法的典型用法代码示例。如果您正苦于以下问题:C++ ListNode::head方法的具体用法?C++ ListNode::head怎么用?C++ ListNode::head使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ListNode的用法示例。


在下文中一共展示了ListNode::head方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: size

int APLValue::size()
{
    int sz = 1;
    for (ListNode* n = shapedata; !n->isNil(); n = n->tail())
    {
        IntegerExpression* extent = n->head()->isInteger();
        if (extent)
        {
            sz *= extent->val();
        }
    }
    return sz;
}
开发者ID:Henry,项目名称:BuddKaminInterpreters,代码行数:13,代码来源:apl.C

示例2: dump

// Dump
void ListNode::dump(std::ostream &s) const
{
    if (VSEFlags::include_list_info)
    {
	// Formal list
	s << "[" << *head() << "|" << *tail() << "]";
    }
    else
    {
	// Somewhat cuter

	EmptyListNode *empty = new EmptyListNode;

	s << "(";

	const VSLNode *node = this; 
	while (node)
	{
	    if (node->isListNode())
	    {
		if (node != this)
		    s << ", ";

		ListNode *list = (ListNode *)node;
		s << *(list->head());
		node = list->tail();
	    }
	    else
	    {
		if (*node != *empty)
		{
		    if (node != this)
			s << ", ";

		    s << *node << "...";
		}
		node = 0;
	    }
	}

	s << ")";

	delete empty;
    }
}
开发者ID:KrisChaplin,项目名称:octeon_toolchain-4.1,代码行数:46,代码来源:ListNode.C

示例3: _dumpTree

// ...as tree
void ListNode::_dumpTree(std::ostream& s) const
{
    if (VSEFlags::include_list_info)
    {
	// Formal list
	head()->dumpTree(s);
	s << ",";
	tail()->dumpTree(s);
    }
    else
    {
	// Somewhat cuter

	EmptyListNode *empty = new EmptyListNode;

	const VSLNode *node = this; 
	while (node)
	{
	    if (node->isListNode())
	    {
		if (node != this)
		    s << ", ";

		ListNode *list = (ListNode *)node;
		list->head()->dumpTree(s);
		node = list->tail();
	    }
	    else
	    {
		if (*node != *empty)
		{
		    if (node != this)
			s << ", ";
		    node->dumpTree(s);
		}
		node = 0;
	    }
	}

	delete empty;
    }
}
开发者ID:KrisChaplin,项目名称:octeon_toolchain-4.1,代码行数:43,代码来源:ListNode.C

示例4: foldOps

int BuiltinCallNode::foldOps(VSLDef *cdef, VSLNode** node)
{
    assert (this == *node);
    int changes = 0;

    // Apply on all arguments
    changes += CallNode::foldOps(cdef, node);

    // If non-associative, return
    if (!VSLBuiltin::isAssoc(_index))
	return changes;

    // If arg is not a list, return
    if (!arg()->isListNode())
	return changes;

    ListNode *args = (ListNode *)arg(); // dirty trick

    // First arg must be a builtin call
    if (!args->head()->isBuiltinCallNode())
	return changes;

    BuiltinCallNode *callee = (BuiltinCallNode *)args->head(); // dirty trick

    // First arg must call the same function
    if (_index != callee->_index)
	return changes;

    // Arg must be a list
    if (!callee->arg()->isListNode())
	return changes;

    ListNode *callArgs = (ListNode *)callee->arg(); // dirty trick

    // Insert list
    if (VSEFlags::show_optimize)
    {
	std::cout << "\n" << cdef->longname() << ": foldOps: replacing\n" 
	    << *this << '\n';
	std::cout.flush();
    }

    int err = callArgs->append(args->tail());
    if (err)
    {
	if (VSEFlags::show_optimize)
	{
	    std::cout << "ABORTING (no replace) since append impossible\n";
	    std::cout.flush();
	}
	return changes;
    }

    VSLNode *newArgs = callee->arg();
    callee->arg() = 0; args->tail() = 0; delete args;
    arg() = newArgs;

    if (VSEFlags::show_optimize)
    {
	std::cout << "by " << *this << '\n';
	std::cout.flush();
    }

    changes++;

    return changes;
}
开发者ID:KrisChaplin,项目名称:octeon_toolchain-4.1,代码行数:67,代码来源:BuiltinCN.C

示例5: foldConsts

int BuiltinCallNode::foldConsts(VSLDef *cdef, VSLNode** node)
{
    // Apply standard optimization
    int changes = CallNode::foldConsts(cdef, node);

    // If optimization was a success, return
    if (*node != this || isConst())
	return changes;

    // If non-associative, return
    if (!VSLBuiltin::isAssoc(_index))
	return changes;

    // Otherwise: isolate constant args in constant subexpressions and
    // optimize them separately
    for (VSLNode *a = arg();
	 a->isListNode() && ((ListNode *)a)->tail()->isListNode();
	 a = ((ListNode *)a)->tail())
    {
	ListNode *list = (ListNode *)a;
	ListNode *tail = (ListNode *)list->tail();

	VSLNode *arg1 = list->head();
	VSLNode *arg2 = tail->head();

	if (arg1->isConst() && arg2->isConst())
	{
	    if (VSEFlags::show_optimize)
	    {
		std::cout << "\n" << cdef->longname() << ": foldConsts: replacing\n"
		    << *this << '\n';
		std::cout.flush();
	    }

	    // Found 2 args arg1, arg2 that are both constant: Replace
	    // f(..., arg1, arg2, ...) by f(..., f(arg1, arg2), ...)

	    // Create f(arg1, arg2)
	    ListNode *new_args = new FixListNode(arg1, arg2);
	    BuiltinCallNode *new_f = new BuiltinCallNode(_index, new_args);

	    // Move nextarg into f(arg, nextarg)
	    list->head() = new_f;
	    list->tail() = tail->tail();

	    tail->head() = 0; tail->tail() = 0; delete tail;

	    if (VSEFlags::show_optimize)
	    {
		std::cout << "by " << *this << '\n';
		std::cout.flush();
	    }

	    changes++;
	}
    }

    // Now try optimization once again
    changes += CallNode::foldConsts(cdef, node);

    return changes;
}
开发者ID:KrisChaplin,项目名称:octeon_toolchain-4.1,代码行数:62,代码来源:BuiltinCN.C


注:本文中的ListNode::head方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。