<commit_before>// Begin CVS Header
//   $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/compareExpressions/CNormalLogical.cpp,v $
//   $Revision: 1.6 $
//   $Name:  $
//   $Author: gauges $
//   $Date: 2007/08/13 21:04:41 $
// End CVS Header

// Copyright (C) 2007 by <NAME>, Virginia Tech Intellectual
// Properties, Inc. and EML Research, gGmbH.
// All rights reserved.

#include "CNormalLogical.h"
#include "CNormalChoiceLogical.h"
#include "CNormalLogicalItem.h"
#include <sstream>
#include <assert.h>

CNormalLogical::CNormalLogical(): CNormalBase(), mNot(false)
{}

CNormalLogical::CNormalLogical(const CNormalLogical& src): CNormalBase(src), mNot(src.mNot)
{
  ChoiceSetOfSets::const_iterator it = this->mChoices.begin(), endit = this->mChoices.end();
  while (it != endit)
    {
      ChoiceSet::const_iterator it4 = it->first.begin(), endit4 = it->first.end();
      while (it4 != endit4)
        {
          delete it4->first;
          ++it4;
        }
      ++it;
    }
  this->mChoices.clear();
  it = src.mChoices.begin();
  endit = src.mChoices.end();
  while (it != endit)
    {
      ChoiceSet tmp;
      ChoiceSet::const_iterator it4 = (*it).first.begin(), endit4 = (*it).first.end();
      while (it4 != endit4)
        {
          tmp.insert(std::make_pair(it4->first->copy(), it4->second));
          ++it4;
        }
      this->mChoices.insert(std::make_pair(tmp, it->second));
      ++it;
    }
  ItemSetOfSets::const_iterator it2 = this->mAndSets.begin(), endit2 = this->mAndSets.end();
  while (it2 != endit2)
    {
      ItemSet::const_iterator it3 = it2->first.begin(), endit3 = it2->first.end();
      while (it3 != endit3)
        {
          delete it3->first;
          ++it3;
        }
      ++it2;
    }
  this->mAndSets.clear();
  it2 = src.mAndSets.begin();
  endit2 = src.mAndSets.end();
  bool flag = false;
  CNormalLogicalItem* pTmpItem = NULL;
  while (it2 != endit2)
    {
      ItemSet tmp;
      ItemSet::const_iterator it3 = it2->first.begin(), endit3 = it2->first.end();
      while (it3 != endit3)
        {
          flag = it3->second;
          pTmpItem = it3->first->copy();
          //std::cout << "1. item: " << pTmpItem->toString() << std::endl;
          tmp.insert(std::make_pair(pTmpItem, flag));
          ++it3;
        }
      flag = it2->second;
      this->mAndSets.insert(std::make_pair(tmp, flag));
      ++it2;
    }
}

CNormalLogical& CNormalLogical::operator=(const CNormalLogical& src)
{
  this->mNot = src.mNot;
  ChoiceSetOfSets::const_iterator it = this->mChoices.begin(), endit = this->mChoices.end();
  while (it != endit)
    {
      ChoiceSet::const_iterator it4 = it->first.begin(), endit4 = it->first.end();
      while (it4 != endit4)
        {
          delete it4->first;
          ++it4;
        }
      ++it;
    }
  this->mChoices.clear();
  it = src.mChoices.begin();
  endit = src.mChoices.end();
  while (it != endit)
    {
      ChoiceSet tmp;
      ChoiceSet::const_iterator it4 = it->first.begin(), endit4 = it->first.end();
      while (it4 != endit4)
        {
          tmp.insert(std::make_pair(new CNormalChoiceLogical(*it4->first), it4->second));
          ++it4;
        }
      this->mChoices.insert(std::make_pair(tmp, it->second));
      ++it;
    }
  ItemSetOfSets::const_iterator it2 = this->mAndSets.begin(), endit2 = this->mAndSets.end();
  while (it2 != endit2)
    {
      ItemSet::const_iterator it3 = it2->first.begin(), endit3 = it2->first.end();
      while (it3 != endit3)
        {
          delete it3->first;
          ++it3;
        }
      ++it2;
    }
  this->mAndSets.clear();
  it2 = src.mAndSets.begin();
  endit2 = src.mAndSets.end();
  while (it2 != endit2)
    {
      ItemSet tmp;
      ItemSet::const_iterator it3 = it2->first.begin(), endit3 = it2->first.end();
      while (it3 != endit3)
        {
          tmp.insert(std::make_pair(new CNormalLogicalItem(*it3->first), it3->second));
          ++it3;
        }
      this->mAndSets.insert(std::make_pair(tmp, it2->second));
      ++it2;
    }
  return *this;
}

