Logo Search packages:      
Sourcecode: lttoolbox version File versions  Download package

node.cc

/*
 * Copyright (C) 2005 Universitat d'Alacant / Universidad de Alicante
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 */
#include <lttoolbox/node.h>

00021 Node::Node()
{
}

00025 Node::~Node()
{
  destroy();
}

00030 Node::Node(Node const &n)
{
  copy(n);  
}

Node &
00036 Node::operator =(Node const &n)
{
  if(this != &n)
  {
    destroy();
    copy(n);
  }
  return *this; 
}

void
00047 Node::copy(Node const &n)
{
  transitions = n.transitions;  
}

void
00053 Node::destroy()
{
}

void
00058 Node::addTransition(int const i, int const o, Node * const d)
{
  Dest &aux = transitions[i];
  aux.size++;
  int *out_tag = new int[aux.size];
  Node **dest = new Node*[aux.size];
 
  for(int i = 0; i<aux.size-1; i++)
  {
    out_tag[i] = aux.out_tag[i];
    dest[i] = aux.dest[i];
  }
  
  if(aux.size > 1)
  {
    delete[] aux.out_tag;
    delete[] aux.dest;
  }

  out_tag[aux.size-1] = o;
  dest[aux.size-1] = d;
  aux.out_tag = out_tag;
  aux.dest = dest;
}

Generated by  Doxygen 1.6.0   Back to index