Sparse Vector. More...

#include <rsparsevector.h>

Inheritance diagram for RSparseVector:
[legend]
Collaboration diagram for RSparseVector:
[legend]

Public Member Functions

int Compare (const RSparseVector &vec) const
 
int Compare (size_t id) const
 
size_t GetId (void) const
 
const RValueGetValue (size_t i) const
 
bool IsIn (size_t i) const
 
RSparseVectoroperator= (const RSparseVector &vec)
 
double operator[] (size_t i) const
 
double & operator[] (size_t i)
 
 RSparseVector (size_t size, size_t id=cNoRef)
 
 RSparseVector (const RSparseVector &vec)
 
void SetExistingElements (double val)
 
 ~RSparseVector (void)
 
- Public Member Functions inherited from RContainer< RValue, true, true >
void Clear (size_t m=0, size_t i=0, bool force=false)
 
int Compare (const RContainer< RValue, true, true > &) const
 
void Copy (const RContainer< RValue, 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
 
RValueGetInsertPtr (const TUse &tag, size_t min=0, size_t max=0)
 
RValueGetInsertPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0)
 
RValueGetInsertPtrAt (const TUse &tag, size_t pos)
 
size_t GetMaxNb (void) const
 
size_t GetMaxPos (void) const
 
size_t GetNb (void) const
 
RValueGetPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const
 
RValueGetPtr (const TUse &tag, size_t min=0, size_t max=0) const
 
const RValueGetPtrAt (size_t idx) const
 
RValueGetPtrAt (size_t idx)
 
RContainer< RValue, 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 RValue **tab, size_t min=0, size_t max=0) const
 
size_t GetTab (RValue **tab, size_t min=0, size_t max=0)
 
void InsertPtr (RValue *ins, bool del=false, size_t min=0, size_t max=0)
 
void InsertPtrAt (RValue *ins, size_t pos, bool del)
 
void InsertPtrAt (RValue *ins, size_t pos)
 
void Inter (const iRContainer< RValue > &src1, const iRContainer< RValue > &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
 
RContaineroperator+= (const RContainer< RValue, a, o > &src)
 
RContaineroperator= (const RContainer< RValue, true, true > &src)
 
RContaineroperator= (const RContainer< RValue, false, true > &src)
 
const RValueoperator[] (size_t idx) const
 
RValueoperator[] (size_t idx)
 
 RContainer (const RContainer< RValue, true, true > &src)
 
 RContainer (const RContainer< RValue, 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< RValue, a, o > &src)
 
void Union (const iRContainer< RValue > &src1, const iRContainer< RValue > &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
 
iRContaineroperator+= (const iRContainer< C > &src)
 
iRContaineroperator= (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< RValue, 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 >
iRContainerAdd (const iRContainer< C > &src)
 
void Create (const iRContainer< C > &src)
 
void DeepCopy (const iRContainer< C > &src)
 
iRContainerNormalCopy (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

Sparse Vector.

The RSparseVector provides a representation for a sparse vector. The vector is coded as a container of RValue. An identifier can be associate to the vector (this feature is used by RSparseMatrix).

Here is an example of code:

a[0]=1.0;
a[5]=2.0;
a[15]=3.0;
for(size_t i=0;i<16;i++)
cout<<static_cast<const RSparseVector&>(b)[i]<<endl;

An important aspect is the use of static_cast<const RSparseVector&> to ensure the call of the const version of the operator(). If static_cast<const RSparseVector&> is not used, the different elements are created with uninitialized values.

Constructor & Destructor Documentation

RSparseVector ( size_t  size,
size_t  id = cNoRef 
)

Construct a sparse vector.

Parameters
sizeInitial maximal size of the vector.
idIdentifier of the vector (cNoRef by default).
RSparseVector ( const RSparseVector vec)

Copy constructor.

Parameters
vecSparse Vector used as source.
~RSparseVector ( void  )

Destruct the sparse vector.

Member Function Documentation

RSparseVector& operator= ( const RSparseVector vec)

The assignment operator.

Parameters
vecSparse Vector used as source.
int Compare ( const RSparseVector vec) const

Compare the identifiers of two sparse vectors. param vec Sparse vector to compared with.

int Compare ( size_t  id) const

Compare the identifier of the sparse vector with a given identifier. param id Identifier to compare with.

void SetExistingElements ( double  val)

Set a given value to all the existing elements.

Parameters
valValue to set.
double operator[] ( size_t  i) const

Return the value at position i. The first value is at position 0.

Parameters
iIndex.
double& operator[] ( size_t  i)

Return the value at position i. The first value is at position 0.

Parameters
iIndex.
bool IsIn ( size_t  i) const

Verify if a given index has a value defined in the vector.

Parameters
iIndex.
Returns
true or false.
const RValue* GetValue ( size_t  i) const

Get a pointer over the value at a given index.

Parameters
iIndex.
Returns
Pointer or null if the index hasn't no value.
size_t GetId ( void  ) const

Get the identifier of the cell.

Returns
Identifier of the cell.

Member Data Documentation

size_t Id
private

Identifier of the vector (used by RSparseMatrix).