Skip to content

Instantly share code, notes, and snippets.

@swapnilshrikhande
Created August 12, 2016 15:38
Show Gist options
  • Save swapnilshrikhande/af07c4e13da053e6022a9f388709b95c to your computer and use it in GitHub Desktop.
Save swapnilshrikhande/af07c4e13da053e6022a9f388709b95c to your computer and use it in GitHub Desktop.
Parse Tree
class Node{
Id value;
List<Node> children;
{
children = new List<Node>();
}
}
parseTree( Map<String,List<Id>> treeMap,String parentId){
List<Id> childrenNode childrenNode = treeMap.get(parentId);
Node parenNode = new Node();
parenNode.value = parentId;
for(Id childId:childrenNode){
parenNode.children.add( parseTree(treeMap,childId) );
}
return parenNode;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment