本文整理汇总了C++中SNode类的典型用法代码示例。如果您正苦于以下问题:C++ SNode类的具体用法?C++ SNode怎么用?C++ SNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSuccessors
void getSuccessors(SNode& node, std::vector<SNode>* s, std::vector<double>* c) {
SNode reachableNode;
for (int deltaX = -1; deltaX <= 1; ++deltaX) {
for (int deltaY = -1; deltaY <= 1; ++deltaY) {
if (deltaX == 0 && deltaY == 0 && node.velocityVector.first == 0 && node.velocityVector.second == 0) {
continue;
}
reachableNode.position = std::make_pair(node.position.first + node.velocityVector.first + deltaX,
node.position.second + node.velocityVector.second + deltaY);
reachableNode.velocityVector = std::make_pair(node.velocityVector.first + deltaX,
node.velocityVector.second + deltaY);
reachableNode.setDirection(deltaX, deltaY);
if (reachableNode.position.first > 0 &&
reachableNode.position.second > 0 &&
reachableNode.position.first < aStarStaticMap->sizeOnXaxis() &&
reachableNode.position.second < aStarStaticMap->sizeOnYaxis() /*&&
aStarStaticMap->canPlayerMoveFromThisPositionWithSuchVector(node.position.first,
node.position.second,
reachableNode.velocityVector.first,
reachableNode.velocityVector.second)*/)
{
//std::cout << "ReachableNode: " << reachableNode.position.first << " " << reachableNode.position.second << std::endl;
s->push_back(reachableNode);
c->push_back(1);
}
}
}
}
示例2: copySwitching
void DerivationWriter :: copySwitching(SNode node)
{
SNode current = node.firstChild();
while (current != lxNone) {
Symbol symbol = (Symbol)current.type;
switch (symbol) {
case nsSwitchOption:
case nsBiggerSwitchOption:
case nsLessSwitchOption:
_writer.newBookmark();
unpackChildren(current);
if (symbol == nsBiggerSwitchOption) {
_writer.insert(lxOption, GREATER_MESSAGE_ID);
}
else if (symbol == nsLessSwitchOption) {
_writer.insert(lxOption, LESS_MESSAGE_ID);
}
else _writer.insert(lxOption, EQUAL_MESSAGE_ID);
_writer.closeNode();
_writer.removeBookmark();
break;
case nsLastSwitchOption:
_writer.newBookmark();
unpackChildren(current);
_writer.insert(lxElse);
_writer.closeNode();
_writer.removeBookmark();
break;
default:
break;
}
current = current.nextNode();
}
}
示例3: login
int Client::list(const string& path, vector<SNode>& attr)
{
string revised_path = Metadata::revisePath(path);
SectorMsg msg;
msg.resize(65536);
msg.setType(101);
msg.setKey(m_iKey);
msg.setData(0, revised_path.c_str(), revised_path.length() + 1);
Address serv;
m_Routing.lookup(revised_path, serv);
login(serv.m_strIP, serv.m_iPort);
if (m_GMP.rpc(serv.m_strIP.c_str(), serv.m_iPort, &msg, &msg) < 0)
return SectorError::E_CONNECTION;
if (msg.getType() < 0)
return *(int32_t*)(msg.getData());
string filelist = msg.getData();
unsigned int s = 0;
while (s < filelist.length())
{
int t = filelist.find(';', s);
SNode sn;
sn.deserialize(filelist.substr(s, t - s).c_str());
attr.insert(attr.end(), sn);
s = t + 1;
}
return attr.size();
}
示例4: copyVariable
void DerivationWriter :: copyVariable(SNode node)
{
SNode local = node.firstChild();
_writer.newNode(lxVariable);
if (_hints != lxNone) {
copyHints(_hints);
_hints = lxNone;
}
unpackNode(local, 0);
_writer.closeNode();
SNode current = node.findChild((LexicalType)nsAssigning);
if (current != lxNone) {
_writer.newNode(lxExpression);
_writer.appendNode(lxAssign);
unpackNode(local, 1);
unpackChildren(current);
_writer.closeNode();
}
}
示例5: resolveClosure
ref_t ModuleScope :: resolveClosure(ref_t closureMessage, ref_t outputRef, ident_t ns)
{
ref_t signRef = 0;
module->resolveAction(getAction(closureMessage), signRef);
int paramCount = getParamCount(closureMessage);
IdentifierString closureName(module->resolveReference(closureTemplateReference));
if (signRef == 0) {
if (paramCount > 0) {
closureName.appendInt(paramCount);
}
if (isWeakReference(closureName)) {
return module->mapReference(closureName, true);
}
else return mapFullReference(closureName, true);
}
else {
ref_t signatures[ARG_COUNT];
size_t signLen = module->resolveSignature(signRef, signatures);
List<SNode> parameters;
SyntaxTree dummyTree;
SyntaxWriter dummyWriter(dummyTree);
dummyWriter.newNode(lxRoot);
for (size_t i = 0; i < signLen; i++) {
dummyWriter.appendNode(lxTarget, signatures[i]);
}
if (outputRef) {
dummyWriter.appendNode(lxTarget, outputRef);
}
// if the output signature is not provided - use the super class
else dummyWriter.appendNode(lxTarget, superReference);
dummyWriter.closeNode();
SNode paramNode = dummyTree.readRoot().firstChild();
while (paramNode != lxNone) {
parameters.add(paramNode);
paramNode = paramNode.nextNode();
}
closureName.append('#');
closureName.appendInt(paramCount + 1);
ref_t templateReference = 0;
if (isWeakReference(closureName)) {
templateReference = module->mapReference(closureName, true);
}
else templateReference = mapFullReference(closureName, true);
if (templateReference) {
return generateTemplate(templateReference, parameters, ns, false);
}
else return superReference;
}
}
示例6: injectNewOperation
void CompilerLogic :: injectNewOperation(SNode node, _CompilerScope& scope, int operation, ref_t elementType, ref_t targetRef)
{
SNode operationNode = node.injectNode((LexicalType)operation, targetRef);
int size = defineStructSize(scope, targetRef, elementType, false);
if (size != 0)
operationNode.appendNode(lxSize, size);
}
示例7: TRUE
/** first
0 - FALSE - call to handel nodes with next priority / order
1 - TRUE (default) - first call for this object
*/
bool INode::childTopDown(bool first)
{
#ifdef DEBUGMSG
qDebug("# INode::childTopDown (%s) cont_td (this %p) first: %d", (const char *) name(), this, first);
qDebug("##(xxx) INode::childTopDown (%s) (this %p) #childcount %d, ordercount %d, aktivorder %d, aktivcount %d, truncation %d",
(const char *) name(), this, childcount_,ordercount_,aktivorder_,aktivcount_,truncation());
#endif
SNode *el; // hilfspointer
if (first) {// first call of 'childTopDown' for this object
childList_ = &(sNode_->children()); // liste der subknoten erzeugen
childcount_ = childList_->count(); // anzahl aller (noch) zu bearbeitenden knoten
aktivorder_=-1; // prioritaet der zu bearbeitenden nodes
if (childcount_ == 0) { //no sub nodes
aktivcount_ = 0;
execBottomUp(); //execState(BU);// BottomUp
return 0;
}
} else { // recursiv call of 'childTopDown' for this object
if (aktivcount_ > 0 || ordercount_ > 0 ) return 1;
if (childcount_ <= 0) return 0;//all sub nodes are handled
if (truncation()) return 0; //all sub nodes are handelt or node is trash
}
//Praemisse (ordercount_ == 0) && (childcount_ > 0)
while (ordercount_ == 0) {
aktivorder_ ++;
for (el = childList_->first(); el != 0; el = childList_->next())
if(el->order() == aktivorder_) ordercount_++; // anzahl der nodes der aktuellen prioritaet
}
#ifdef DEBUGMSG
qDebug("## INode::childTopDown (%s) (this %p) #childs %d, ordercount %d, aktivorder %d, aktivcount_ %d",
(const char *) name(), this, childcount_, ordercount_, aktivorder_,aktivcount_);
#endif
INode *inode;
for (el = childList_->first(); el != 0; el = childList_->next()) {
if (truncation()) { //bedingungen nicht mehr erfüllt
aktivcount_ = 0;
execBottomUp(); //execState(BU);// BottomUp
return 0;
}
if (el->order() == aktivorder_) {
incrementCount(); //einer mehr in der queue -> siehe decrementCount()
childcount_--; ordercount_--; //aktuelle wird gleich bearbeitet
inode = new INode(el); //new INode
CHECK_PTR(inode);
inode->status(HI);
inode->execState(TD);
childLink(inode); // remount node in the tree
inode->execTopDown(); //start topdown operator
//childcount_--; ordercount_--; //aktuelle wird gleich bearbeitet
//!MP25.07.2001 inode might be deleted
//! analysis_->nodeChange(inode); //info to the rest of the world
analysis_->nodeChange(0);
}
}
return 1;
}
示例8: report
int Slave::report(const string& master_ip, const int& master_port, const int32_t& transid, const vector<string>& filelist, const int& change)
{
vector<string> serlist;
for (vector<string>::const_iterator i = filelist.begin(); i != filelist.end(); ++ i)
{
struct stat s;
if (-1 == stat((m_strHomeDir + *i).c_str(), &s))
continue;
SNode sn;
sn.m_strName = *i;
sn.m_bIsDir = S_ISDIR(s.st_mode) ? 1 : 0;
sn.m_llTimeStamp = s.st_mtime;
sn.m_llSize = s.st_size;
char buf[1024];
sn.serialize(buf);
//update local
Address addr;
addr.m_strIP = "127.0.0.1";
addr.m_iPort = 0;
m_pLocalFile->update(buf, addr, change);
serlist.push_back(buf);
}
if (serlist.empty())
return 0;
SectorMsg msg;
msg.setType(1);
msg.setKey(0);
msg.setData(0, (char*)&transid, 4);
msg.setData(4, (char*)&m_iSlaveID, 4);
msg.setData(8, (char*)&change, 4);
int32_t num = serlist.size();
msg.setData(12, (char*)&num, 4);
int pos = 16;
for (vector<string>::iterator i = serlist.begin(); i != serlist.end(); ++ i)
{
int32_t bufsize = i->length() + 1;
msg.setData(pos, (char*)&bufsize, 4);
msg.setData(pos + 4, i->c_str(), bufsize);
pos += bufsize + 4;
}
cout << "report " << master_ip << " " << master_port << " " << num << endl;
if (m_GMP.rpc(master_ip.c_str(), master_port, &msg, &msg) < 0)
return -1;
if (msg.getType() < 0)
return *(int32_t*)msg.getData();
return 1;
}
示例9: unpackChildren
void DerivationWriter :: unpackChildren(SNode node, int mode)
{
SNode current = node.firstChild();
while (current != lxNone) {
unpackNode(current, mode);
current = current.nextNode();
}
}
示例10: main
int main()
{
//prueba del constructor por omision
SNode<int> node;
SNode<int> * aux = new SNode<int>;
cout<<"Valores por omision"<<endl;
printSNode(&node);cout<<endl;
printSNode(aux);cout<<endl;
//constructores por copia
SNode<int> node1(10);
SNode<int> * aux1 = new SNode<int>(20);
cout<<"Valores por copia"<<endl;
printSNode(&node1);cout<<endl;
printSNode(aux1);cout<<endl;
//insertamos elementos en una lista simple
SNode<int> lista;
for(int i = 0; i < 10 ; i++)
{
lista.insertNext(i);
}
cout<<"Valores de la lista"<<endl;
imprimirLista(lista);
//insertamos elementos en una lista simple de manera ordenada
SNode<int> listaOrdenada;
for(int i = 0; i < 10 ; i++)
{
listaOrdenada.orderedInsertion(i);
}
cout<<"Valores de lista Ordenada"<<endl;
imprimirLista(listaOrdenada);
//utilizamos el iterador sobre nodo
cout<<"Valores lista ordenada usando iterador"<<endl;
for(SNode<int>::Iterator it(&listaOrdenada); it.hasCurrent(); it.next())
{
cout<<it.getCurrent()->getData()<<" ";
}
cout<<endl;
cout<<"Valores lista ordenada"<<endl;
simpleSort(lista);
//quickSort(lista);
imprimirLista(lista);
cout<<"Valores minimo de la lista"<<endl;
cout<<searchMin(&lista)<<endl;
delete aux;
delete aux1;
return 0;
}
示例11:
void TMCtrl::capture(AnimCtrl* animctrl, void* opaque)
{
if(!_node.valid())
return;
SNode* n = _node.get_unsafe();
_pos_captured = n->pos();
_rot_captured = n->rot();
_scale_captured = n->scale();
}
示例12: ENTERMETHOD
SNode SNode::multiplyParenthesesInProduct() const {
ENTERMETHOD();
CHECKNODETYPE(*this,NT_PRODUCT);
const FactorArray &a = getFactorArray();
const size_t n = a.size();
FactorArray newFactorArray(a.getTree(), n);
for(size_t i = 0; i < n; i++) {
SNode f = a[i];
newFactorArray *= powerExp(f.base().multiplyParentheses(), f.exponent().multiplyParentheses());
}
BitSet done(newFactorArray.size() + 1);
do {
FactorArray tmp = newFactorArray;
newFactorArray.clear();
done.setCapacity(tmp.size() + 1);
done.clear();
for(size_t i1 = 1; i1 < tmp.size(); i1++) {
if(done.contains(i1)) continue;
SNode f1 = tmp[i1];
if((f1.base().getSymbol() == SUM) && !f1.exponent().isOne()) {
continue;
}
for(size_t i2 = 0; i2 < i1; i2++) {
if(done.contains(i1)) break;
if(done.contains(i2)) continue;
SNode f2 = tmp[i2];
if((f2.base().getSymbol() == SUM) && !f2.exponent().isOne()) {
continue;
}
if(f1.base().getSymbol() == SUM) {
newFactorArray *= multiplyFactorSum(f2, f1.base());
done.add(i1);
done.add(i2);
} else if(f2.base().getSymbol() == SUM) {
newFactorArray *= multiplyFactorSum(f1, f2.base());
done.add(i1);
done.add(i2);
}
}
}
for(size_t i = 0; i < tmp.size(); i++) {
if(!done.contains(i)) {
newFactorArray *= tmp[i];
}
}
} while(!done.isEmpty());
SNode result = productExp(newFactorArray);
RETURNNODE( result );
}
示例13: injectVariableAssigning
void CompilerLogic :: injectVariableAssigning(SNode node, _CompilerScope& scope, _Compiler& compiler, ref_t targetRef, ref_t& type, bool paramMode)
{
ClassInfo info;
defineClassInfo(scope, info, targetRef);
node.setArgument(defineStructSize(info, false));
//HOTFIX : allowing to assign a reference variable
if (!node.argument && paramMode) {
// replace the parameter with the field expression
compiler.injectFieldExpression(node.firstChild(lxObjectMask));
type = info.fieldTypes.get(0).value2;
}
}
示例14: copyNode
void SyntaxTree :: copyNode(SyntaxTree::Writer& writer, SyntaxTree::Node node)
{
SNode current = node.firstChild();
while (current != lxNone) {
if (current.strArgument >= 0) {
writer.newNode(current.type, current.identifier());
}
else writer.newNode(current.type, current.argument);
copyNode(writer, current);
writer.closeNode();
current = current.nextNode();
}
}
示例15: findTerminalInfo
SyntaxTree::Node SyntaxTree :: findTerminalInfo(SyntaxTree::Node node)
{
if (node.existChild(lxRow))
return node;
SNode current = node.firstChild();
while (current != lxNone) {
SNode terminalNode = findTerminalInfo(current);
if (terminalNode != lxNone)
return terminalNode;
current = current.nextNode();
}
return current;
}