TreeNode* _deserialize(vector<string>& strs) {
     static int index = 0;
     if (index >= strs.size() || strs[index] == "#") {
         index++;
         return NULL;
     }
         
     TreeNode* root = new TreeNode(atoi(strs[index++].c_str()));
     root->left = _deserialize(strs);
     root->right = _deserialize(strs);
     return root;
 }
Esempio n. 2
0
 TreeNode* _deserialize(string &data, int &index)
 {
     if(index == data.length())
         return NULL;
     else if(data[index] == '#')
     {
         index += 2;
         return NULL;
     }
     else
     {
         TreeNode *tmp = new TreeNode(parse_next_val(data, index));
         tmp->left = _deserialize(data, index);
         tmp->right = _deserialize(data, index);
         return tmp;
     }
 }
DataTypeInformation&
DataTypeInformation::deserialize(InformationInterface::Format& data) {
  _deserialize(data);
  return *this;
}
DataTypeInformation::DataTypeInformation(InformationInterface::Format& data) {
  _deserialize(data);
}
Esempio n. 5
0
 // Decodes your encoded data to tree.
 TreeNode* deserialize(string data) {
     int index = 0;
     return _deserialize(data, index);
 }
 /**
  * This method will be invoked second, the argument data is what exactly
  * you serialized at method "serialize", that means the data is not given by
  * system, it's given by your own serialize method. So the format of data is
  * designed by yourself, and deserialize it here as you serialize it in 
  * "serialize" method.
  */
 TreeNode *deserialize(string data) {
     vector<string> strs = split(data, ',');
     return _deserialize(strs);
 }