#include <key_mutable_set.h>
Inherits multiset< KeyMutableShell< T >, _Compare >.
Inheritance diagram for KeyMutableSet:


Public Methods | |
| SUPER::iterator | find (T &key) |
| This allows you to find an item given a Key. More... | |
| SUPER::iterator | find (const Key &key) |
| This allows you to find an item given a Key. More... | |
| SUPER::iterator | lower_bound (T &key) |
| This allows you to find the first item that has AT LEAST the value of a Key . More... | |
| SUPER::iterator | lower_bound (const Key &key) |
| This allows you to find the first item that has AT LEAST the value of a Key . More... | |
| SUPER::iterator | upper_bound (T &key) |
| This allows you to find the first item that has MORE THAN the value of a Key . More... | |
| SUPER::iterator | upper_bound (const Key &key) |
| This allows you to find the first item that has MORE THAN the value of a Key . More... | |
| void | checkSet () |
| This just checks the order of the set for testing purposes.. More... | |
| SUPER::iterator | changeKey (typename SUPER::iterator iter, const Key &newKey) |
| Given an iterator you can alter that iterator's key to be the one passed in. More... | |
Private Types | |
| typedef std::multiset< KeyMutableShell< T >, _Compare > | SUPER |
Private Methods | |
| T & | valueFromKey (const Key &key) |
Note: T is the type that each element is pointing to. The template argument should not be a pointer, but the type when added will be T* .
|
|||||
|
|
|
||||||||||||||||
|
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.
00081 {
00082 typename SUPER::iterator templess=iter,tempmore=iter;
00083 tempmore++;
00084 if (templess!=begin())
00085 templess--;
00086 _Compare comparator;
00087 KeyMutableShell<T> newKeyShell(&valueFromKey(newKey));
00088 bool endOutOfOrder=false;
00089 if (tempmore!=end()) {
00090 endOutOfOrder=comparator(*tempmore,newKeyShell);
00091 }
00092 if (comparator(newKeyShell,*templess)||endOutOfOrder) {
00093 KeyMutableShell<T> k = *iter;
00094 erase(iter);
00095 k->changeKey(newKey);
00096 insert (k);
00097 }else {
00098 (*iter)->changeKey(newKey);
00099 }
00100 //checkSet();
00101 return tempmore;
00102 }
|
|
|||||||||
|
This just checks the order of the set for testing purposes..
00067 {
00068 _Compare comparator;
00069 if (begin()!=end()) {
00070 for (typename SUPER::iterator newiter=begin(), iter=newiter++;newiter!=end();iter=newiter++) {
00071 if (comparator(*newiter,*iter)) { //greater than
00072 printf("ERROR: keys out of order!!!!!!\n");
00073 }
00074 }
00075 }
00076 }
|
|
||||||||||
|
This allows you to find an item given a Key.
00047 {
00048 return find(valueFromKey(key));
00049 }
|
|
||||||||||
|
This allows you to find an item given a Key.
00043 {
00044 return SUPER::find(KeyMutableShell<T>(&key));
00045 }
|
|
||||||||||
|
This allows you to find the first item that has AT LEAST the value of a Key .
00055 {
00056 return lower_bound(valueFromKey(key));
00057 }
|
|
||||||||||
|
This allows you to find the first item that has AT LEAST the value of a Key .
00051 {
00052 return SUPER::lower_bound(KeyMutableShell<T>(&key));
00053 }
|
|
||||||||||
|
This allows you to find the first item that has MORE THAN the value of a Key .
00063 {
00064 return upper_bound(valueFromKey(key));
00065 }
|
|
||||||||||
|
This allows you to find the first item that has MORE THAN the value of a Key .
00059 {
00060 return SUPER::upper_bound(KeyMutableShell<T>(&key));
00061 }
|
|
||||||||||
|
00036 {
00037 static T t;
00038 t.changeKey(key);
00039 return t;
00040 }
|
1.2.15