A class to manage sets of ordered items. More...
#include <ordered_set.hpp>
Public Types | |
typedef super::const_iterator | const_iterator |
typedef super::value_type | value_type |
typedef super::referent_type | referent_type |
typedef super::const_reference | const_reference |
Public Member Functions | |
ordered_set & | operator*= (const ordered_set &that) |
Intersection. | |
ordered_set & | operator+= (const ordered_set &that) |
Union. | |
ordered_set & | operator-= (const ordered_set &that) |
Difference. | |
ordered_set & | operator/= (const ordered_set &that) |
Symetric difference. | |
bool | operator> (const ordered_set &that) const |
Inclusion. | |
bool | operator>= (const ordered_set &that) const |
Inclusion or equality. | |
bool | operator< (const ordered_set &that) const |
Inclusion. | |
bool | operator<= (const ordered_set &that) const |
Inclusion or equality. | |
ordered_set & | intersection (const ordered_set &that) |
Intersection. | |
ordered_set & | join (const ordered_set &that) |
Union. | |
ordered_set & | difference (const ordered_set &that) |
Difference. | |
ordered_set & | symetric_difference (const ordered_set &that) |
Symetric difference. | |
bool | contains (const ordered_set &that) const |
Inclusion or equality. | |
bool | strictly_contains (const ordered_set &that) const |
Inclusion. | |
Private Types | |
typedef avl< K, Comp > | super |
Static Private Attributes | |
static Comp | s_key_comp |
Function object used to compare keys. |
A class to manage sets of ordered items.
Definition at line 44 of file ordered_set.hpp.
typedef super::const_iterator claw::math::ordered_set< K, Comp >::const_iterator |
Reimplemented from claw::avl< K, Comp >.
Definition at line 51 of file ordered_set.hpp.
typedef super::const_reference claw::math::ordered_set< K, Comp >::const_reference |
Reimplemented from claw::avl< K, Comp >.
Definition at line 54 of file ordered_set.hpp.
typedef super::referent_type claw::math::ordered_set< K, Comp >::referent_type |
Reimplemented from claw::avl< K, Comp >.
Definition at line 53 of file ordered_set.hpp.
typedef avl<K, Comp> claw::math::ordered_set< K, Comp >::super [private] |
Definition at line 48 of file ordered_set.hpp.
typedef super::value_type claw::math::ordered_set< K, Comp >::value_type |
Reimplemented from claw::avl< K, Comp >.
Definition at line 52 of file ordered_set.hpp.
bool claw::math::ordered_set< K, Comp >::contains | ( | const ordered_set< K, Comp > & | that | ) | const [inline] |
Inclusion or equality.
that | The instance that should be contained. |
Definition at line 223 of file ordered_set.tpp.
References claw::avl< K, Comp >::begin(), claw::avl< K, Comp >::end(), claw::math::ordered_set< K, Comp >::s_key_comp, and claw::avl< K, Comp >::size().
Referenced by claw::math::ordered_set< K, Comp >::operator<=(), and claw::math::ordered_set< K, Comp >::operator>=().
00224 { 00225 bool ok = super::size() >= that.size(); 00226 const_iterator it_this( super::begin() ); 00227 const_iterator it_that( that.begin() ); 00228 00229 while ( ok && (it_that != that.end()) && (it_this != super::end()) ) 00230 if ( s_key_comp( *it_this, *it_that ) ) 00231 ++it_this; 00232 else if ( s_key_comp( *it_that, *it_this ) ) 00233 ok = false; 00234 else 00235 { 00236 ++it_this; 00237 ++it_that; 00238 } 00239 00240 return it_that == that.end(); 00241 } // ordered_set::contains()
claw::math::ordered_set< K, Comp > & claw::math::ordered_set< K, Comp >::difference | ( | const ordered_set< K, Comp > & | that | ) | [inline] |
Difference.
that | The instance from which to remove items. |
Definition at line 184 of file ordered_set.tpp.
References claw::avl< K, Comp >::begin(), claw::avl< K, Comp >::end(), claw::avl< K, Comp >::erase(), and claw::avl< K, Comp >::find().
Referenced by claw::math::ordered_set< K, Comp >::operator-=(), and claw::math::ordered_set< K, Comp >::symetric_difference().
00185 { 00186 std::list<K> remove_us; 00187 const_iterator it; 00188 00189 for (it=super::begin(); it!=super::end(); ++it) 00190 if ( that.find( *it ) != that.end() ) 00191 remove_us.push_front( *it ); 00192 00193 typename std::list<K>::const_iterator remove_it; 00194 00195 for (remove_it=remove_us.begin(); remove_it!=remove_us.end(); ++remove_it) 00196 super::erase( *remove_it ); 00197 00198 return *this; 00199 } // ordered_set::difference()
claw::math::ordered_set< K, Comp > & claw::math::ordered_set< K, Comp >::intersection | ( | const ordered_set< K, Comp > & | that | ) | [inline] |
Intersection.
that | The instance to intersect from. |
Definition at line 143 of file ordered_set.tpp.
References claw::avl< K, Comp >::begin(), claw::avl< K, Comp >::end(), claw::avl< K, Comp >::erase(), and claw::avl< K, Comp >::find().
Referenced by claw::math::ordered_set< K, Comp >::operator*=().
00144 { 00145 std::list<K> remove_us; 00146 const_iterator it; 00147 00148 for (it=super::begin(); it!=super::end(); ++it) 00149 if ( that.find( *it ) == that.end() ) 00150 remove_us.push_front( *it ); 00151 00152 typename std::list<K>::const_iterator remove_it; 00153 00154 for (remove_it=remove_us.begin(); remove_it!=remove_us.end(); ++remove_it) 00155 super::erase( *remove_it ); 00156 00157 return *this; 00158 } // ordered_set::intersection()
claw::math::ordered_set< K, Comp > & claw::math::ordered_set< K, Comp >::join | ( | const ordered_set< K, Comp > & | that | ) | [inline] |
Union.
that | The instance to join with. |
Definition at line 167 of file ordered_set.tpp.
References claw::avl< K, Comp >::begin(), claw::avl< K, Comp >::end(), and claw::avl< K, Comp >::insert().
Referenced by claw::math::ordered_set< K, Comp >::operator+=(), and claw::math::ordered_set< K, Comp >::symetric_difference().
00168 { 00169 const_iterator it; 00170 00171 for (it=that.begin(); it!=that.end(); ++it) 00172 super::insert( *it ); 00173 00174 return *this; 00175 } // ordered_set::join()
claw::math::ordered_set< K, Comp > & claw::math::ordered_set< K, Comp >::operator*= | ( | const ordered_set< K, Comp > & | that | ) | [inline] |
Intersection.
that | The instance to intersect from. |
Definition at line 43 of file ordered_set.tpp.
References claw::math::ordered_set< K, Comp >::intersection().
00044 { 00045 return intersection( that ); 00046 } // ordered_set::operator*=()
claw::math::ordered_set< K, Comp > & claw::math::ordered_set< K, Comp >::operator+= | ( | const ordered_set< K, Comp > & | that | ) | [inline] |
Union.
that | The instance to join with. |
Definition at line 55 of file ordered_set.tpp.
References claw::math::ordered_set< K, Comp >::join().
00056 { 00057 return join( that ); 00058 } // ordered_set::operator+=()
claw::math::ordered_set< K, Comp > & claw::math::ordered_set< K, Comp >::operator-= | ( | const ordered_set< K, Comp > & | that | ) | [inline] |
Difference.
that | The instance from which to remove items. |
Definition at line 67 of file ordered_set.tpp.
References claw::math::ordered_set< K, Comp >::difference().
00068 { 00069 return difference( that ); 00070 } // ordered_set::operator-=()
claw::math::ordered_set< K, Comp > & claw::math::ordered_set< K, Comp >::operator/= | ( | const ordered_set< K, Comp > & | that | ) | [inline] |
Symetric difference.
that | The instance to differ from. |
Definition at line 79 of file ordered_set.tpp.
References claw::math::ordered_set< K, Comp >::symetric_difference().
00080 { 00081 return symetric_difference( that ); 00082 } // ordered_set::operator/=()
bool claw::math::ordered_set< K, Comp >::operator< | ( | const ordered_set< K, Comp > & | that | ) | const [inline] |
Inclusion.
that | The instance that should contain. |
Reimplemented from claw::avl< K, Comp >.
Definition at line 118 of file ordered_set.tpp.
References claw::math::ordered_set< K, Comp >::strictly_contains().
bool claw::math::ordered_set< K, Comp >::operator<= | ( | const ordered_set< K, Comp > & | that | ) | const [inline] |
Inclusion or equality.
that | The instance that should be contained. |
Reimplemented from claw::avl< K, Comp >.
Definition at line 131 of file ordered_set.tpp.
References claw::math::ordered_set< K, Comp >::contains().
bool claw::math::ordered_set< K, Comp >::operator> | ( | const ordered_set< K, Comp > & | that | ) | const [inline] |
Inclusion.
that | The instance that should be contained. |
Reimplemented from claw::avl< K, Comp >.
Definition at line 92 of file ordered_set.tpp.
References claw::math::ordered_set< K, Comp >::strictly_contains().
00093 { 00094 return strictly_contains( that ); 00095 } // ordered_set::operator>()
bool claw::math::ordered_set< K, Comp >::operator>= | ( | const ordered_set< K, Comp > & | that | ) | const [inline] |
Inclusion or equality.
that | The instance that should be contained. |
Reimplemented from claw::avl< K, Comp >.
Definition at line 105 of file ordered_set.tpp.
References claw::math::ordered_set< K, Comp >::contains().
00106 { 00107 return contains( that ); 00108 } // ordered_set::operator>=()
bool claw::math::ordered_set< K, Comp >::strictly_contains | ( | const ordered_set< K, Comp > & | that | ) | const [inline] |
Inclusion.
that | The instance that should contain. |
Definition at line 252 of file ordered_set.tpp.
References claw::avl< K, Comp >::size().
Referenced by claw::math::ordered_set< K, Comp >::operator<(), and claw::math::ordered_set< K, Comp >::operator>().
00253 { 00254 return contains(that) && ( super::size() > that.size() ); 00255 } // ordered_set::strictly_contains()
claw::math::ordered_set< K, Comp > & claw::math::ordered_set< K, Comp >::symetric_difference | ( | const ordered_set< K, Comp > & | that | ) | [inline] |
Symetric difference.
that | The instance to differ from. |
Definition at line 208 of file ordered_set.tpp.
References claw::math::ordered_set< K, Comp >::difference(), and claw::math::ordered_set< K, Comp >::join().
Referenced by claw::math::ordered_set< K, Comp >::operator/=().
00209 { 00210 ordered_set<K, Comp> my_copy(*this), his_copy(that); 00211 00212 return difference( that ).join( his_copy.difference(my_copy) ); 00213 } // ordered_set::symetric_difference()
Comp claw::math::ordered_set< K, Comp >::s_key_comp [inline, static, private] |
Function object used to compare keys.
Definition at line 77 of file ordered_set.hpp.
Referenced by claw::math::ordered_set< K, Comp >::contains().