<commit_before>/**
 * CCopasiNode class.
 * The class CCopasiNode is describes a node of the CCopasiTree.
 *
 * Created for Copasi by <NAME> 2003
 */

#include "copasi.h"
#include "CCopasiNode.h"

CCopasiNode::CCopasiNode(CCopasiNode * pParent):
    mpParent(pParent),
    mpChild(NULL),
    mpSibbling(NULL)
{}

CCopasiNode::CCopasiNode(const CCopasiNode & src):
    mpParent(src.mpParent),
    mpChild(src.mpChild),
    mpSibbling(src.mpSibbling)
{}

CCopasiNode::~CCopasiNode()
{
  while (mpChild) delete mpChild;

  if (mpParent)
    mpParent->removeChild(this);
  std::cout << "deleting: " << this << std::endl;
}

bool CCopasiNode::setParent(CCopasiNode * pParent)
{
  mpParent = pParent;
  return true;
}

CCopasiNode * CCopasiNode::getParent() {return mpParent;}

bool CCopasiNode::addChild(CCopasiNode * pChild,
                           CCopasiNode * pAfter)
{
  if (!pChild) return false;           // Nothing to insert.

  if (pAfter == this)
    {
      pChild->setSibbling(mpChild);
      mpChild = NULL;
    }

  if (mpChild)
    return mpChild->addSibbling(pChild, pAfter);

  mpChild = pChild;
  mpChild->setParent(this);

  return true;
}

bool CCopasiNode::removeChild(CCopasiNode * pChild)
{
  if (!pChild) return false;           // Nothing to remove.

  if (mpChild != pChild)
    return mpChild->removeSibbling(pChild);

  mpChild = mpChild->getSibbling();
  return true;
}

bool CCopasiNode::setChild(CCopasiNode * pChild)
{
  mpChild = pChild;
  return true;
}

CCopasiNode * CCopasiNode::getChild() {return mpChild;}

bool CCopasiNode::addSibbling(CCopasiNode * pSibbling,
                              CCopasiNode * pAfter)
{
  if (!pSibbling) return false;        // Nothing to insert.

  if (this == pAfter)
    {
      pSibbling->setParent(mpParent);
      pSibbling->setSibbling(mpSibbling);
      mpSibbling = pSibbling;
      return true;
    }

  CCopasiNode * pTmp = this;
  while (pTmp != pAfter && pTmp->getSibbling())
    pTmp = pTmp->getSibbling();

  if (pTmp == pAfter || pAfter == NULL)
    return pTmp->addSibbling(pSibbling, pTmp);
  else
    return false;                      // Insertion point no found.
}

bool CCopasiNode::removeSibbling(CCopasiNode * pSibbling)
{
  if (!pSibbling) return false;        // Nothing to remove.

  if (this == pSibbling)
    {
      if (mpParent)
        mpParent->removeChild(pSibbling);
      else
        return false;                  // Root can not be removed
    }

  CCopasiNode * pTmp = this;
  CCopasiNode * pTmpSibbling = this->mpSibbling;

  while (pTmpSibbling != pSibbling && pTmpSibbling != NULL)
    {
      pTmp = pTmpSibbling;
      pTmpSibbling = pTmpSibbling->getSibbling();
    }

  if (pTmpSibbling)
    return pTmp->setSibbling(pSibbling->getSibbling());
  else
    return false;                      // We did not find pSibbling.
}

bool CCopasiNode::setSibbling(CCopasiNode * pSibbling)
{
  mpSibbling = pSibbling;
  return true;
}

CCopasiNode * CCopasiNode::getSibbling() {return mpSibbling;}
<commit_msg>Removed outpu statement for debugging.<commit_after>/**
 * CCopasiNode class.
 * The class CCopasiNode is describes a node of the CCopasiTree.
 *
 * Created for Copasi by <NAME> 2003
 */

#include "copasi.h"
#include "CCopasiNode.h"

CCopasiNode::CCopasiNode(CCopasiNode * pParent):
    mpParent(pParent),
    mpChild(NULL),
    mpSibbling(NULL)
{}

CCopasiNode::CCopasiNode(const CCopasiNode & src):
    mpParent(src.mpParent),
    mpChild(src.mpChild),
    mpSibbling(src.mpSibbling)
{}

CCopasiNode::~CCopasiNode()
{
  while (mpChild) delete mpChild;

  if (mpParent)
    mpParent->removeChild(this);
}

bool CCopasiNode::setParent(CCopasiNode * pParent)
{
  mpParent = pParent;
  return true;
}

CCopasiNode * CCopasiNode::getParent() {return mpParent;}

bool CCopasiNode::addChild(CCopasiNode * pChild,
                           CCopasiNode * pAfter)
{
  if (!pChild) return false;           // Nothing to insert.

  if (pAfter == this)
    {
      pChild->setSibbling(mpChild);
      mpChild = NULL;
    }

  if (mpChild)
    return mpChild->addSibbling(pChild, pAfter);

  mpChild = pChild;
  mpChild->setParent(this);

  return true;
}

bool CCopasiNode::removeChild(CCopasiNode * pChild)
{
  if (!pChild) return false;           // Nothing to remove.

  if (mpChild != pChild)
    return mpChild->removeSibbling(pChild);

  mpChild = mpChild->getSibbling();
  return true;
}

bool CCopasiNode::setChild(CCopasiNode * pChild)
{
  mpChild = pChild;
  return true;
}

CCopasiNode * CCopasiNode::getChild() {return mpChild;}

bool CCopasiNode::addSibbling(CCopasiNode * pSibbling,
                              CCopasiNode * pAfter)
{
  if (!pSibbling) return false;        // Nothing to insert.

  if (this == pAfter)
    {
      pSibbling->setParent(mpParent);
      pSibbling->setSibbling(mpSibbling);
      mpSibbling = pSibbling;
      return true;
    }

  CCopasiNode * pTmp = this;
  while (pTmp != pAfter && pTmp->getSibbling())
    pTmp = pTmp->getSibbling();

  if (pTmp == pAfter || pAfter == NULL)
    return pTmp->addSibbling(pSibbling, pTmp);
  else
    return false;                      // Insertion point no found.
}

bool CCopasiNode::removeSibbling(CCopasiNode * pSibbling)
{
  if (!pSibbling) return false;        // Nothing to remove.

  if (this == pSibbling)
    {
      if (mpParent)
        mpParent->removeChild(pSibbling);
      else
        return false;                  // Root can not be removed
    }

  CCopasiNode * pTmp = this;
  CCopasiNode * pTmpSibbling = this->mpSibbling;

  while (pTmpSibbling != pSibbling && pTmpSibbling != NULL)
    {
      pTmp = pTmpSibbling;
      pTmpSibbling = pTmpSibbling->getSibbling();
    }

  if (pTmpSibbling)
    return pTmp->setSibbling(pSibbling->getSibbling());
  else
    return false;                      // We did not find pSibbling.
}

bool CCopasiNode::setSibbling(CCopasiNode * pSibbling)
{
  mpSibbling = pSibbling;
  return true;
}

CCopasiNode * CCopasiNode::getSibbling() {return mpSibbling;}

{'fraction_non_alphanumeric': 0.11848025329111815, 'fraction_numerical': 0.0013331111481419764, 'mean_word_length': 2.9486842105263156, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 37, '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': '3808199', 'n_tokens_mistral': 2227, 'n_tokens_neox': 2185, 'n_words': 444}