LintCode 880: Construct Binary Tree from String

本文介绍了一种从包含括号和整数的字符串中构建二叉树的方法。通过递归解析输入字符串,找到根节点、左子树和右子树,实现了字符串到二叉树的转换。
  1. Construct Binary Tree from String

You need to construct a binary tree from a string consisting of parenthesis and integers.

The whole input represents a binary tree. It contains an integer followed by zero, one or two pairs of parenthesis. The integer represents the root’s value and a pair of parenthesis contains a child binary tree with the same structure.

You always start to construct the left child node of the parent first if it exists.

Example
Example 1:

Input: “-4(2(3)(1))(6(5))”
Output: {-4,2,6,3,1,5}
Explanation:
The output is look like this:
-4
/
2 6
/ \ /
3 1 5
Example 2:

Input: “1(-1)”
Output: {1,-1}
Explanation:
The output is look like this:
1
/
-1
Notice
There will only be ‘(’, ‘)’, ‘-’ and ‘0’ ~ ‘9’ in the input string.
An empty tree is represented by “” instead of “()”.

解法1:递归。
每次把string分成root, leftStr, rightStr 3 部分。分界线就是当“(“和”)“匹配的那个地方。
注意:
1)startPos是第一个数字结束时后的下一个位置,即”(“的位置。pos会再往后移一个位置,即leftStr开始的第一个数字。然后开始找bracket Count=0的地方,此时pos指向”)"。所以leftStr开始于startPos + 1,终止于pos - 1,所以substr的长度为(pos - 1)-(startPos+1)+1=pos-startPos-1。
而rightStr的开始位置为pos+2,即下一个数字的位置。rightStr的终止位置为n - 2,即倒数第2个")"。所以rightStr的长度为(n-2)-(pos+2)+1=n-pos-3。
2) 以input="-4(2(3)(1))(6(5)(7))"为例,
第一轮:root = -4, leftStr=2(3)(1), rightStr=6(5)(7)
第二轮:root = 2, leftStr = 3, rightStr = 1
root = 6, leftStr = 5, rightStr = 7
3) str2tree的入口参数为string &s,注意这里有个引用,所以不能直接用rootNode->left = s.substr(…),因为s.substr()返回一个const。解决办法有两个:
方法1:如下面代码所示,定义临时变量leftStr, rightStr
方法2:定义一个helper(stinrg &s, int start, int end),这样string s永远不变,通过返回开始和终点位置来达到substr的效果。
方法3:用const_cast<>消掉const属性? 但不知道怎么操作。TBD。

/**
 * Definition of TreeNode:
 * class TreeNode {
 * public:
 *     int val;
 *     TreeNode *left, *right;
 *     TreeNode(int val) {
 *         this->val = val;
 *         this->left = this->right = NULL;
 *     }
 * }
 */

