Ascending Ordered Sparse Vector. More...
#include <rmaxvector.h>
Public Member Functions | |
size_t | Add (size_t id, double val, bool fixed=false) |
int | Compare (const RMaxVector &vec) const |
int | Compare (size_t id) const |
size_t | GetId (void) const |
const RMaxValue * | GetValue (size_t i) const |
const RMaxValue * | GetValueId (size_t id) const |
bool | IsIn (size_t id) const |
RMaxVector & | operator= (const RMaxVector &vec) |
double | operator[] (size_t i) const |
RMaxVector (size_t size, size_t id=cNoRef) | |
RMaxVector (const RMaxVector &vec) | |
~RMaxVector (void) | |
Public Member Functions inherited from RContainer< RMaxValue, true, true > | |
void | Clear (size_t m=0, size_t i=0, bool force=false) |
int | Compare (const RContainer< RMaxValue, true, true > &) const |
void | Copy (const RContainer< RMaxValue, a, true > &src) |
void | DeletePtr (const TUse &tag, bool sortkey, bool del, size_t min=0, size_t max=0) |
void | DeletePtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) |
void | DeletePtr (const TUse &tag, size_t min=0, size_t max=0) |
void | DeletePtrAt (size_t pos, bool shift, bool del) |
void | DeletePtrAt (size_t pos, bool shift) |
void | DeletePtrAt (size_t pos) |
void | Exchange (size_t pos1, size_t pos2) |
size_t | GetIncNb (void) const |
size_t | GetIndex (const TUse &tag, bool &find, size_t min=0, size_t max=0) const |
RMaxValue * | GetInsertPtr (const TUse &tag, size_t min=0, size_t max=0) |
RMaxValue * | GetInsertPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) |
RMaxValue * | GetInsertPtrAt (const TUse &tag, size_t pos) |
size_t | GetMaxNb (void) const |
size_t | GetMaxPos (void) const |
size_t | GetNb (void) const |
RMaxValue * | GetPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const |
RMaxValue * | GetPtr (const TUse &tag, size_t min=0, size_t max=0) const |
const RMaxValue * | GetPtrAt (size_t idx) const |
RMaxValue * | GetPtrAt (size_t idx) |
RContainer< RMaxValue, false, true > * | GetPtrs (const TUse &tag, size_t min=0, size_t max=0) const |
size_t | GetTab (const void **tab, size_t min=0, size_t max=0) const |
size_t | GetTab (void **tab, size_t min=0, size_t max=0) |
size_t | GetTab (const RMaxValue **tab, size_t min=0, size_t max=0) const |
size_t | GetTab (RMaxValue **tab, size_t min=0, size_t max=0) |
void | InsertPtr (RMaxValue *ins, bool del=false, size_t min=0, size_t max=0) |
void | InsertPtrAt (RMaxValue *ins, size_t pos, bool del) |
void | InsertPtrAt (RMaxValue *ins, size_t pos) |
void | Inter (const iRContainer< RMaxValue > &src1, const iRContainer< RMaxValue > &src2) |
bool | IsIn (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const |
bool | IsIn (const TUse &tag, size_t min=0, size_t max=0) const |
RContainer & | operator+= (const RContainer< RMaxValue, a, o > &src) |
RContainer & | operator= (const RContainer< RMaxValue, true, true > &src) |
RContainer & | operator= (const RContainer< RMaxValue, false, true > &src) |
const RMaxValue * | operator[] (size_t idx) const |
RMaxValue * | operator[] (size_t idx) |
RContainer (const RContainer< RMaxValue, true, true > &src) | |
RContainer (const RContainer< RMaxValue, false, true > &src) | |
RContainer (size_t m, size_t i=0) | |
void | ReOrder (int sortOrder(const void *, const void *)) |
void | ReOrder (int sortOrder(const void *, const void *), size_t min, size_t max) |
void | ReOrder (void) |
void | Shift (size_t idx, bool reverse) |
void | Transfer (RContainer< RMaxValue, a, o > &src) |
void | Union (const iRContainer< RMaxValue > &src1, const iRContainer< RMaxValue > &src2) |
bool | VerifyIndex (size_t idx) const |
void | VerifyTab (size_t max=0) |
virtual | ~RContainer (void) |
Public Member Functions inherited from iRContainer< C > | |
void | Clear (size_t m=0, size_t i=0, bool force=false) |
void | Copy (const iRContainer< C > &src) |
void | DeletePtr (const TUse &tag, bool sortkey, bool del, size_t min=0, size_t max=0) |
void | DeletePtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) |
void | DeletePtr (const TUse &tag, size_t min=0, size_t max=0) |
void | DeletePtrAt (size_t pos, bool shift) |
void | DeletePtrAt (size_t pos) |
void | DeletePtrAt (size_t pos, bool shift, bool del) |
void | Exchange (size_t pos1, size_t pos2) |
size_t | GetIncNb (void) const |
size_t | GetIndex (const TUse &tag, bool &find, size_t min=0, size_t max=0) const |
size_t | GetIndex (bool order, const TUse &tag, bool &find, size_t min=0, size_t max=0) const |
C * | GetInsertPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) |
C * | GetInsertPtr (const TUse &tag, size_t min=0, size_t max=0) |
C * | GetInsertPtrAt (const TUse &tag, size_t pos) |
size_t | GetMaxNb (void) const |
size_t | GetMaxPos (void) const |
size_t | GetNb (void) const |
C * | GetPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const |
C * | GetPtr (const TUse &tag, size_t min=0, size_t max=0) const |
const C * | GetPtrAt (size_t idx) const |
C * | GetPtrAt (size_t idx) |
size_t | GetTab (const C **tab, size_t min=0, size_t max=0) const |
size_t | GetTab (C **tab, size_t min=0, size_t max=0) |
size_t | GetTab (const void **tab, size_t min=0, size_t max=0) const |
size_t | GetTab (void **tab, size_t min=0, size_t max=0) |
void | InsertPtr (C *ins, bool del=false, size_t min=0, size_t max=0) |
void | InsertPtrAt (C *ins, size_t pos, bool del) |
void | InsertPtrAt (C *ins, size_t pos) |
void | Inter (const iRContainer< C > &src1, const iRContainer< C > &src2) |
bool | IsIn (const TUse &tag, size_t min=0, size_t max=0) const |
bool | IsIn (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const |
iRContainer & | operator+= (const iRContainer< C > &src) |
iRContainer & | operator= (const iRContainer< C > &src) |
const C * | operator[] (size_t idx) const |
C * | operator[] (size_t idx) |
void | ReOrder (int sortOrder(const void *, const void *), size_t min, size_t max) |
void | ReOrder (int sortOrder(const void *, const void *)) |
void | ReOrder (void) |
void | Shift (size_t idx, bool reverse) |
void | Transfer (iRContainer< C > &src) |
void | Union (const iRContainer< C > &src1, const iRContainer< C > &src2) |
bool | VerifyIndex (size_t idx) const |
void | VerifyTab (size_t max=0) |
virtual | ~iRContainer (void) |
Private Attributes | |
size_t | Id |
Additional Inherited Members | |
Static Public Member Functions inherited from RContainer< RMaxValue, true, true > | |
static int | SortOrder (const void *a, const void *b) |
Static Public Member Functions inherited from iRContainer< C > | |
static int | SortOrder (const void *a, const void *b) |
Protected Member Functions inherited from iRContainer< C > | |
iRContainer & | Add (const iRContainer< C > &src) |
void | Create (const iRContainer< C > &src) |
void | DeepCopy (const iRContainer< C > &src) |
iRContainer & | NormalCopy (const iRContainer< C > &src) |
Protected Attributes inherited from iRContainer< C > | |
size_t | IncPtr |
size_t | LastPtr |
size_t | MaxPtr |
size_t | NbPtr |
C ** | Tab |
Detailed Description
Ascending Ordered Sparse Vector.
The RMaxVector provides a representation for a sparse vector where the values are ascending ordered (a[0]>a[1]>...>a[n]). The vector is coded as a container of RMaxValue. An identifier can be associate to the vector (this feature is used by RMaxMatrix).
Here is an example of code:
An important aspect is the use of static_cast<const RMaxVector&> to ensure the call of the const version of the operator(). If static_cast<const RMaxVector&> is not used, the different elements are created with uninitialized values.
Constructor & Destructor Documentation
RMaxVector | ( | size_t | size, |
size_t | id = cNoRef |
||
) |
Construct a sparse ordered vector.
- Parameters
-
size Initial maximal size of the vector. id Identifier of the vector (cNoRef by default).
RMaxVector | ( | const RMaxVector & | vec | ) |
Copy constructor.
- Parameters
-
vec Sparse ordered vector used as source.
~RMaxVector | ( | void | ) |
Destruct the sparse ordered vector.
Member Function Documentation
RMaxVector& operator= | ( | const RMaxVector & | vec | ) |
The assignment operator.
- Parameters
-
vec Sparse ordered vector used as source.
int Compare | ( | const RMaxVector & | vec | ) | const |
Compare the identifiers of two sparse ordered vectors. param vec Sparse ordered vector to compared with.
int Compare | ( | size_t | id | ) | const |
Compare the identifier of the sparse ordered vector with a given identifier. param id Identifier to compare with.
double operator[] | ( | size_t | i | ) | const |
Return the ith maximal value. The maximal value is at position 0.
- Parameters
-
i Index.
size_t Add | ( | size_t | id, |
double | val, | ||
bool | fixed = false |
||
) |
Add a value associated to a given identifier into the vector.
- Parameters
-
id Identifier. val Value to add. fixed Indicate if the size of the vector is fixed. If true, the value is only inserted if another value is smaller (this latest value will then be removed).
- Returns
- the index of the value inserted or if the value is worser than all the existing one and fixed was true.
bool IsIn | ( | size_t | id | ) | const |
Verify if a given identifier has a value defined in the vector.
- Parameters
-
id Identifier.
- Returns
- true or false.
const RMaxValue* GetValue | ( | size_t | i | ) | const |
Get a pointer over the value at a given index.
- Parameters
-
i Index.
- Returns
- Pointer to the value.
const RMaxValue* GetValueId | ( | size_t | id | ) | const |
Get a pointer over the value associated to a given identifier.
- Parameters
-
id Identifier.
- Returns
- Pointer or null if the identifier hasn't no value.
size_t GetId | ( | void | ) | const |
- Returns
- Identifier of the vector.
Member Data Documentation
|
private |
Identifier of the vector (used by RSMaxMatrix).