Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

range_set< T > Class Template Reference

#include <range.hpp>

List of all members.

Public Types

typedef TSet::value_type value_type
typedef TSet::const_reference reference
typedef TSet::const_reference const_reference
typedef TSet::const_iterator iterator
typedef TSet::const_iterator const_iterator
typedef TSet::size_type size_type
typedef TSet::difference_type difference_type
typedef TSet::const_reverse_iterator reverse_iterator
typedef TSet::const_reverse_iterator const_reverse_iterator

Public Methods

const_iterator begin () const
const_iterator end () const
const_reverse_iterator rbegin () const
const_reverse_iterator rend () const
bool empty () const
size_type size () const
size_type max_size () const
bool insert (const value_type &)
void erase (iterator i)
void erase (const value_type &)
void erase (iterator a, iterator b)
void swap (range_set< T > &rhs)

Private Types

typedef std::vector< range<
T > > 
TSet

Private Attributes

TSet set

template<class T>
class range_set< T >


Member Typedef Documentation

template<class T>
typedef TSet::const_iterator range_set< T >::const_iterator
 

Definition at line 63 of file range.hpp.

Referenced by range_set< long >::begin(), and range_set< long >::end().

template<class T>
typedef TSet::const_reference range_set< T >::const_reference
 

Definition at line 61 of file range.hpp.

template<class T>
typedef TSet::const_reverse_iterator range_set< T >::const_reverse_iterator
 

Definition at line 67 of file range.hpp.

Referenced by range_set< long >::rbegin(), and range_set< long >::rend().

template<class T>
typedef TSet::difference_type range_set< T >::difference_type
 

Definition at line 65 of file range.hpp.

template<class T>
typedef TSet::const_iterator range_set< T >::iterator
 

Definition at line 62 of file range.hpp.

Referenced by range_set< long >::erase().

template<class T>
typedef TSet::const_reference range_set< T >::reference
 

Definition at line 60 of file range.hpp.

template<class T>
typedef TSet::const_reverse_iterator range_set< T >::reverse_iterator
 

Definition at line 66 of file range.hpp.

template<class T>
typedef TSet::size_type range_set< T >::size_type
 

Definition at line 64 of file range.hpp.

Referenced by range_set< long >::max_size(), and range_set< long >::size().

template<class T>
typedef std::vector< range<T> > range_set< T >::TSet [private]
 

Definition at line 50 of file range.hpp.

template<class T>
typedef TSet::value_type range_set< T >::value_type
 

Definition at line 59 of file range.hpp.

Referenced by range_set< T >::erase().


Member Function Documentation

template<class T>
const_iterator range_set< T >::begin   const [inline]
 

Definition at line 71 of file range.hpp.

Referenced by CodeParser::CheckCodeRecursively(), range_set< T >::erase(), and CodeParser::ExcludeFileRange().

00071 { return set.begin(); }

template<class T>
bool range_set< T >::empty   const [inline]
 

Definition at line 77 of file range.hpp.

00077 { return set.empty(); }

template<class T>
const_iterator range_set< T >::end   const [inline]
 

Definition at line 72 of file range.hpp.

Referenced by CodeParser::CheckCodeRecursively(), CodeParser::ExcludeFileRange(), and range_set< T >::insert().

00072 { return set.end(); }

template<class T>
void range_set< T >::erase iterator    a,
iterator    b
[inline]
 

Definition at line 88 of file range.hpp.

00089   { set.erase(const_cast<typename TSet::iterator>(a),const_cast<typename TSet::iterator>(b)); }

template<class T>
void range_set< T >::erase const value_type  
 

Definition at line 172 of file range.hpp.

References range_set< T >::begin(), range_set< T >::set, and range_set< T >::value_type.

