Concept Vector. More...

#include <gvector.h>

Inheritance diagram for GVector:
[legend]

Public Member Functions

 GVector (GConcept *metaconcept)
 
 GVector (GConcept *metaconcept, size_t max)
 
 GVector (const GVector &vector)
 
int Compare (const GVector &vector) const
 
int Compare (const GConcept &metaconcept) const
 
int Compare (const GConcept *metaconcept) const
 
R::RConstCursor< GConceptRefGetRefs (void) const
 
R::RCursor< GConceptRefGetRefs (void)
 
GConceptGetMetaConcept (void) const
 
size_t GetMetaConceptId (void) const
 
const GConceptRefGetRef (GConceptRef *ref) const
 
GConceptRefGetRef (GConceptRef *ref)
 
const GConceptRefGetRef (GConcept *concept) const
 
GConceptRefGetRef (GConcept *concept)
 
void InsertRef (GConceptRef *ref)
 
void DeleteRef (GConceptRef *ref)
 
void DeleteRef (const GConcept *concept)
 
bool IsIn (const GConcept *concept) const
 
size_t GetTab (const GConceptRef **tab) const
 
void Clear (size_t size=0)
 
size_t GetNb (void) const
 
bool IsDefined (void) const
 
double GetMaxWeight (void) const
 
double GetMaxAbsWeight (void) const
 
double GetSumWeights (void) const
 
double GetSumAbsWeights (void) const
 
void Extract (GVector &vector, const GConceptType *type)
 
template<class S >
void Print (S &stream, const R::RString &name, const char *format="%E", size_t colsize=12) const
 
void Intersection (const GVector &vector)
 
GVectoroperator= (const GVector &vector)
 
GVectoroperator+= (const GVector &vector)
 
GVectoroperator-= (const GVector &vector)
 
GVectoroperator*= (const double nb)
 
GVectoroperator/= (const double nb)
 
virtual ~GVector (void)
 

Static Public Member Functions

static int SortOrder (const void *a, const void *b)
 

Protected Member Functions

void Copy (const R::RContainer< GConceptRef, false, true > &vector)
 

Private Member Functions

void AnalyzeWeights (void) const
 
- Private Member Functions inherited from RContainer< GConceptRef, true, true >
 RContainer (size_t m, size_t i=0)
 
 RContainer (const RContainer< GConceptRef, true, true > &src)
 
 RContainer (const RContainer< GConceptRef, false, true > &src)
 
int Compare (const RContainer< GConceptRef, true, true > &) const
 
size_t GetNb (void) const
 
size_t GetMaxPos (void) const
 
size_t GetMaxNb (void) const
 
size_t GetIncNb (void) const
 
bool VerifyIndex (size_t idx) const
 
void VerifyTab (size_t max=0)
 
void Clear (size_t m=0, size_t i=0, bool force=false)
 
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 Exchange (size_t pos1, size_t pos2)
 
void Shift (size_t idx, bool reverse)
 
void Transfer (RContainer< GConceptRef, a, o > &src)
 
RContaineroperator= (const RContainer< GConceptRef, true, true > &src)
 
RContaineroperator= (const RContainer< GConceptRef, false, true > &src)
 
void Copy (const RContainer< GConceptRef, a, true > &src)
 
RContaineroperator+= (const RContainer< GConceptRef, a, o > &src)
 
size_t GetIndex (const TUse &tag, bool &find, 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
 
bool IsIn (const TUse &tag, size_t min=0, size_t max=0) const
 
const GConceptRef * operator[] (size_t idx) const
 
GConceptRef * operator[] (size_t idx)
 
const GConceptRef * GetPtrAt (size_t idx) const
 
GConceptRef * GetPtrAt (size_t idx)
 
GConceptRef * GetPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0) const
 
GConceptRef * GetPtr (const TUse &tag, size_t min=0, size_t max=0) const
 
GConceptRef * GetInsertPtr (const TUse &tag, bool sortkey, size_t min=0, size_t max=0)
 
GConceptRef * GetInsertPtr (const TUse &tag, size_t min=0, size_t max=0)
 
GConceptRef * GetInsertPtrAt (const TUse &tag, size_t pos)
 
RContainer< GConceptRef, 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 GConceptRef **tab, size_t min=0, size_t max=0) const
 
size_t GetTab (GConceptRef **tab, size_t min=0, size_t max=0)
 
void InsertPtrAt (GConceptRef *ins, size_t pos, bool del)
 
