本文整理汇总了C++中Link::append方法的典型用法代码示例。如果您正苦于以下问题:C++ Link::append方法的具体用法?C++ Link::append怎么用?C++ Link::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Link
的用法示例。
在下文中一共展示了Link::append方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv) {
using std::ifstream;
using std::string;
Link *x = new Link();
Link *y = new Link();
int test = 1;
ifstream ifp;
ifstream tfp;
string file = "data.txt";
if(argc >= 2 ) {
file = argv[argc - 1];
test = 0;
}
ifp.open(file.c_str());
int value;
while(ifp >> value) { x->prepend(value); }
ifp.close();
if(test == 1) { x->display(); }
tfp.open(file.c_str());
while(tfp >> value) { y->append(value); }
tfp.close();
if(test == 1) { y->display(); }
x->display();
y->display();
//add->display();
return 0;
}
示例2: compile
void StabVM::compile(const uint8_t *bytecode) {
size_t pc = 0; /* program counter */
Link *tip = nullptr;
Link *fork_ptr = nullptr;
uint8_t cmd;
uint8_t arg0, arg1;
size_t chain = 0; /* currently compiling chain */
size_t output = 0; /* used outputs counter */
size_t fork = 0; /* used forks counter */
size_t inv = 0; /* used inverters counter */
pc = 0;
while(true) {
cmd = bytecode[pc];
switch (cmd){
case END:
return;
case INPUT:
arg0 = bytecode[pc+1];
vmDbgCheck(arg0 < ACS_INPUT_ENUM_END);
vmDbgCheck(chain < TOTAL_INPUT_CNT);
tip = input_pool[chain].compile(&acs_in.ch[arg0]);
exec_chain[chain] = tip;
chain += 1;
pc += 2;
break;
case TERM:
tip->append(&terminator);
tip = nullptr;
pc += 1;
break;
case NEG:
vmDbgCheck(inv < TOTAL_INV_CNT);
tip = tip->append(&inverter_pool[inv]);
inv += 1;
pc += 1;
break;
case PID:
arg0 = bytecode[pc+1];
arg1 = bytecode[pc+2];
vmDbgCheck(arg0 < TOTAL_PID_CNT);
vmDbgCheck(arg1 < ACS_INPUT_ENUM_END);
tip = tip->append(pid_pool[arg0].compile(&acs_in.ch[arg1], &this->dT));
pc += 3;
break;
case SUM:
arg0 = bytecode[pc+1];
vmDbgCheck(arg0 < TOTAL_SUM_CNT);
tip = tip->append(&sum_pool[arg0]);
pc += 2;
break;
case SCALE:
arg0 = bytecode[pc+1];
vmDbgCheck(arg0 < TOTAL_SCALE_CNT);
tip = tip->append(&scale_pool[arg0]);
pc += 2;
break;
case FORK:
vmDbgCheck(nullptr == fork_ptr); /* nested forks forbidden */
vmDbgCheck(fork < TOTAL_FORK_CNT);
tip = tip->append(&fork_pool[fork]);
fork_ptr = tip;
fork += 1;
pc += 1;
break;
case FORK_RET:
vmDbgCheck(nullptr != fork_ptr); /* there is no fork return pending */
tip = fork_ptr;
pc += 1;
break;
case OUTPUT:
arg0 = bytecode[pc+1];
vmDbgCheck(output < TOTAL_OUT_CNT);
vmDbgCheck(arg0 < IMPACT_ENUM_END);
tip = tip->append(out_pool[output].compile(&impact.ch[arg0]));
output += 1;
pc += 2;
break;
default:
vmDbgPanic("illegal instruction");
break;
}
}
}