00173 {
00174   // testa range invalido o vuoto
00175   if (value.begin >= value.end)
00176     return;
00177 
00178   typename TSet::iterator i = std::lower_bound(set.begin(),set.end(),value,range_comp());
00179 
00180   if (i==set.end())
00181     return;
00182 
00183   // se non interseca con nessuno esci
00184   if ( value.end <= (*i).begin )
00185     return;
00186 
00187   // tronca successivo
00188   if ( value.begin > (*i).begin )
00189   {
00190     // sdoppia range
00191     if ( value.end < (*i).end)
00192     {
00193       T begin = (*i).begin;
00194       (*i).begin = value.end;
00195       set.insert(i,value_type(begin,value.begin));
00196       return;
00197     }
00198     (*i).end = value.begin;
00199     ++i;
00200   }
00201 
00202   // cerca tutti i range che si devono togliere del tutto
00203   typename TSet::iterator ii = i;
00204   while( ii != set.end() && value.end >= (*ii).end )
00205     ++ii;
00206 
00207   // toglie parte in eccesso al range corrente
00208   if ( value.end >= (*ii).begin )
00209     (*ii).begin = value.end;
00210 
00211   // toglie ranges in eccesso
00212   set.erase(i,ii);
00213 }

template<class T>
void range_set< T >::erase iterator    i [inline]
 

Definition at line 85 of file range.hpp.

00086   { set.erase(const_cast<typename TSet::iterator>(i)); }

template<class T>
bool range_set< T >::insert const value_type  
 

Definition at line 122 of file range.hpp.

References range_set< T >::end(), and range_set< T >::set.

Referenced by CodeParser::CheckCodeRecursively().

00123 {
00124   // testa range invalido o vuoto
00125   if (value.begin >= value.end)
00126     return true;
00127 
00128   typename TSet::iterator i = std::lower_bound(set.begin(),set.end(),value,range_comp());
00129 
00130   // se fuori range inserisce e basta
00131   if (i==set.end() || value.end < (*i).begin)
00132   {
00133     set.insert(i,value);
00134     return false;
00135   }
00136 
00137   // estende inizio se necessario
00138   bool res = true;
00139   if (value.begin < (*i).begin)
00140   {
00141     (*i).begin = value.begin;
00142     res = false;
00143   }
00144 
00145   // estende fine se necessario
00146   if (value.end >= (*i).end)
00147   {
00148     // calcola fine range e range in eccesso
00149     T end = value.end;
00150     typename TSet::iterator ii = i;
00151     while(++ii != set.end())
00152     {
00153       if (end >=(*ii).begin && end<=(*ii).end)
00154         end = (*ii).end;
00155       if (end < (*ii).end)
00156         break;
00157     }
00158 
00159     // estendi range finale
00160     (*i).end = end;
00161 
00162     // cancella ranges in eccesso
00163     set.erase(++i,ii);
00164 
00165     // il range non era interamente presente
00166     return false;
00167   }
00168   return res;
00169 }

template<class T>
size_type range_set< T >::max_size   const [inline]
 

Definition at line 79 of file range.hpp.

00079 { return set.max_size(); }

template<class T>
const_reverse_iterator range_set< T >::rbegin   const [inline]
 

Definition at line 73 of file range.hpp.

00073 { return set.rbegin(); }

template<class T>
const_reverse_iterator range_set< T >::rend   const [inline]
 

Definition at line 74 of file range.hpp.

00074 { return set.rend(); }

template<class T>
size_type range_set< T >::size   const [inline]
 

Definition at line 78 of file range.hpp.

00078 { return set.size(); }

template<class T>
void range_set< T >::swap range_set< T > &    rhs [inline]
 

Definition at line 90 of file range.hpp.

00090 { set.swap(rhs.set); }


Member Data Documentation

template<class T>
TSet range_set< T >::set [private]
 

Definition at line 51 of file range.hpp.

Referenced by range_set< long >::begin(), range_set< long >::empty(), range_set< long >::end(), range_set< T >::erase(), range_set< long >::erase(), range_set< T >::insert(), range_set< long >::max_size(), range_set< long >::rbegin(), range_set< long >::rend(), range_set< long >::size(), and range_set< long >::swap().


The documentation for this class was generated from the following file:
Generated on Mon Jan 13 22:20:37 2003 for perdr by doxygen1.2.15