本文整理汇总了C++中ListNode类的典型用法代码示例。如果您正苦于以下问题:C++ ListNode类的具体用法?C++ ListNode怎么用?C++ ListNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ListNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: error
void LazyFunction::apply(Expr& target, ListNode* args, Environment* rho)
{
// number of args should match definition
ListNode* anames = argNames_;
if (anames->length() != args->length())
{
error("argument length mismatch");
return;
}
// convert arguments into thunks
ListNode* newargs = makeThunks(args, rho);
// make new environment
Environment* newrho = new Environment(anames, newargs, context_);
// evaluate body in new environment
if (body_())
{
body_()->eval(target, valueOps, newrho);
}
else
{
target = 0;
}
newrho = 0;
}
示例2: main
int main(int argc, const char * argv[]) {
// ListNode *n = new ListNode(1);
// n->addNode(2)->addNode(3)->addNode(4)->addNode(5);
//
// Solution a;
// a.reverseBetween(n, 2, 4);
// ListNode *n = new ListNode(5);
//
// Solution a;
// a.reverseBetween(n, 1, 1);
// ListNode *n = new ListNode(3);
// n->addNode(5);
//
// Solution a;
// a.reverseBetween(n, 1, 2);
ListNode *n = new ListNode(1);
n->addNode(2)->addNode(3);
Solution a;
a.reverseBetween(n, 1, 2);
return 0;
}
示例3: MOZ_ASSERT
ParseNode *
ParseNode::append(ParseNodeKind kind, JSOp op, ParseNode *left, ParseNode *right,
FullParseHandler *handler)
{
if (!left || !right)
return nullptr;
MOZ_ASSERT(left->isKind(kind) && left->isOp(op) && (js_CodeSpec[op].format & JOF_LEFTASSOC));
ListNode *list;
if (left->pn_arity == PN_LIST) {
list = &left->as<ListNode>();
} else {
ParseNode *pn1 = left->pn_left, *pn2 = left->pn_right;
list = handler->new_<ListNode>(kind, op, pn1);
if (!list)
return nullptr;
list->append(pn2);
}
list->append(right);
list->pn_pos.end = right->pn_pos.end;
return list;
}
示例4: member
bool List::member(ICollectible *c) const{
for(ListNode *current = head; current != NULL; current = current->getNext())
if(current->getElem() == c)
return true;
return false;
}
示例5:
ParseNode*
ParseNode::appendOrCreateList(ParseNodeKind kind, JSOp op, ParseNode* left, ParseNode* right,
FullParseHandler* handler, ParseContext<FullParseHandler>* pc)
{
// The asm.js specification is written in ECMAScript grammar terms that
// specify *only* a binary tree. It's a royal pain to implement the asm.js
// spec to act upon n-ary lists as created below. So for asm.js, form a
// binary tree of lists exactly as ECMAScript would by skipping the
// following optimization.
if (!pc->useAsmOrInsideUseAsm()) {
// Left-associative trees of a given operator (e.g. |a + b + c|) are
// binary trees in the spec: (+ (+ a b) c) in Lisp terms. Recursively
// processing such a tree, exactly implemented that way, would blow the
// the stack. We use a list node that uses O(1) stack to represent
// such operations: (+ a b c).
if (left->isKind(kind) && left->isOp(op) && (js_CodeSpec[op].format & JOF_LEFTASSOC)) {
ListNode* list = &left->as<ListNode>();
list->append(right);
list->pn_pos.end = right->pn_pos.end;
return list;
}
}
ParseNode* list = handler->new_<ListNode>(kind, op, left);
if (!list)
return nullptr;
list->append(right);
return list;
}
示例6: while
//
// SquadObj::LoadState
//
// Load a state configuration scope
//
void SquadObj::LoadState(FScope *fScope)
{
// Call parent scope first
GameObj::LoadState(fScope);
// Get specific config scope
fScope = fScope->GetFunction(SCOPE_CONFIG);
FScope *sScope;
while ((sScope = fScope->NextFunction()) != NULL)
{
switch (sScope->NameCrc())
{
case 0xEDF0E1CF: // "Team"
SetTeam(Team::Name2Team(StdLoad::TypeString(sScope)));
break;
case 0x2F382D90: // "ModifierSettings"
settings.LoadState(sScope);
break;
case 0xE3554C44: // "Node"
{
ListNode *node = list.Append();
StdLoad::TypeReaper(sScope, *node);
node->LoadState(sScope);
break;
}
}
}
}
示例7: binarySearchX
vector< Point2d > PointPersistentList::enumerateNE(coord_t x, coord_t y) {
vector< Point2d > v;
// determine the time at which to search by searching for the x
int index = binarySearchX(x);
// if set of points is empty, bail out
if(index == -1) return v;
// while the closest point is too small
while(points_sorted_by_x[index].x < x) {
// check the previous point, which should be larger since the
// array is sorted by x descending
--index;
// if we have passed the beginning of the array, then there are no
// points within the query region
if(index < 0)
return v;
}
// get the first node in this list at time index
ListNode<Point2d, Point2d::yxdesc >* pln = points_right.getList(index);
// while the current point is not null and has a greater or equal
// y than the query
while(pln != NULL && pln->data.y >= y) {
// push the point onto the list to be returned
v.push_back(pln->data);
// move on to next point
pln = pln->getNext(index);
}
return v;
}
示例8: removeFromBack
bool LinkedList::removeFromBack(string &output)
{
if (!isEmpty())
{
ListNode* currNode = head;
ListNode* prevNode;
// move to second last node
while (currNode->getNext() != NULL)
{
prevNode = currNode;
currNode = currNode->getNext();
}
output = currNode->value;
delete currNode;
prevNode->next = NULL;
last = prevNode;
}
else
{
return false;
}
}
示例9: remove
void PtrListRep::remove(void* element)
{
if(element!=NULL && _first!=NULL)
{
for(ListNode* n=_first; n!=NULL; n=n->getNext())
{
void* el = n->getElement();
if(el==element)
{ // remove the node
ListNode* prev = n->getPrevious();
ListNode* next = n->getNext();
if(prev!=NULL)
prev->setNext(next);
else // the node is the very first
_first = next;
if(next!=NULL)
next->setPrevious(prev);
else // the node is the last
_last = prev;
delete n;
break;
}
}
}
}
示例10: DoNetList
void DoNetList(FILE *pFout, BomKeyNode *pBkn, ListNode *pNetList){
KeyValNode *kvn;
MapNode *mn;
ListNode *ln;
int c,d;
const char *net_in;
char net_out[32];
for(c = 0; c < pNetList->count(); c++){
mn = pNetList->getNode(c);
if(mn->nodeType() == 2){
kvn = (KeyValNode*)mn;
mn = kvn->value();
if(mn->nodeType() == 3 && mn != pNetList){
net_in = kvn->key();
if(net_in[0] != '*'){
strcpy(net_out, net_in);
}else{
sprintf(net_out, "unnamed_%s", &(net_in[1]));
}
fprintf(pFout, "%s\t", net_out);
ln = (ListNode *) mn;
for(d = 0; d < ln->count(); d++){
fprintf(pFout, "%s",pBkn->printRef(ln->getNode(d)));
}
fprintf(pFout, "\n");
}
}
}
}
示例11: Print
// Print the list.
void ListNode::Print () {
ListNode* list = this;
for (; list; list = list->Rest()) {
cout << list->First() << " ";
}
cout << endl;
}
示例12: Remove
void LinkedList::Remove(void* item)
{
if (frontNode)
{
ListNode* currNode = frontNode;
do
{
if (currNode->GetItem() == item)
{
break;
}
currNode = currNode->GetNext();
} while (currNode);
if (currNode)
{
delete currNode;
numItems--;
if (numItems == 0)
{
frontNode = NULL;
backNode = NULL;
}
}
}
}
示例13: createMiddlePhaseJobs
/*!
* Create middlephase jobs according to the \ref BroadPhaseJob.
*
* See also \ref MiddlePhaseJobCreator and \ref
* DetectorDeformManager::pickAlgorithmFor
*/
void Pipeline::createMiddlePhaseJobs(BroadPhaseJob* broadPhaseJob) {
List<CollisionPair*>& jobResults = broadPhaseJob->getJobResultsReference();
for (ListNode<CollisionPair*>* node = jobResults.getFirstNode(); node; node = node->getNext()) {
CollisionPair* pair = node->getData();
// TODO make CollisionPair store Proxy pointers.
// we usually dont care about the BVs when reading the pairs!!
Proxy* p1 = pair->bvol1->getHierarchyNode()->getProxy();
Proxy* p2 = pair->bvol2->getHierarchyNode()->getProxy();
if (p1->getProxyType() & PROXYTYPE_DEFORMABLE ||
p2->getProxyType() & PROXYTYPE_DEFORMABLE) {
if (mWorld->getUseCollisionCaching()) {
bool cacheApplied = mWorld->getCollisionCache()->applyCacheIfAvailable(p1, p2);
if (cacheApplied) {
continue;
}
}
DetectorDeformAlgorithm* algorithm = mDetectorDeformManager->pickAlgorithmFor(p1, p2);
if (algorithm) {
// TODO: fix API.
// createCollisionJobFor() uses CollisionPair,
// pickAlgorithmFor() uses two Proxy pointers.
// choose one!
algorithm->createCollisionJobFor(*pair);
}
}
}
mMiddlePhaseJobCreator->createJobs(broadPhaseJob);
}
示例14: add
void KdTree::add( KdTreeNode* kdnode, Object* ob )
{
//std::cout<<_buffer_l<<std::endl;
ListNode* node = &_ListNodeBuffer[_buffer_l++];
node->setObject( ob );
node->setNext( kdnode->getList() );
kdnode->setList( node );
}
示例15: while
void List<NODETYPE>::concatenate(List<NODETYPE> &listSecond) {
ListNode<NODETYPE> *currentPtr = listSecond.firstPtr;
while (currentPtr != 0) {
insertAtBack(currentPtr->getData());
currentPtr = currentPtr->nextPtr;
}
}