Esempio n. 1
0
Tree.prototype.getNodesByLevel = function(level) {
  var newNodeList = new NodeList();
  for(var i = 0; this.nodeList[i] != null; i++) {
    if(this.nodeList[i].level == level) newNodeList.addNode(this.nodeList[i]);
  }
  return newNodeList;
};
Esempio n. 2
0
 var addLeaves = function(candidate) {
   if(candidate.toNodeList.length === 0) {
     leaves.addNode(candidate);
   } else {
     candidate.toNodeList.forEach(addLeaves);
   }
 };
Esempio n. 3
0
 var addLeaves = function(node) {
   if(node.toNodeList.length === 0) {
     leaves.addNode(node);
     return;
   }
   node.toNodeList.forEach(addLeaves);
 };
Esempio n. 4
0
Tree.prototype.getLeaves = function(node) {
  var leaves = new NodeList();
  if(node) {
    if(node.toNodeList.length === 0) {
      leaves.addNode(node);
      return leaves;
    }
    var addLeaves = function(candidate) {
      if(candidate.toNodeList.length === 0) {
        leaves.addNode(candidate);
      } else {
        candidate.toNodeList.forEach(addLeaves);
      }
    };
    node.toNodeList.forEach(addLeaves);
  } else {
    this.nodeList.forEach(function(candidate) {
      if(candidate.toNodeList.length === 0) leaves.addNode(candidate);
    });
  }
  return leaves;
};
Esempio n. 5
0
 this.nodeList.forEach(function(candidate) {
   if(candidate.toNodeList.length === 0) leaves.addNode(candidate);
 });