Vaucanson  1.4.1
support.hxx
1 // support.hxx: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 #ifndef VCSN_MISC_SUPPORT_HXX
18 # define VCSN_MISC_SUPPORT_HXX
19 
20 # include <vaucanson/misc/support.hh>
22 # include <vaucanson/automata/concept/handlers.hh>
23 
24 namespace vcsn
25 {
26  namespace misc
27  {
28 
29  /*----------.
30  | Support. |
31  `----------*/
32 
34  template <class U, class T>
35  Support<std::map<U, T> >::Support (const Support& s)
36  : m_ (s.m_)
37  {
38  }
39 
40  template <class U, class T>
41  Support<std::map<U, T> >::Support (const std::map<U, T>& m)
42  : m_ (m)
43  {
44  }
45 
46  template <class U, class T>
47  unsigned
48  Support<std::map<U, T> >::size () const
49  {
50  return m_.size ();
51  }
52 
53  template <class U, class T>
54  typename Support<std::map<U, T> >::iterator
55  Support<std::map<U, T> >::find (const U& k) const
56  {
57  return m_.find (k);
58  }
59 
60  template <class U, class T>
61  bool
62  Support<std::map<U, T> >::empty () const
63  {
64  return m_.empty ();
65  }
66 
67  template <class U, class T>
68  typename Support<std::map<U, T> >::iterator
69  Support<std::map<U, T> >::begin () const
70  {
71  return iterator (m_.begin ());
72  }
73 
74  template <class U, class T>
75  typename Support<std::map<U, T> >::iterator
76  Support<std::map<U, T> >::end () const
77  {
78  return iterator (m_.end ());
79  }
80 
81  template <class U, class T>
82  U
83  Support< std::map<U, T> >::back () const
84  {
85  return *max_element (begin (), end ());
86  }
87 
89  template <class U>
90  Support<std::set<U> >::Support (const Support& s)
91  : m_ (s.m_)
92  {
93  }
94 
95  template <class U>
96  Support<std::set<U> >::Support (const std::set<U>& m)
97  : m_ (m)
98  {
99  }
100 
101  template <class U>
102  unsigned
103  Support<std::set<U> >::size () const
104  {
105  return m_.size ();
106  }
107 
108  template <class U>
109  typename Support<std::set<U> >::iterator
110  Support<std::set<U> >::find (const U& k) const
111  {
112  return m_.find (k);
113  }
114 
115  template <class U>
116  bool
117  Support<std::set<U> >::empty () const
118  {
119  return m_.empty ();
120  }
121 
122  template <class U>
123  typename Support<std::set<U> >::iterator
124  Support<std::set<U> >::begin () const
125  {
126  return iterator (m_.begin ());
127  }
128 
129  template <class U>
130  typename Support<std::set<U> >::iterator
131  Support<std::set<U> >::end () const
132  {
133  return iterator (m_.end ());
134  }
135 
136  template <class U>
137  U
138  Support< std::set<U> >::back () const
139  {
140  return *max_element (begin (), end ());
141  }
142 
143  /*------------------.
144  | SupportIterator. |
145  `------------------*/
146 
147  template <class C>
148  SupportIterator<C>::SupportIterator (map_iterator mp)
149  : i (mp)
150  {}
151 
152  template <class C>
153  typename SupportIterator<C>::key_type
155  {
156  return i->first;
157  }
158 
159  template <class C>
160  SupportIterator<C>& SupportIterator<C>::operator++ ()
161  {
162  ++i;
163  return *this;
164  }
165 
166  template <class C>
167  SupportIterator<C> SupportIterator<C>::operator++ (int)
168  {
169  SupportIterator<C> tmp = *this;
170  ++i;
171  return tmp;
172  }
173 
174  template <class C>
175  bool
176  SupportIterator<C>::operator!= (const SupportIterator& o) const
177  {
178  return o.i != i;
179  }
180 
181  template <class C>
182  bool
183  SupportIterator<C>::operator== (const SupportIterator& o) const
184  {
185  return ! (*this != o);
186  }
187 
188  /*------------------.
189  | SupportIterator. |
190  `------------------*/
191 
192  template <class U>
193  SupportIterator<std::set<U> >::SupportIterator (iterator mp)
194  : i (mp)
195  {}
196 
197  template <class U>
198  typename SupportIterator<std::set<U> >::value_t
199  SupportIterator<std::set<U> >::operator* () const
200  {
201  return *i;
202  }
203 
204  template <class U>
205  SupportIterator<std::set<U> >&
206  SupportIterator<std::set<U> >::operator++ ()
207  {
208  ++i;
209  return *this;
210  }
211 
212  template <class U>
213  SupportIterator<std::set<U> >
214  SupportIterator<std::set<U> >::operator++ (int)
215  {
216  SupportIterator<std::set<U> > tmp = *this;
217  ++i;
218  return tmp;
219  }
220 
221  template <class U>
222  bool
223  SupportIterator<std::set<U> >::operator!= (const SupportIterator& o) const
224  {
225  return o.i != i;
226  }
227 
228  template <class U>
229  bool
230  SupportIterator<std::set<U> >::operator== (const SupportIterator& o) const
231  {
232  return ! (*this != o);
233  }
234 
235  } // misc
236 } // vcsn
237 
238 #endif // ! VCSN_MISC_SUPPORT_HXX