Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ListMutableSet< T, _Compare > Class Template Reference

#include <key_mutable_set.h>

Inheritance diagram for ListMutableSet< T, _Compare >:

Public Member Functions

void flatten ()
 
void checkSet ()
 This just checks the order of the set for testing purposes.. More...
 
void changeKey (typename SUPER::iterator &iter, const T &newKey, typename SUPER::iterator &templess, typename SUPER::iterator &rettempmore)
 Given an iterator you can alter that iterator's key to be the one passed in. More...
 
SUPER::iterator changeKey (typename SUPER::iterator iter, const T &newKey)
 
SUPER::iterator insert (const T &newKey, typename SUPER::iterator hint)
 
SUPER::iterator insert (const T &newKey)
 

Detailed Description

template<class T, class _Compare = std::less< T >>
class ListMutableSet< T, _Compare >

Definition at line 104 of file key_mutable_set.h.

Member Function Documentation

template<class T , class _Compare = std::less< T >>
void ListMutableSet< T, _Compare >::changeKey ( typename SUPER::iterator &  iter,
const T &  newKey,
typename SUPER::iterator &  templess,
typename SUPER::iterator &  rettempmore 
)
inline

Given an iterator you can alter that iterator's key to be the one passed in.

The type must have a function called changeKey(const Key &newKey) that changes its key to the specified new key.

Definition at line 122 of file key_mutable_set.h.

References ListMutableSet< T, _Compare >::insert().

Referenced by ListMutableSet< T, _Compare >::changeKey().

126  {
127  MutableShell< T >newKeyShell( newKey );
128  templess = rettempmore = iter;
129  ++rettempmore;
130  typename SUPER::iterator tempmore = rettempmore;
131  if ( tempmore == this->end() )
132  --tempmore;
133  if ( templess != this->begin() )
134  --templess;
135  _Compare comparator;
136  if ( comparator( newKeyShell, *templess ) || comparator( *tempmore, newKeyShell ) ) {
137  rettempmore = templess = iter = this->insert( newKeyShell, this->erase( iter ) );
138  ++rettempmore;
139  if ( templess != this->begin() )
140  --templess;
141  } else {
142  **iter = newKey;
143  //return iter;
144  }
145  }
template<class T , class _Compare = std::less< T >>
SUPER::iterator ListMutableSet< T, _Compare >::changeKey ( typename SUPER::iterator  iter,
const T &  newKey 
)
inline

Definition at line 147 of file key_mutable_set.h.

References ListMutableSet< T, _Compare >::changeKey().

148  {
149  typename SUPER::iterator templess = iter, tempmore = iter;
150  changeKey( iter, newKey, templess, tempmore );
151  return iter;
152  }
template<class T , class _Compare = std::less< T >>
void ListMutableSet< T, _Compare >::checkSet ( )
inline

This just checks the order of the set for testing purposes..

Definition at line 111 of file key_mutable_set.h.

112  {
113  _Compare comparator;
114  if ( this->begin() != this->end() )
115  for (typename SUPER::iterator newiter = this->begin(), iter = newiter++; newiter != this->end(); iter = newiter++)
116  assert( !comparator( *newiter, *iter ) );
117  }
template<class T , class _Compare = std::less< T >>
void ListMutableSet< T, _Compare >::flatten ( )
inline

Definition at line 109 of file key_mutable_set.h.

109 {}
template<class T , class _Compare = std::less< T >>
SUPER::iterator ListMutableSet< T, _Compare >::insert ( const T &  newKey,
typename SUPER::iterator  hint 
)
inline

Definition at line 153 of file key_mutable_set.h.

Referenced by ListMutableSet< T, _Compare >::changeKey(), and ListMutableSet< T, _Compare >::insert().

154  {
155  bool gequal = false, lequal = false;
156  _Compare comparator;
157  while (1) {
158  if ( hint != this->end() ) {
159  bool tlequal = !comparator( *hint, newKey );
160  bool tgequal = !comparator( newKey, *hint );
161  if (tlequal) {
162  if ( gequal || tgequal || hint == this->begin() ) {
163  return this->SUPER::insert( hint, newKey );
164  } else {
165  lequal = true;
166  --hint;
167  }
168  }
169  if (tgequal) {
170  gequal = true;
171  ++hint;
172  if (lequal || tlequal)
173  return this->SUPER::insert( hint, newKey );
174  }
175  } else if ( hint == this->begin() ) {
176  this->SUPER::insert( hint, newKey );
177  } else {
178  if (gequal)
179  return this->SUPER::insert( hint, newKey );
180  else
181  --hint;
182  }
183  }
184  }
template<class T , class _Compare = std::less< T >>
SUPER::iterator ListMutableSet< T, _Compare >::insert ( const T &  newKey)
inline

Definition at line 185 of file key_mutable_set.h.

References ListMutableSet< T, _Compare >::insert().

186  {
187  return this->insert( newKey, this->begin() );
188  }

The documentation for this class was generated from the following file: