C++ (Qt)template <typename NodeData> struct OctNode {00037 OctNode() {00038 for (int i = 0; i < 8; ++i)00039 children[i] = NULL;00040 }00041 ~OctNode() {00042 for (int i = 0; i < 8; ++i)00043 delete children[i];00044 }00045 OctNode *children[8];00046 vector<NodeData> data;00047 };
C++ (Qt)NNumeric Stack::pop (){ NNumeric tmp = *m_stack.back (); delete m_stack.back (); m_stack.pop_back (); return tmp;}
C++ (Qt)void NeorgekEngine::NEngine::MathematicalOperations(ushort Modifikator){ NNumeric arg0, arg1, arg2; NDataTypes* dt; switch (Modifikator) { case 2: dt = this->StackValue.pop(); arg2 = dynamic_cast<NNumeric*>(dt); delete dt; dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; if (!arg1.IsReal() && !arg2.IsReal()) { arg0.setIsReal(false); arg0.setValue(double(arg1) + double(arg2)); } else arg0 = double(arg1) + double(arg2); this->StackValue.push(arg0); break; case 3: dt = this->StackValue.pop(); arg2 = dynamic_cast<NNumeric*>(dt); delete dt; dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; if (!arg1.IsReal() && !arg2.IsReal()) { arg0.setIsReal(false); arg0.setValue(double(arg1) - double(arg2)); } else arg0 = double(arg1) - double(arg2); this->StackValue.push(arg0); break; case 4: dt = this->StackValue.pop(); arg2 = dynamic_cast<NNumeric*>(dt); delete dt; dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; if (!arg1.IsReal() && !arg2.IsReal()) { arg0.setIsReal(false); arg0.setValue(double(arg1) * double(arg2)); } else arg0 = double(arg1) * double(arg2); this->StackValue.push(arg0); break; case 5: dt = this->StackValue.pop(); arg2 = dynamic_cast<NNumeric*>(dt); delete dt; dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; //if (arg2 == 0) if (!arg1.IsReal() && !arg2.IsReal()) { arg0.setIsReal(false); arg0.setValue(double(arg1) / double(arg2)); } else arg0 = double(arg1) / double(arg2); this->StackValue.push(arg0); break; case 6: dt = this->StackValue.pop(); arg0 = dynamic_cast<NNumeric*>(dt); delete dt; arg0++; arg0.setID(-1); arg0.setConstValue(false); arg0.setName(""); this->StackValue.push(arg0); break; case 7: dt = this->StackValue.pop(); arg0 = dynamic_cast<NNumeric*>(dt); delete dt; arg0--; arg0.setID(-1); arg0.setConstValue(false); arg0.setName(""); this->StackValue.push(arg0); break; case 8: dt = this->StackValue.pop(); arg2 = dynamic_cast<NNumeric*>(dt); delete dt; dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; arg0.setIsReal(false); arg0.setValue((ldiv(qint32(arg1), qint32(arg2)).quot)); this->StackValue.push(arg0); break; case 9: dt = this->StackValue.pop(); arg2 = dynamic_cast<NNumeric*>(dt); delete dt; dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; arg0.setIsReal(false); arg0.setValue((ldiv(qint32(arg1), qint32(arg2)).rem)); this->StackValue.push(arg0); break; case 10: dt = this->StackValue.pop(); arg2 = dynamic_cast<NNumeric*>(dt); delete dt; dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; if (!arg1.IsReal() && !arg2.IsReal()) { arg0.setIsReal(false); arg0.setValue(pow(double(arg1),double(arg2))); } else arg0 = pow(double(arg1),double(arg2)); this->StackValue.push(arg0); break; case 11: dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; if (!arg1.IsReal()) { arg0.setIsReal(false); arg0.setValue(sqrt(double(arg1))); } else arg0 = sqrt(double(arg1)); this->StackValue.push(arg0); break; case 12: dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; arg0.setIsReal(arg1.IsReal()); arg0.setValue(std::abs(double(arg1))); this->StackValue.push(arg0); break; case 13: dt = this->StackValue.pop(); arg2 = dynamic_cast<NNumeric*>(dt); delete dt; dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; if (double(arg1) < double(arg2)) arg0 = arg1; else arg0 = arg2; arg0.setID(-1); arg0.setConstValue(false); arg0.setName(""); this->StackValue.push(arg0); break; case 14: dt = this->StackValue.pop(); arg2 = dynamic_cast<NNumeric*>(dt); delete dt; dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; if (double(arg1) > double(arg2)) arg0 = arg1; else arg0 = arg2; arg0.setID(-1); arg0.setConstValue(false); arg0.setName(""); this->StackValue.push(arg0); break; case 15: dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; srand ( time(NULL) ); arg0.setIsReal(false); arg0.setValue(qint32(rand() % qint32(arg1))); this->StackValue.push(arg0); break; case 16: dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; arg0 = log10(double(arg1)); this->StackValue.push(arg0); break; case 17: dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; arg0 = log(double(arg1)); this->StackValue.push(arg0); break; case 18: dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; arg0 = exp(double(arg1)); this->StackValue.push(arg0); break; case 19: dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; arg0 = cos(double(arg1)); this->StackValue.push(arg0); break; case 20: dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; arg0 = sin(double(arg1)); this->StackValue.push(arg0); break; case 21: dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; arg0 = tan(double(arg1)); this->StackValue.push(arg0); break; case 22: dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; arg0 = 1.0/tan(double(arg1)); this->StackValue.push(arg0); break; case 23: dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; arg0 = acos(double(arg1)); this->StackValue.push(arg0); break; case 24: dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; arg0 = asin(double(arg1)); this->StackValue.push(arg0); break; case 25: dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; arg0 = atan(double(arg1)); this->StackValue.push(arg0); break; case 26: dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; arg0 = 1.0/atan(double(arg1)); this->StackValue.push(arg0); break; case 27: dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; arg0 = floor(double(arg1)); this->StackValue.push(arg0); break; case 28: dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; arg0 = ceil(double(arg1)); this->StackValue.push(arg0); break; case 29: dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; arg0 = arg1.round(); this->StackValue.push(arg0); break; case 30: dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; arg0 = arg1.fractional(); this->StackValue.push(arg0); break; case 31: dt = this->StackValue.pop(); arg1 = dynamic_cast<NNumeric*>(dt); delete dt; arg0 = arg1.integer(); this->StackValue.push(arg0); break; case 32: srand ( time(NULL) ); arg0 = double(rand() % 1001)/1000.0; this->StackValue.push(arg0); break; }}
C++ (Qt)case NNumeric::operation_plus: stack.push(stack.pop_value() + stack.pop_valie()); break;
C++ (Qt)NNumeric Stack::pop_value( void ){ if (!size()) throw "stack error"; NNumeric * temp = pop(); NNumeric value(*temp); delete temp; return value;}
Модификатор Комментарий2 +3 -4 *5 /6 ++7 --8 целочисленное деление9 % (остаток от целочисленного деления)10 ^11 квадратный корень12 модуль числа13 минимальное число14 максимальное число15 целочисленный рандом от 0 и до m-116 log1017 ln18 exp19 cos20 sin21 tg22 ctg23 arccos24 arcsin25 arctg26 arcctg27 округление в сторону нуля до целого28 округление в большую сторону до целого29 округление до целого30 выделение дробной части31 отсечение дробной части32 рандом от 0 до 1