void InsertPtrAt (GConceptRef *ins, size_t pos)
 
void InsertPtr (GConceptRef *ins, bool del=false, 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 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 Inter (const iRContainer< GConceptRef > &src1, const iRContainer< GConceptRef > &src2)
 
void Union (const iRContainer< GConceptRef > &src1, const iRContainer< GConceptRef > &src2)
 
virtual ~RContainer (void)
 
- Private Member Functions inherited from iRContainer< C >
size_t GetNb (void) const
 
size_t GetMaxPos (void) const
 
size_t GetMaxNb (void) const
 
size_t GetIncNb (void) const
 
bool VerifyIndex (size_t idx) const
 
void VerifyTab (size_t max=0)
 
void Clear (size_t m=0, size_t i=0, bool force=false)
 
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 Exchange (size_t pos1, size_t pos2)
 
void Shift (size_t idx, bool reverse)
 
void Transfer (iRContainer< C > &src)
 
iRContaineroperator= (const iRContainer< C > &src)
 
void Copy (const iRContainer< C > &src)
 
iRContaineroperator+= (const iRContainer< C > &src)
 
size_t GetIndex (bool order, const TUse &tag, bool &find, size_t min=0, size_t max=0) const
 
size_t GetIndex (const TUse &tag, bool &find, 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
 
bool IsIn (const TUse &tag, size_t min=0, size_t max=0) const
 
const C * operator[] (size_t idx) const
 
C * operator[] (size_t idx)
 
const C * GetPtrAt (size_t idx) const
 
C * GetPtrAt (size_t idx)
 
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
 
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 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 C **tab, size_t min=0, size_t max=0) const
 
size_t GetTab (C **tab, 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 InsertPtr (C *ins, bool del=false, 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 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 Inter (const iRContainer< C > &src1, const iRContainer< C > &src2)
 
void Union (const iRContainer< C > &src1, const iRContainer< C > &src2)
 
virtual ~iRContainer (void)
 
void Create (const iRContainer< C > &src)
 
iRContainerNormalCopy (const iRContainer< C > &src)
 
void DeepCopy (const iRContainer< C > &src)
 
iRContainerAdd (const iRContainer< C > &src)
 

Private Attributes

GConceptMetaConcept
 
double MaxWeight
 
double MaxAbsWeight
 
- Private Attributes inherited from iRContainer< C >
C ** Tab
 
size_t NbPtr
 
size_t MaxPtr
 
size_t LastPtr
 
size_t IncPtr
 

Additional Inherited Members

- Static Private Member Functions inherited from RContainer< GConceptRef, true, true >
static int SortOrder (const void *a, const void *b)
 
- Static Private Member Functions inherited from iRContainer< C >
static int SortOrder (const void *a, const void *b)
 

Detailed Description

Concept Vector.

The GVector provides a representation for a (sparse) vector of concept references associated with a given meta-concept. Each element of the vector is represented by a GConceptRef class.

In practice, several vectors are used to describe the object (document, profile, community or class) in the tensor space model.

Constructor & Destructor Documentation

GVector ( GConcept metaconcept)

Constructor of a vector.

Parameters
metaconceptMeta-concept associated with the vector.
GVector ( GConcept metaconcept,
size_t  max 
)

Constructor of a vector.

Parameters
metaconceptMeta-concept associated with the vector.
maxInitial number of maximal references.
GVector ( const GVector vector)

Copy constructor of a vector.

Parameters
vectorVector.
virtual ~GVector ( void  )
virtual

Destruct the vector.

Member Function Documentation

static int SortOrder ( const void *  a,
const void *  b 
)
static

Static function used to order the concept weights.

Parameters
aPointer to the first object.
bPointer to the second object.
void Copy ( const R::RContainer< GConceptRef, false, true > &  vector)
protected

Copy method for the vectors.

Parameters
vectorSource vector.
int Compare ( const GVector vector) const

Compare two vectors using to their meta-concept.

See also
R::RContainer
Parameters
vectorVector.
Returns
int
int Compare ( const GConcept metaconcept) const

Compare a vector and a meta-concept.

See also
R::RContainer
Parameters
metaconceptMeta-concept.
Returns
int
int Compare ( const GConcept metaconcept) const

Compare a vector and a meta-concept.

See also
R::RContainer
Parameters
metaconceptMeta-concept.
Returns
int
R::RConstCursor<GConceptRef> GetRefs ( void  ) const

Get a cursor on the concept references.

Returns
a cursor of GConceptRef.
R::RCursor<GConceptRef> GetRefs ( void  )

Get a cursor on the concept references.

Returns
a cursor of GConceptRef.
GConcept* GetMetaConcept ( void  ) const

Get the meta-concept associated with the vector.

Returns
a pointer to a GConcept.
size_t GetMetaConceptId ( void  ) const
Returns
the meta-concept identifier associated with the vector.
const GConceptRef* GetRef ( GConceptRef ref) const

Get a concept reference based on a given one. If it is not found, it is created with a null weight.

Parameters
refConcept reference.
Returns
a pointer to a GConceptRef.
GConceptRef* GetRef ( GConceptRef ref)

Get a concept reference based on a given one. If it is not found, it is created with a null weight.

Parameters
refConcept reference.
Returns
a pointer to a GConceptRef.
const GConceptRef* GetRef ( GConcept concept) const

Get a pointer to a concept reference based on a given concept. If it is not found, it is created with a null weight.

Parameters
conceptConcept.
Returns
a pointer to a GConceptRef.
GConceptRef* GetRef ( GConcept concept)

Get a pointer to a concept reference based on a given concept. If it is not found, it is created with a null weight.

Parameters
conceptConcept.
Returns
a pointer to a GConceptRef.
void InsertRef ( GConceptRef ref)

Insert a concept reference.

Parameters
refConcept reference.
void DeleteRef ( GConceptRef ref)

Delete a concept reference.

Parameters
refConcept reference.
void DeleteRef ( const GConcept concept)

Delete an reference to a given concept.

Parameters
conceptConcept.
bool IsIn ( const GConcept concept) const

Verify if a given concept is in the vector.

Parameters
conceptConcept.
Returns
true if the concept is contained.
size_t GetTab ( const GConceptRef **  tab) const

Fill an array with the concept references.

Parameters
tabArray to fill.
Returns
the number of elements copied.
void Clear ( size_t  size = 0)

Clear the vector and extend it if necessary.

Parameters
sizeExpected size of the vector.
size_t GetNb ( void  ) const
Returns
the number of elements in the container.
bool IsDefined ( void  ) const

Verifies if the vector is defined, i.e. if it has at least one element.

Returns
true if the vector is defined.
void AnalyzeWeights ( void  ) const
private

Analyze the weights to compute the maximum weights for the different types.

double GetMaxWeight ( void  ) const

Compute the maximal weight of the concept references in the vector.

Returns
double.
double GetMaxAbsWeight ( void  ) const

Compute the maximal absolute weight of the concept references in the vector.

Returns
double.
double GetSumWeights ( void  ) const

Compute the sum of the weights of the concept references in the vector.

Returns
double.
double GetSumAbsWeights ( void  ) const

Compute the sum of the absolute weights of the concept references in the vector.

Returns
double.
void Extract ( GVector vector,
const GConceptType type 
)

Extract all concepts related to a given type an put them into a given vector that will be emptied.

Parameters
vectorDestination vectors.
typeType selected.
void Print ( S &  stream,
const R::RString name,
const char *  format = "%E",
size_t  colsize = 12 
) const

Print the content of the vector.

Template Parameters
SStream class that implements the << operator.
Parameters
streamStream.
nameName of the vector.
formatFormat used to print the number. By default, it is "%E".
colsizeSize of a column. By default, it is 12.
void Intersection ( const GVector vector)

Build the intersection two vectors. In practice, the weight of the concept references in both vectors are added, the rest is deleted.

Parameters
vectorVector to search for the intersection.
Warning
Only vectors associated with the same meta-concept can be compared.
GVector& operator= ( const GVector vector)

Assignment operator for the vectors.

Parameters
vectorVector to assign.
GVector& operator+= ( const GVector vector)

Addition operator for the vectors.

Parameters
vectorVector to add.
Warning
Only vectors associated with the same meta-concept can be added.
GVector& operator-= ( const GVector vector)

Subtraction operator for the vectors.

Parameters
vectorVector to subtract.
Warning
Only vectors associated with the same meta-concept can be subtracted.
GVector& operator*= ( const double  nb)

Multiplication operator for the vectors.

Parameters
nbNumber to multiply by.
GVector& operator/= ( const double  nb)

Division operator for the vectors.

Parameters
nbNumber to multiply by.

Member Data Documentation

GConcept* MetaConcept
private

Meta-concept associated to the vector.

double MaxWeight
private

The maximal weight of the vector.

double MaxAbsWeight
private

The maximal absolute weight the vector.