WSTester updated to work plus hopefully all the other changes that need to go into...
[jabaws.git] / binaries / src / ViennaRNA / RNAforester / src / ppforestsz.t.cpp
1 /*
2   Copyright by Matthias Hoechsmann (C) 2002
3   =====================================                                   
4   You may use, copy and distribute this file freely as long as you
5   - do not change the file,
6   - leave this copyright notice in the file,
7   - do not make any profit with the distribution of this file
8   - give credit where credit is due
9   You are not allowed to copy or distribute this file otherwise
10   The commercial usage and distribution of this file is prohibited
11   Please report bugs and suggestions to <mhoechsm@TechFak.Uni-Bielefeld.DE>
12 */
13
14 #ifndef _PPFORESTSZ_T_CPP_
15 #define _PPFORESTSZ_T_CPP_
16
17 #include <map>
18
19 #include "misc.h"
20 #include "ppforestsz.h"
21
22
23 // PPForest<T>
24
25 template <class L> 
26 PPForestSZ<L>::PPForestSZ(Uint nrOfNodes)
27 : m_size(nrOfNodes)
28 {
29   m_lml=new Uint[nrOfNodes];    
30   m_lb=new L[nrOfNodes];
31   m_keyroot=new bool[nrOfNodes];
32 }
33
34 template <class L>
35 PPForestSZ<L>::PPForestSZ(const PPForestSZ<L> &ppf)
36 {
37   m_size=ppf.size();    
38
39   m_lml=new Uint[ppf.size()];   
40   m_lb=new L[ppf.size()];
41   m_keyroot=new bool[ppf.size()];
42
43   memcpy(m_lml,ppf.m_lml,sizeof(Uint)*m_size);
44   memcpy(m_keyroot,ppf.m_keyroot,sizeof(bool)*m_size);
45
46   for(Uint i=0;i<m_size;i++)
47         m_lb[i]=ppf.m_lb[i];
48
49
50 template <class L> 
51 PPForestSZ<L>::~PPForestSZ()
52 {
53   DELETE_ARRAY(m_lml);
54   DELETE_ARRAY(m_lb);
55   DELETE_ARRAY(m_keyroot);
56 }
57
58 template <class L> 
59 void PPForestSZ<L>::calcKeyroots()
60 {
61   std::map<Uint,Uint> keyrootMap;
62
63   for(Uint i=0;i<m_size;i++)
64   {
65     m_keyroot[i]=false;
66     keyrootMap[lml(i)]=i;
67   }
68
69   std::map<Uint,Uint>::const_iterator it;
70   for(it=keyrootMap.begin();it!=keyrootMap.end();it++)
71   {
72         m_keyroot[it->second]=true;
73   }
74
75 }
76
77 #endif