00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef VCSN_ALGORITHMS_INTERNAL_SKELETON_HXX
00018 # define VCSN_ALGORITHMS_INTERNAL_SKELETON_HXX
00019
00020 # include <vaucanson/algorithms/internal/skeleton.hh>
00021
00022 namespace vcsn
00023 {
00024
00025
00026
00027
00028
00029 template<typename A, typename T>
00030 Skeleton<A, T>::Skeleton(const Element<A, T>& x) : a(x)
00031 {
00032
00033 typedef Element<A, T> automaton_t;
00034
00035 AUTOMATON_TYPES(automaton_t);
00036
00037 int i, j;
00038 std::list<htransition_t> out;
00039 std::map<series_set_elt_t, int> Lmap;
00040 std::map<hstate_t, int> Smap;
00041
00042 states.reserve(a.states().size());
00043 transitions.reserve(a.transitions().size());
00044 src_transitions.reserve(a.transitions().size());
00045 dst_transitions.reserve(a.transitions().size());
00046 transitions_labels.reserve(a.transitions().size());
00047
00048
00049
00050 std::list<int> dummy;
00051 delta_in.assign(a.states().size(), dummy);
00052 delta_out.assign(a.states().size(), dummy);
00053
00054
00055
00056
00057
00058 i = 0;
00059 for_all_states(q, a)
00060 {
00061 states.push_back(*q);
00062 Smap[*q] = i++;
00063
00064 if (a.is_initial(*q))
00065 I.push_front(i - 1);
00066 else
00067 if (a.is_final(*q))
00068 F.push_front(i - 1);
00069 }
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 i = 0;
00080
00081 j = 0;
00082 for_all_transitions(e, a)
00083 {
00084 transitions.push_back(*e);
00085 src_transitions.push_back(Smap[a.src_of(*e)]);
00086 dst_transitions.push_back(Smap[a.dst_of(*e)]);
00087
00088 if (Lmap.find(a.series_of(*e)) == Lmap.end())
00089 transitions_labels.push_back(Lmap[a.series_of(*e)] = i++);
00090 else
00091 transitions_labels.push_back(Lmap[a.series_of(*e)]);
00092 }
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 std::vector< std::list<int> > transitions_lex(i);
00113
00114 for (i = 0; i < static_cast<int>(a.transitions().size()); i++)
00115 transitions_lex[transitions_labels[i]].push_front(i);
00116
00117
00118
00119 for (i = 0; i < static_cast<int>(transitions_lex.capacity()); i++)
00120 for (std::list<int>::iterator it = transitions_lex[i].begin();
00121 it != transitions_lex[i].end(); it++)
00122 {
00123 delta_in[dst_transitions[*it]].push_back(*it);
00124 delta_out[src_transitions[*it]].push_back(*it);
00125 }
00126
00127 }
00128
00129 template<typename A, typename T>
00130 void Skeleton<A, T>::reserve_aux_states_int()
00131 {
00132 aux_states_int.reserve(a.states().size());
00133 }
00134
00135 template<typename A, typename T>
00136 void Skeleton<A, T>::reserve_aux_states_bool()
00137 {
00138 aux_states_bool.reserve(a.states().size());
00139 }
00140
00141 template<typename A, typename T>
00142 void Skeleton<A, T>::reserve_aux_states_generic()
00143 {
00144 aux_states_generic.reserve(a.states().size());
00145 }
00146
00147 template<typename A, typename T>
00148 void Skeleton<A, T>::reserve_aux_transitions_int()
00149 {
00150 aux_transitions_int.reserve(a.transitions().size());
00151 }
00152
00153 template<typename A, typename T>
00154 void Skeleton<A, T>::reserve_aux_transitions_bool()
00155 {
00156 aux_transitions_bool.reserve(a.transitions().size());
00157 }
00158
00159 template<typename A, typename T>
00160 void Skeleton<A, T>::reserve_aux_transitions_generic()
00161 {
00162 aux_transitions_generic.reserve(a.transitions().size());
00163 }
00164
00165 }
00166
00167 #endif // ! VCSN_ALGORITHMS_INTERNAL_SKELETON_HXX