Project
Public Member Functions | Friends | List of all members
Categories Class Reference

Set of Category datastructure. More...

#include <Categories.h>

Public Member Functions

 Categories (int number_of_categories=2, std::string prefix="cat")
 
 Categories (std::vector< std::string > vect_category_ids)
 
 Categories (const Categories &categories)
 
std::vector< int > getRankCategories ()
 
void setRankCategories (std::vector< int > &set_ranks)
 
void setRankCategories ()
 
std::vector< std::string > getIdCategories ()
 
void setIdCategories (std::string prefix)
 
void setIdCategories (std::vector< std::string > &set_category_ids)
 
Category getCategoryOfRank (int rank)
 
int getNumberCategories ()
 
Category operator[] (int index)
 
Category operator[] (int index) const
 

Friends

std::ostream & operator<< (std::ostream &out, const Categories &categories)
 

Detailed Description

Set of Category datastructure.

The Categories datastructure represents a full set of category, well formatted to be used in the problem. It is implemented with a c++ Vector.

It is used to represents all the category defined in a dataset. Each category must be different for all the others, and more specifically, the rank must be correctly defined such that we can decide which category is better when comparing two single categories. Futhermore, the categories must be ranked such that when itterating over the categories, we go from the best one (higest rank) to the lowest one. Therefore, categories[0] always represents the best category of the set.

Constructor & Destructor Documentation

◆ Categories() [1/3]

Categories::Categories ( int  number_of_categories = 2,
std::string  prefix = "cat" 
)

Categories standard constructor 1

Parameters
number_of_categoriesnumber of categories wanted
prefixprefix given to each category ids.

◆ Categories() [2/3]

Categories::Categories ( std::vector< std::string >  vect_category_ids)

Categories standard constructor 2

Parameters
vect_category_idsvector of category ids

◆ Categories() [3/3]

Categories::Categories ( const Categories categories)

Categories constructor by copy

Parameters
number_of_categoriesnumber of categories wanted

Member Function Documentation

◆ getCategoryOfRank()

Category Categories::getCategoryOfRank ( int  rank)

getCategoryOfRank get the category corresponding to the requested rank in the vector.

Parameters
rankrank of the category to return

◆ getIdCategories()

std::vector<std::string> Categories::getIdCategories ( )

Getter all the ids from Categories object

Returns
vector of Category ids

◆ getNumberCategories()

int Categories::getNumberCategories ( )

Set a new values of Category ids from Categories object

Parameters
set_category_idsvector of new Category id for Categories object

◆ getRankCategories()

std::vector<int> Categories::getRankCategories ( )

Getter all the ranks from Categories object

Returns
vector of category ranks

◆ operator[]()

Category Categories::operator[] ( int  index)

Overloading [] operator for Categories

Parameters
indexindex of the object we want
Returns
Category object at index position of Categories object

◆ setIdCategories() [1/2]

void Categories::setIdCategories ( std::string  prefix)

Set a new values of Category ids from Categories object

Parameters
prefixprefix given to Category ids.

◆ setIdCategories() [2/2]

void Categories::setIdCategories ( std::vector< std::string > &  set_category_ids)

Set a new values of Category ids from Categories object

Parameters
set_category_idsvector of new Category id for Categories object

◆ setRankCategories() [1/2]

void Categories::setRankCategories ( )

Setter all the ranks from Categories object Ranks start at 0 and end until length of Categories vector.

◆ setRankCategories() [2/2]

void Categories::setRankCategories ( std::vector< int > &  set_ranks)

Setter all the ranks from Categories object

Parameters
set_ranksvector of new category ranks

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const Categories categories 
)
friend

Overloading << operator for Categories class

Parameters
outostream
categoriesCategories object

The documentation for this class was generated from the following file: