1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "wukong_tree.h" 17 18 namespace OHOS { 19 namespace WuKong { RecursUpdateNodeIndex(const uint32_t offset)20bool WuKongTree::RecursUpdateNodeIndex(const uint32_t offset) 21 { 22 index_ = index_ + offset; 23 for (auto child : children_) { 24 child->RecursUpdateNodeIndex(offset); 25 } 26 return true; 27 } GetSubName(std::string name,uint32_t count)28uint64_t WuKongTree::GetSubName(std::string name, uint32_t count) 29 { 30 TRACK_LOG_STR("name %s", name.c_str()); 31 const uint8_t heightPosion = 8; 32 uint64_t subName = 0; 33 uint32_t nameSize = name.size(); 34 for (uint32_t index = count; index > 0; index--) { 35 if (index > nameSize) { 36 continue; 37 } 38 subName |= name[nameSize - index]; 39 if (index > 1) { 40 subName = subName << heightPosion; 41 } 42 } 43 return subName; 44 } 45 } // namespace WuKong 46 } // namespace OHOS