CNormalLogical::~CNormalLogical()
{
  ChoiceSetOfSets::const_iterator it = this->mChoices.begin(), endit = this->mChoices.end();
  while (it != endit)
    {
      ChoiceSet::const_iterator it4 = it->first.begin(), endit4 = it->first.end();
      while (it4 != endit4)
        {
          delete it4->first;
          ++it4;
        }
      ++it;
    }
  this->mChoices.clear();
  ItemSetOfSets::const_iterator it2 = this->mAndSets.begin(), endit2 = this->mAndSets.end();
  while (it2 != endit2)
    {
      ItemSet::const_iterator it3 = it2->first.begin(), endit3 = it2->first.end();
      while (it3 != endit3)
        {
          delete it3->first;
          ++it3;
        }
      ++it2;
    }
  this->mAndSets.clear();
}

CNormalLogical* CNormalLogical::copy() const
  {
    return new CNormalLogical(*this);
  }<commit_msg>Rewrote the copy constructor and assignment operator of CNormalLogical so that is now uses the new template utility functions to delete and copy sets of sets. Hopefully this gets rid of the misterious bug.<commit_after>// Begin CVS Header
//   $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/compareExpressions/CNormalLogical.cpp,v $
//   $Revision: 1.7 $
//   $Name:  $
//   $Author: gauges $
//   $Date: 2007/08/14 13:54:01 $
// End CVS Header

// Copyright (C) 2007 by <NAME>, Virginia Tech Intellectual
// Properties, Inc. and EML Research, gGmbH.
// All rights reserved.

#include "CNormalLogical.h"
#include "CNormalChoiceLogical.h"
#include "CNormalLogicalItem.h"
#include <sstream>
#include <assert.h>

CNormalLogical::CNormalLogical(): CNormalBase(), mNot(false)
{}

CNormalLogical::CNormalLogical(const CNormalLogical& src): CNormalBase(src), mNot(src.mNot)
{
  cleanSetOfSets(this->mChoices);
  copySetOfSets(src.mChoices, this->mChoices);
  cleanSetOfSets(this->mAndSets);
  copySetOfSets(src.mAndSets, this->mAndSets);
}

CNormalLogical& CNormalLogical::operator=(const CNormalLogical& src)
{
  this->mNot = src.mNot;
  cleanSetOfSets(this->mChoices);
  copySetOfSets(src.mChoices, this->mChoices);
  cleanSetOfSets(this->mAndSets);
  copySetOfSets(src.mAndSets, this->mAndSets);
  return *this;
}

CNormalLogical::~CNormalLogical()
{
  cleanSetOfSets(this->mChoices);
  cleanSetOfSets(this->mAndSets);
}

CNormalLogical* CNormalLogical::copy() const
  {
    return new CNormalLogical(*this);
  }
{'fraction_non_alphanumeric': 0.16283794342866073, 'fraction_numerical': 0.022190967338646665, 'mean_word_length': 2.87409200968523, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 82, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7381615', 'n_tokens_mistral': 2370, 'n_tokens_neox': 2312, 'n_words': 418}