Exemplo n.º 1
0
// Compares all pairs of children, finding and removing duplicate BTERMs
void noDuplicateNodes( ChildList &l )
{
  //This is shallow!
  //ONLY SAFE WHEN DELETING BTERMS for now (note is prev to Aug 2009)

  // BK Aug 21, 2009: seems to be deep compare and deep delete
  ChildList dups;
  CLIter n1 = l.begin();
  CLIter n2 = ++(l.begin());
  CLIter end = l.end();
  while( n1 != end ){
    //assert((*n1)->t == BTERM);
    while( n2 != end ){
      //Comparison
      if( (*n1)->equals(*n2) ){
	dups.push_back(*n2);
      }
      n2++;
    }
    n1++;
    n2 = n1;
    n2++;
  }

  dups.sort();
  dups.unique();
  
  for(n2 = dups.begin(); n2 != dups.end(); n2++){
    for(n1 = l.begin(); n1 != l.end(); n1++){
      if(*n1 == *n2){
	(*n1)->destroyTree();
	l.erase(n1);
	break;
      }
    }
  }
  dups.clear();
}
Exemplo n.º 2
0
void Window::rebuildChildrenList()
{
	mChildren.clear();
	EnumChildWindows(mHWND, sCollectChildrenCallback, reinterpret_cast<LPARAM>(this));
}
Exemplo n.º 3
0
///////////////////////
// Post-condition (memory management):
//   Always return a pointer to this node.
//
SymNode* SymNode::toDNF(){
  debout("toDNF");
  CLIter iter,end,dup;
  if( t == BTERM || t == FTYPE || t == ETYPE || t == TTYPE){
    debout("p:isLiteral");
    return this;
  }
  //Ensure all of the clauses are in DNF
  iter = children.begin();
  end = children.end();

  ChildList *newList = new ChildList();
  while( iter != end ){
    debout("loop:p1");
    SymNode *returned;
    returned = (*iter)->toDNF();
    if( returned != NULL ){
      newList->push_back(*iter);
    }
    iter++;
  }
  debout("p2");
  this->children.swap( *newList );
  newList->clear();
  delete newList;

  deboutnn( "toDNF: children.size(): ");
  debout(children.size() );

  //All chilren are false if they have been pruned by DNF  
  if( children.empty() ){
    debout("p:shouldn\'t be happening");
    assert(0);
    this->destroyTree();
    return new SymNode(FTYPE,-1);
  }
  debout("p3");
  if( t == SOR ){
    debout("p3.1");
    
    //Then we are fine because all of the clauses are in DNF
    this->removeParens();
    //noDuplicateNodes(this->children);
    return this;
  } else if( t == SAND ){
    debout("p4");
    //We need to distribute "and" over the clauses that are in DNF already
    //It's exponential time!!!!!!!!!
    //TEMP MARK

    // BK: this never happens, because distribute has not line: return 0;
    if( this->distribute() ==  0 ){ 
      assert(0); //Shouldn't be happening
      debout("p6 this->distribute() == 0");
      //The children are false according to our restrictions and so this is false and therefor useless
      this->destroyTree();  // BK fixed possible leak
      delete this;
      return new SymNode(FTYPE,-1);
    }
    debout("p5");
    //noDuplicateNodes(this->children);
    return this;
  }else{
    //raise exception "not" is not implemented
    assert(0);
  }
  return NULL;
}