Key for monotone bounded vectors. More...
#include <MonotoneBoundedVector.h>
Public Types | |
enum | |
typedef Traits< ElementType, StdVector, NoMap > | Traits_ |
typedef StdVector< typename NoMap< ElementType > ::OutputType_ > | ConverterType_ |
typedef ConverterType_::InputType_ | InputType_ |
typedef ConverterType_::OutputType_ | OutputType_ |
typedef ElementType | OutputType_ |
Public Member Functions | |
MonotoneBoundedVector (const string &name, size_t size=0) | |
Constructs a MonotoneBoundedVector given its name and expected size. | |
MonotoneBoundedVector (const string &name, const ElementType &bound1, size_t size=0) | |
Constructs a MonotoneBoundedVector given its name, a bound and expected size. | |
MonotoneBoundedVector (const string &name, const ElementType &bound1, const ElementType &bound2, size_t size=0) | |
Constructs a MonotoneBoundedVector given its name, two bounds and expected size. | |
void | checkSoFar (const StdVector< ElementType > &container) const |
Checks for monotonicity and boundness of the values. | |
void | checkSize (size_t size) const |
Checks for the size of the vector of values. | |
string | getName () const |
Gets Key's name. | |
string | getName () const |
Gets name. | |
void | setName (const string &name) |
Sets name. | |
ElementType | map (const value::Variant &variant) const |
Performs the mapping. | |
Private Attributes | |
const size_t | size_ |
const Bound1< ElementType > | bound1_ |
const Bound2< ElementType > | bound2_ |
Key for monotone bounded vectors.
This template
is used for keys whose converter type is a StdVector holding a std::vector<
ElementType>
V (of size n) with bounded and ordered elements.
There are five types of monotonicity modeled by monotone class
es:
Given a monotone class
Monotone and two bound template class
es Bound1 and Bound2 (See Bounded for more information on bound template class
es), V will be accepted only if
true
for all i = 0, ..., n - 1; andtrue
for all i = 0 ..., n - 1;where bound1_ and bound2_ are instantiations (for ElementType) of bound template class
es Bound1 and Bound2, resp.
Additionally, at construction time, the key name and the expected size of the V are fixed. At the time the value for this key is requested, V's size and its expected size are compared. If they do not match, then V is rejected.
Example 1: A key for a vector of dates in strictly increasing order:
MonotoneBoundedVector<ptime, StrictlyIncreasing> dates("Dates");
Example 2: A key for a vector of prices which accepts positive numbers.
MonotoneBoundedVector<double, NoBound, Geq> prices("Prices", 0.0);
Example 3: Same as in Example 2 but accepting only 10 elements:
MonotoneBoundedVector<double, NoBound, Geq> prices("Prices", 0.0, 10);
Example 4: A key for a vector of 5 decreasing numbers in the interval (-2,2):
MonotoneBoundedVector<double, Decreasing, Greater, Less> a("A", -2.0, 2.0, 5);
ElementType | : (template parameter) See description above; | |
Monotone | : (template parameter) Monotone class ; | |
Bound1 | : (template parameter) 1st bound template class ; | |
Bound2 | : (template parameter) 2nd bound template class . |
MonotoneBoundedVector | ( | const string & | name, | |
size_t | size = 0 | |||
) | [explicit] |
Constructs a MonotoneBoundedVector given its name and expected size.
name | : The key name; | |
size | : Expected size. By default, size = 0 which means there is no expected size, i.e., any strictly positive size for the StdVector content will be accepted. |
MonotoneBoundedVector | ( | const string & | name, | |
const ElementType & | bound1, | |||
size_t | size = 0 | |||
) |
Constructs a MonotoneBoundedVector given its name, a bound and expected size.
name | : The key name; | |
bound1 | : The value to be wrapped by Bound1; | |
size | : Expected size. By default, size = 0 which means there is no expected size, i.e., any stricktly positive size for the StdVector content will be accepted. |
MonotoneBoundedVector | ( | const string & | name, | |
const ElementType & | bound1, | |||
const ElementType & | bound2, | |||
size_t | size = 0 | |||
) |
Constructs a MonotoneBoundedVector given its name, two bounds and expected size.
name | : The key name; | |
bound1 | : The value to be wrapped by Bound1; | |
bound2 | : The value to be wrapped by Bound2; | |
size | : Expected size. By default, size = 0 which means there is no expected size, i.e., any strictly positive size for the StdVector content will be accepted. |
void checkSoFar | ( | const StdVector< ElementType > & | container | ) | const |
Checks for monotonicity and boundness of the values.
container | : The StdVector containing the std::vector of to be checked. |
RuntimeError | : If test fails. |
void checkSize | ( | size_t | size | ) | const |
Checks for the size of the vector of values.
container | : The StdVector containing the std::vector whose size should be checked. |
RuntimeError | : If there is no expected size or if it does not agree with real size. |
string getName | ( | ) | const [inherited] |
Gets Key's name.
string getName | ( | ) | const [inherited] |
Gets name.
void setName | ( | const string & | name | ) | [inherited] |
Sets name.
name | : The name. |
ElementType map | ( | const value::Variant & | variant | ) | const [inherited] |
Performs the mapping.
This method retrieves the content of value::Variant and, by considering enabled lexical convertions, converts it to Output. (See LexicalToolKit documentation.)
variant | : A value::Variant containing the input to be mapped. |