class Solution {
public:
    /**
     * @param s: a string
     * @return: a root of this tree
     */
    TreeNode * str2tree(string &s) {
        int n = s.size();
        if (n == 0) return NULL;
        int pos = 1;
        while(pos < s.size() && isdigit(s[pos])) pos++;

        TreeNode * rootNode = new TreeNode(stoi(s.substr(0, pos)));
        if (pos == n) return rootNode;
        //recursivly process the subtrees
        int bracketCount = 1;
        int startPos = pos; pos++;
        while(pos < n) {
            bracketCount += s[pos] == '(';
            bracketCount -= s[pos] == ')';
            if (bracketCount == 0) {
                string leftStr = s.substr(startPos + 1, pos - startPos - 1);
//                cout<<"leftStr="<<leftStr<<endl;
                rootNode->left = str2tree(leftStr);
                if (pos < n - 1) {
                    string rightStr = s.substr(pos + 2, n - pos - 3);
//                    cout<<"rightStr="<<rightStr<<endl;
                    rootNode->right = str2tree(rightStr);
                }
                break;
            }
            pos++;
        }
        return rootNode;
    }
};
请仔细阅读和分析下面函数 1. 保持原始的功能逻辑不变 2. 已经给定的结构体名字和元素不要更改 3. 程序内部错误和异常使用英文, 其他添加中文注释说明 4. 不使用 auto,使用显式 for 循环 5. 结构体采用32位定义 6. 不要使用小函数,使用一个函数进行部署 7. 实现全部功能,完整可编译的代码 8. 提高执行效率,降低计算复杂度 void __fastcall HDDMDevice::readarch_pb(HDDMDevice *this, const std::string *filePath, unsigned __int16 dword154) { google::protobuf::Message *v5; // rdx const std::string *v6; // rsi int v7; // ebp int v8; // r13d __int64 v9; // rbp const std::string **v10; // rax __int64 qword50_1; // rdx __int64 v12; // r12 std::string *qword50; // rdi const std::string *v14; // rsi std::string *qword68; // rdi __int64 qword68_1; // rax HDDMDevice *qword230; // r14 char *s2_1; // rbp HDDMDevice *p_char228; // r12 size_t n_2; // r15 int n0x7FFFFFFF_1; // eax _QWORD *s1; // rdi size_t n; // rdx size_t n_3; // r13 __int64 n0x7FFFFFFF; // r13 int p_qword90_2; // r15d HDDMBelDef *v27; // rbp HDDMBelDef **qword80; // rax bool v29; // zf __int64 qword80_1; // rax HDDMTileType *v31; // rdi char *qword290; // r14 _QWORD *s2_2; // rbp char *p_char288; // r12 size_t n_5; // r15 int n0x7FFFFFFF_3; // eax _QWORD *s1_1; // rdi size_t n_4; // r13 size_t n_1; // rdx __int64 n0x7FFFFFFF_2; // r13 HDDMTileType *v41; // r14 int v42; // r15d char *p_char2B8; // r15 int v44; // r13d HDDMSiteType *s2_4; // rbp HDDMSiteType **qword98; // rax __int64 qword98_1; // rax HDDMSiteType *s2_5; // rdi char *qword2C0; // r14 char *p_char2B8_1; // rbp int v51; // r15d char *p_char258; // r14 int v53; // r15d HDDMTileType *v54; // rbp HDDMTileType **qwordB0; // rax __int64 qwordB0_1; // rax HDDMTileType *v57; // rdi HDDMTileType **qword260; // r13 HDDMTileType **p_char258_1; // rbp __int64 p_char258_2; // rax __int64 insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_; // rax HDDMTileType **p_qword90a_1; // rdx __int64 v63; // rdi char *p_char2B8_2; // rax __int64 v65; // rax __int64 insert_hint_unique_pos; // rax char *p_char2B8_3; // rdx __int64 v68; // rdi __int64 p_char288_1; // rax __int64 p_char228_1; // rax unsigned int v71; // eax unsigned int v72; // eax __int64 v73; // r12 __int64 v74; // rbp __int64 qword1E0_1; // rax std::string *qword1E0; // rdi const std::string *v77; // rsi int v78; // [rsp+0h] [rbp-538h] int word28_1; // [rsp+8h] [rbp-530h] int word28_3; // [rsp+8h] [rbp-530h] _QWORD *v81; // [rsp+8h] [rbp-530h] void **p_s2; // [rsp+10h] [rbp-528h] std::string *v83; // [rsp+18h] [rbp-520h] std::string *s2_3; // [rsp+18h] [rbp-520h] int v85; // [rsp+18h] [rbp-520h] int dword154a; // [rsp+20h] [rbp-518h] int dword154b[2]; // [rsp+20h] [rbp-518h] int dword154c[2]; // [rsp+20h] [rbp-518h] int dword154d[2]; // [rsp+20h] [rbp-518h] unsigned int word28_2; // [rsp+28h] [rbp-510h] std::istream *v91; // [rsp+28h] [rbp-510h] std::istream *v92; // [rsp+28h] [rbp-510h] HUTMemWatcher *v93; // [rsp+30h] [rbp-508h] std::string *v94; // [rsp+38h] [rbp-500h] HDDMXng::TileType *v95; // [rsp+40h] [rbp-4F8h] int p_qword90; // [rsp+48h] [rbp-4F0h] HDDMTileType **p_qword90a; // [rsp+48h] [rbp-4F0h] HDDMTileType **p_qword60; // [rsp+50h] [rbp-4E8h] _QWORD *p_qwordA8; // [rsp+58h] [rbp-4E0h] int *v100; // [rsp+60h] [rbp-4D8h] _QWORD *p_qword78; // [rsp+68h] [rbp-4D0h] _QWORD *v102; // [rsp+70h] [rbp-4C8h] int v103; // [rsp+78h] [rbp-4C0h] HDDMXng::Architecture *v105; // [rsp+80h] [rbp-4B8h] HUTMemWatcher *v106; // [rsp+88h] [rbp-4B0h] char v107; // [rsp+9Eh] [rbp-49Ah] BYREF char v108; // [rsp+9Fh] [rbp-499h] BYREF char v109[16]; // [rsp+A0h] [rbp-498h] BYREF _QWORD v110[2]; // [rsp+B0h] [rbp-488h] BYREF _QWORD v111[2]; // [rsp+C0h] [rbp-478h] BYREF _QWORD v112[2]; // [rsp+D0h] [rbp-468h] BYREF _QWORD v113[2]; // [rsp+E0h] [rbp-458h] BYREF _QWORD v114[2]; // [rsp+F0h] [rbp-448h] BYREF _QWORD v115[2]; // [rsp+100h] [rbp-438h] BYREF int v116[2]; // [rsp+110h] [rbp-428h] BYREF _QWORD v117[2]; // [rsp+120h] [rbp-418h] BYREF _QWORD v118[2]; // [rsp+130h] [rbp-408h] BYREF HDDMTileType *v119[2]; // [rsp+140h] [rbp-3F8h] BYREF void *s2; // [rsp+150h] [rbp-3E8h] BYREF int v121; // [rsp+158h] [rbp-3E0h] BYREF __int64 v122; // [rsp+160h] [rbp-3D8h] int *v123; // [rsp+168h] [rbp-3D0h] int *v124; // [rsp+170h] [rbp-3C8h] __int64 v125; // [rsp+178h] [rbp-3C0h] _BYTE v126[176]; // [rsp+180h] [rbp-3B8h] BYREF _QWORD v127[22]; // [rsp+230h] [rbp-308h] BYREF _QWORD v128[4]; // [rsp+2E0h] [rbp-258h] BYREF int v129; // [rsp+300h] [rbp-238h] __int64 v130; // [rsp+330h] [rbp-208h] int v131; // [rsp+338h] [rbp-200h] __int64 v132; // [rsp+368h] [rbp-1D0h] unsigned int word28_4; // [rsp+370h] [rbp-1C8h] int word28; // [rsp+3A0h] [rbp-198h] int p_qword90_1; // [rsp+3A4h] [rbp-194h] int v136; // [rsp+3A8h] [rbp-190h] int v137; // [rsp+3ACh] [rbp-18Ch] int v138; // [rsp+3B0h] [rbp-188h] _QWORD v139[2]; // [rsp+3C0h] [rbp-178h] BYREF _BYTE v140[360]; // [rsp+3D0h] [rbp-168h] BYREF p_s2 = &s2; v102 = v139; std::string::string(v139, "", &s2); v94 = (std::string *)v119; v105 = (HDDMXng::Architecture *)v128; std::string::string(v128, "device:readFamilyXng", v119); v106 = (HUTMemWatcher *)v126; HUTMemWatcher::HUTMemWatcher((HUTMemWatcher *)v126, (const std::string *)v128, (const std::string *)v139); v93 = (HUTMemWatcher *)v127; std::string::_Rep::_M_dispose(v128[0] - 24LL, v127); std::string::_Rep::_M_dispose(v139[0] - 24LL, v128); sub_1F9A060(v139, *(_QWORD *)filePath, 4, 0); this->gap310[16] = dword154 > 1u; this->dword154 = dword154; std::istream::read((std::istream *)v140, v109, 8); HDDMXng::Architecture::Architecture((HDDMXng::Architecture *)v128); HDDMDevice::readMessage((HDDMDevice *)v140, (std::istream *)v128, v5); v6 = (const std::string *)v128[2]; this->word28 = word28; std::string::assign((std::string *)&this->qword30, v6); HDDMDevice::setupArchSpecific(this); v7 = v129; if ( v129 ) { this->byte1F0 = 1; std::vector<std::string>::reserve(&this->char1D8, v7); if ( v7 > 0 ) { v73 = 8LL * (unsigned int)(v7 - 1) + 8; v74 = 0; do { qword1E0 = (std::string *)this->qword1E0; v77 = *(const std::string **)(v128[3] + v74); if ( qword1E0 == (std::string *)this->qword1E8 ) { std::vector<std::string>::_M_emplace_back_aux<std::string const&>(&this->char1D8, v77); } else { if ( qword1E0 ) { std::string::string(qword1E0, v77); qword1E0_1 = this->qword1E0; } else { qword1E0_1 = 0; } this->qword1E0 = qword1E0_1 + 8; } v74 += 8; } while ( v74 != v73 ); } } v8 = v131; if ( v131 ) { std::vector<std::string>::reserve(&this->char48, v131); if ( v8 > 0 ) { v9 = 0; do { v12 = 8 * v9; qword50 = (std::string *)this->qword50; v10 = (const std::string **)(v130 + 8 * v9); v14 = *v10; if ( qword50 == (std::string *)this->qword58 ) { std::vector<std::string>::_M_emplace_back_aux<std::string const&>(&this->char48, v14); v10 = (const std::string **)(v130 + v12); } else { if ( qword50 ) { std::string::string(qword50, v14); v10 = (const std::string **)(v130 + v12); qword50_1 = this->qword50; } else { qword50_1 = 0; } this->qword50 = qword50_1 + 8; } *(_WORD *)std::map<std::string,unsigned short>::operator[](this->gap2E0, *v10) = v9++; } while ( v8 > (int)v9 ); } } p_qword60 = (HDDMTileType **)&this->qword60; word28_2 = word28_4; std::vector<std::string>::reserve(&this->qword60, word28_4); v83 = 0; word28_1 = 0; if ( word28_2 ) { do { std::string::string((std::string *)&s2, *(const std::string **)((char *)v83 + v132)); qword68 = (std::string *)this->qword68; if ( qword68 == (std::string *)this->qword70 ) { std::vector<std::string>::_M_emplace_back_aux<std::string const&>(p_qword60, &s2); } else { if ( qword68 ) { std::string::string(qword68, (const std::string *)&s2); qword68_1 = this->qword68; } else { qword68_1 = 0; } this->qword68 = qword68_1 + 8; } qword230 = (HDDMDevice *)this->qword230; if ( !qword230 ) { p_char228 = (HDDMDevice *)&this->char228; LABEL_97: v127[0] = &s2; p_char228_1 = std::_Rb_tree<std::string,std::pair<std::string const,unsigned short>,std::_Select1st<std::pair<std::string const,unsigned short>>,std::less<std::string>,std::allocator<std::pair<std::string const,unsigned short>>>::_M_emplace_hint_unique<std::piecewise_construct_t const&,std::tuple<std::string const&>,std::tuple<>>( this->gap220, p_char228, &unk_7B5DE75, v127, &v107); s2_1 = (char *)s2; p_char228 = (HDDMDevice *)p_char228_1; goto LABEL_30; } s2_1 = (char *)s2; p_char228 = (HDDMDevice *)&this->char228; n_2 = *((_QWORD *)s2 - 3); do { while ( 1 ) { s1 = *(_QWORD **)&qword230->dword20; n = n_2; n_3 = *(s1 - 3); if ( n_3 <= n_2 ) n = *(s1 - 3); n0x7FFFFFFF_1 = memcmp(s1, s2_1, n); if ( !n0x7FFFFFFF_1 ) break; LABEL_20: if ( n0x7FFFFFFF_1 < 0 ) goto LABEL_27; LABEL_21: p_char228 = qword230; qword230 = *(HDDMDevice **)&qword230->word10; if ( !qword230 ) goto LABEL_28; } n0x7FFFFFFF = n_3 - n_2; if ( n0x7FFFFFFF > 0x7FFFFFFF ) goto LABEL_21; if ( n0x7FFFFFFF >= (__int64)0xFFFFFFFF80000000LL ) { n0x7FFFFFFF_1 = n0x7FFFFFFF; goto LABEL_20; } LABEL_27: qword230 = *(HDDMDevice **)&qword230->dword18; } while ( qword230 ); LABEL_28: if ( &this->char228 == (char *)p_char228 || (int)std::string::compare((std::string *)&s2, (const std::string *)&p_char228->dword20) < 0 ) { goto LABEL_97; } LABEL_30: p_char228->word28 = word28_1; std::string::_Rep::_M_dispose(s2_1 - 24, v127); ++word28_1; v83 = (std::string *)((char *)v83 + 8); } while ( word28_1 != word28_2 ); } std::string::string(v111, "", v119); v95 = (HDDMXng::TileType *)v118; std::string::string(v110, "device::ArchXngBelDefs", v118); HUTMemWatcher::HUTMemWatcher((HUTMemWatcher *)v127, (const std::string *)v110, (const std::string *)v111); std::string::_Rep::_M_dispose(v110[0] - 24LL, &s2); std::string::_Rep::_M_dispose(v111[0] - 24LL, &s2); p_qword78 = &this->qword78; p_qword90_2 = p_qword90_1; p_qword90 = p_qword90_1; std::vector<HDDMBelDef *>::reserve(&this->qword78, p_qword90_1); if ( p_qword90_2 <= 0 ) goto LABEL_54; word28_3 = 0; LODWORD(p_qword60) = dword154; do { if ( (unsigned __int16)this->word28 <= word28_3 ) { v27 = (HDDMBelDef *)operator new(0x70u); HDDMBelDef::HDDMBelDef(v27); *((_BYTE *)v27 + 11) |= 0x20u; *(_QWORD *)v27 = off_96B67F0; } else { v27 = (HDDMBelDef *)operator new(0x70u); HDDMBelDef::HDDMBelDef(v27); *(_QWORD *)v27 = off_96B67B0; } qword80 = (HDDMBelDef **)this->qword80; v29 = qword80 == (HDDMBelDef **)this->qword88; v119[0] = v27; if ( v29 ) { std::vector<HDDMBelDef *>::_M_emplace_back_aux<HDDMBelDef * const&>(p_qword78, v119); v31 = v119[0]; } else { if ( qword80 ) { *qword80 = v27; qword80_1 = this->qword80; v31 = v119[0]; } else { v31 = v27; qword80_1 = 0; } this->qword80 = qword80_1 + 8; } *((_WORD *)v31 + 7) = (4 * (word28_3 & 0xFFF)) | *((_WORD *)v31 + 7) & 0xC003; (*(void (__fastcall **)(HDDMTileType *, _BYTE *, HDDMDevice *, _QWORD))(*(_QWORD *)v31 + 32LL))( v31, v140, this, dword154); qword290 = (char *)this->qword290; v91 = v119[0]; s2_3 = (HDDMTileType *)((char *)v119[0] + 16); if ( !qword290 ) { p_char288 = &this->char288; goto LABEL_95; } s2_2 = (_QWORD *)*((_QWORD *)v119[0] + 2); p_char288 = &this->char288; n_5 = *(s2_2 - 3); do { while ( 1 ) { s1_1 = (_QWORD *)*((_QWORD *)qword290 + 4); n_4 = *(s1_1 - 3); n_1 = n_4; if ( n_5 <= n_4 ) n_1 = n_5; n0x7FFFFFFF_3 = memcmp(s1_1, s2_2, n_1); if ( !n0x7FFFFFFF_3 ) break; LABEL_42: if ( n0x7FFFFFFF_3 < 0 ) goto LABEL_49; LABEL_43: p_char288 = qword290; qword290 = (char *)*((_QWORD *)qword290 + 2); if ( !qword290 ) goto LABEL_50; } n0x7FFFFFFF_2 = n_4 - n_5; if ( n0x7FFFFFFF_2 > 0x7FFFFFFF ) goto LABEL_43; if ( n0x7FFFFFFF_2 >= (__int64)0xFFFFFFFF80000000LL ) { n0x7FFFFFFF_3 = n0x7FFFFFFF_2; goto LABEL_42; } LABEL_49: qword290 = (char *)*((_QWORD *)qword290 + 3); } while ( qword290 ); LABEL_50: if ( &this->char288 != p_char288 && (int)std::string::compare(s2_3, (const std::string *)(p_char288 + 32)) >= 0 ) { v41 = v91; goto LABEL_53; } LABEL_95: s2 = s2_3; p_char288_1 = std::_Rb_tree<std::string,std::pair<std::string const,HDDMBelDef *>,std::_Select1st<std::pair<std::string const,HDDMBelDef *>>,std::less<std::string>,std::allocator<std::pair<std::string const,HDDMBelDef *>>>::_M_emplace_hint_unique<std::piecewise_construct_t const&,std::tuple<std::string const&>,std::tuple<>>( this->gap280, p_char288, &unk_7B5DE75, &s2, &v108); v41 = v119[0]; p_char288 = (char *)p_char288_1; LABEL_53: ++word28_3; *((_QWORD *)p_char288 + 5) = v41; } while ( p_qword90 != word28_3 ); LABEL_54: HUTMemWatcher::~HUTMemWatcher((HUTMemWatcher *)v127); std::string::string(v113, "", v119); std::string::string(v112, "device::ArchXngSiteTypes", v118); HUTMemWatcher::HUTMemWatcher((HUTMemWatcher *)v127, (const std::string *)v112, (const std::string *)v113); std::string::_Rep::_M_dispose(v112[0] - 24LL, &s2); std::string::_Rep::_M_dispose(v113[0] - 24LL, &s2); p_qword90a = (HDDMTileType **)&this->qword90; v42 = v136; LODWORD(v81) = v136; std::vector<HDDMSiteType *>::reserve(&this->qword90, v136); if ( v42 > 0 ) { p_char2B8 = &this->char2B8; v44 = 0; do { s2_4 = (HDDMSiteType *)operator new(0x170u); HDDMSiteType::HDDMSiteType(s2_4); qword98 = (HDDMSiteType **)this->qword98; v29 = qword98 == (HDDMSiteType **)this->qwordA0; s2 = s2_4; if ( v29 ) { std::vector<HDDMSiteType *>::_M_emplace_back_aux<HDDMSiteType * const&>(p_qword90a, &s2); s2_5 = (HDDMSiteType *)s2; } else { if ( qword98 ) { *qword98 = s2_4; qword98_1 = this->qword98; s2_5 = (HDDMSiteType *)s2; } else { s2_5 = s2_4; qword98_1 = 0; } this->qword98 = qword98_1 + 8; } *((_WORD *)s2_5 + 5) = ((_WORD)v44 << 6) | *((_WORD *)s2_5 + 5) & 0x3F; HDDMSiteType::readme_pb(s2_5, (std::istream *)v140, this); std::string::string((std::string *)v114, (const std::string *)((char *)s2 + 32)); qword2C0 = (char *)this->qword2C0; p_char2B8_1 = &this->char2B8; if ( !qword2C0 ) goto LABEL_89; do { while ( (int)std::string::compare((std::string *)(qword2C0 + 32), (const std::string *)v114) >= 0 ) { p_char2B8_1 = qword2C0; qword2C0 = (char *)*((_QWORD *)qword2C0 + 2); if ( !qword2C0 ) goto LABEL_65; } qword2C0 = (char *)*((_QWORD *)qword2C0 + 3); } while ( qword2C0 ); LABEL_65: if ( p_char2B8_1 == p_char2B8 || (int)std::string::compare((std::string *)v114, (const std::string *)(p_char2B8_1 + 32)) < 0 ) { LABEL_89: *(_QWORD *)dword154b = p_char2B8_1; p_char2B8_2 = (char *)operator new(0x30u); p_char2B8_1 = p_char2B8_2; if ( p_char2B8_2 ) { *(_DWORD *)p_char2B8_2 = 0; v65 = v114[0]; *((_QWORD *)p_char2B8_1 + 1) = 0; *((_QWORD *)p_char2B8_1 + 2) = 0; *((_QWORD *)p_char2B8_1 + 3) = 0; *((_QWORD *)p_char2B8_1 + 5) = 0; *((_QWORD *)p_char2B8_1 + 4) = v65; v114[0] = (char *)&std::string::_Rep::_S_empty_rep_storage + 24; } insert_hint_unique_pos = std::_Rb_tree<std::string,std::pair<std::string const,HDDMSiteType *>,std::_Select1st<std::pair<std::string const,HDDMSiteType *>>,std::less<std::string>,std::allocator<std::pair<std::string const,HDDMSiteType *>>>::_M_get_insert_hint_unique_pos( this->gap2B0, *(_QWORD *)dword154b, p_char2B8_1 + 32); if ( p_char2B8_3 ) { v68 = 1; if ( !insert_hint_unique_pos && p_char2B8 != p_char2B8_3 ) { *(_QWORD *)dword154d = p_char2B8_3; v72 = std::string::compare((std::string *)(p_char2B8_1 + 32), (const std::string *)(p_char2B8_3 + 32)); p_char2B8_3 = *(char **)dword154d; v68 = v72 >> 31; } std::_Rb_tree_insert_and_rebalance(v68, p_char2B8_1, p_char2B8_3, &this->char2B8); ++this->qword2D8; } else { *(_QWORD *)dword154c = insert_hint_unique_pos; std::string::_Rep::_M_dispose(*((_QWORD *)p_char2B8_1 + 4) - 24LL, v119); operator delete(p_char2B8_1); p_char2B8_1 = *(char **)dword154c; } } ++v44; *((_QWORD *)p_char2B8_1 + 5) = s2; std::string::_Rep::_M_dispose(v114[0] - 24LL, v119); } while ( (_DWORD)v81 != v44 ); } HUTMemWatcher::~HUTMemWatcher((HUTMemWatcher *)v127); v100 = v116; std::string::string(v116, "", v119); std::string::string(v115, "device::ArchXngTileTypes", v118); HUTMemWatcher::HUTMemWatcher((HUTMemWatcher *)v127, (const std::string *)v115, (const std::string *)v116); std::string::_Rep::_M_dispose(v115[0] - 24LL, &s2); std::string::_Rep::_M_dispose(*(_QWORD *)v116 - 24LL, &s2); v121 = 0; v122 = 0; v125 = 0; v123 = &v121; v124 = &v121; p_qwordA8 = &this->qwordA8; v51 = v137; v85 = v137; std::vector<HDDMTileType *>::reserve(&this->qwordA8, v137); if ( v51 > 0 ) { p_char258 = &this->char258; v53 = 0; dword154a = dword154; v92 = (std::istream *)v140; do { v54 = (HDDMTileType *)operator new(0x2A0u); HDDMTileType::HDDMTileType(v54); qwordB0 = (HDDMTileType **)this->qwordB0; v29 = qwordB0 == (HDDMTileType **)this->qwordB8; v119[0] = v54; if ( v29 ) { std::vector<HDDMTileType *>::_M_emplace_back_aux<HDDMTileType * const&>(p_qwordA8, v94); v57 = v119[0]; } else { if ( qwordB0 ) { *qwordB0 = v54; qwordB0_1 = this->qwordB0; v57 = v119[0]; } else { v57 = v54; qwordB0_1 = 0; } this->qwordB0 = qwordB0_1 + 8; } HDDMTileType::readme_pb( v57, v92, v78, (int)v81, (int)p_s2, v85, dword154a, (int)v92, (int)v93, (int)v94, v95, (int)p_qword90a, (int)p_qword60, p_qwordA8, (int)v100, p_qword78, (int)v102, v103, (int)v105, (__int64)v106); v81 = v117; HDDMTileType::getName((HDDMTileType *)v117); qword260 = (HDDMTileType **)this->qword260; p_char258_1 = (HDDMTileType **)&this->char258; if ( !qword260 ) goto LABEL_84; do { while ( (int)std::string::compare((std::string *)(qword260 + 4), (const std::string *)v117) >= 0 ) { p_char258_1 = qword260; qword260 = (HDDMTileType **)qword260[2]; if ( !qword260 ) goto LABEL_79; } qword260 = (HDDMTileType **)qword260[3]; } while ( qword260 ); LABEL_79: if ( p_char258_1 == (HDDMTileType **)p_char258 || (int)std::string::compare((std::string *)v117, (const std::string *)(p_char258_1 + 4)) < 0 ) { LABEL_84: p_qword60 = p_char258_1; p_qword90a = (HDDMTileType **)this->p_qword90; p_char258_2 = operator new(0x30u); p_char258_1 = (HDDMTileType **)p_char258_2; if ( p_char258_2 ) { *(_DWORD *)p_char258_2 = 0; *(_QWORD *)(p_char258_2 + 8) = 0; *(_QWORD *)(p_char258_2 + 16) = 0; *(_QWORD *)(p_char258_2 + 24) = 0; *(_QWORD *)(p_char258_2 + 32) = v117[0]; v117[0] = (char *)&std::string::_Rep::_S_empty_rep_storage + 24; *(_QWORD *)(p_char258_2 + 40) = 0; } insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_ = std::_Rb_tree<std::string,std::pair<std::string const,HDDMTileType *>,std::_Select1st<std::pair<std::string const,HDDMTileType *>>,std::less<std::string>,std::allocator<std::pair<std::string const,HDDMTileType *>>>::_M_get_insert_hint_unique_pos( p_qword90a, p_qword60, p_char258_2 + 32); if ( p_qword90a_1 ) { v63 = 1; if ( !insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_ && p_char258 != (char *)p_qword90a_1 ) { p_qword90a = p_qword90a_1; v71 = std::string::compare((std::string *)(p_char258_1 + 4), (const std::string *)(p_qword90a_1 + 4)); p_qword90a_1 = p_qword90a; v63 = v71 >> 31; } std::_Rb_tree_insert_and_rebalance(v63, p_char258_1, p_qword90a_1, &this->char258); ++this->qword278; } else { p_qword90a = (HDDMTileType **)insert_hint_unique_posESt23_Rb_tree_const_iteratorIS4_ERS1_; std::string::_Rep::_M_dispose((char *)p_char258_1[4] - 24, v95); operator delete(p_char258_1); p_char258_1 = p_qword90a; } } ++v53; p_char258_1[5] = v119[0]; std::string::_Rep::_M_dispose(v117[0] - 24LL, v95); } while ( v85 != v53 ); } std::_Rb_tree<std::string,std::string,std::_Identity<std::string>,std::less<std::string>,std::allocator<std::string>>::_M_erase( p_s2, v122); HUTMemWatcher::~HUTMemWatcher(v93); std::string::string(v94, "", v117); std::string::string(v95, "device::ArchXngFlags", v100); HUTMemWatcher::HUTMemWatcher(v93, v95, v94); std::string::_Rep::_M_dispose(v118[0] - 24LL, p_s2); std::string::_Rep::_M_dispose((char *)v119[0] - 24, p_s2); this->byte1F3 = v138 & 1; this->byte1F3 &= 1u; HUTMemWatcher::~HUTMemWatcher(v93); HDDMXng::Architecture::~Architecture(v105); sub_1F34A70(v102); HUTMemWatcher::~HUTMemWatcher(v106); }
09-29
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值