Public Member Functions | Private Attributes | Friends | List of all members
Attributes Class Reference

#include <attributes.h>

Public Member Functions

 Attributes ()
 
void add (Attribute *attribute) throw ( logic_error )
 
int getClassIndex () const throw ( logic_error )
 
bool getHasNominalAttributes () const
 
bool getHasNumericAttributes () const
 
Attributeget (int i) const throw ( logic_error )
 
AttributegetClassAttribute () const throw ( logic_error )
 
int getIndex (string name) const throw ( logic_error )
 
int getSize () const
 
void parse (istream &in) throw ( logic_error )
 
void setClassIndex (int classIndex) throw ( logic_error )
 

Private Attributes

vector< Attribute * > attributes
 
bool hasNumericAttributes
 
bool hasNominalAttributes
 
int classIndex
 

Friends

ostream & operator<< (ostream &out, const Attributes &a)
 

Constructor & Destructor Documentation

Attributes::Attributes ( )

Default constructor.

Member Function Documentation

void Attributes::add ( Attribute attribute)
throw (logic_error
)

Adds a new attribute to this set of attributes.

Parameters
attributethe attribute's name
Exceptions
logic_errorif the attribute can not be added because of type or memory problems
Attribute * Attributes::get ( int  i) const
throw (logic_error
)

Returns the ith attribute in this set of attributes.

Parameters
ithe index of the specified attribute
Returns
the ith Attribute
Exceptions
logic_errorif the index is out of range
Attribute * Attributes::getClassAttribute ( ) const
throw (logic_error
)

Returns the class attribute.

Returns
the class attribute
Exceptions
logic_errorif the class index is out of range
int Attributes::getClassIndex ( ) const
throw (logic_error
)

Returns the index of the class label.

Returns
the index of the class label
Exceptions
logic_errorif the class index is out of range
bool Attributes::getHasNominalAttributes ( ) const

Returns true if this set of attributes has one or more nominal attributes; returns false otherwise.

Returns
true if this set of attributes has nominal attributes
bool Attributes::getHasNumericAttributes ( ) const

Returns true if this set of attributes has one or more numeric attributes; returns false otherwise.

Returns
true if this set of attributes has numeric attributes
int Attributes::getIndex ( string  name) const
throw (logic_error
)

Returns the attribute's index.

Parameters
namethe attribute's name
Returns
the attribute's position in the names array
Exceptions
logic_errorif the name is invalid
int Attributes::getSize ( ) const

Returns the number of attributes.

Returns
the number of attributes
void Attributes::parse ( istream &  in)
throw (logic_error
)

Parses the attribute declarations in the specified input stream. By convention, the last attribute is the class label after parsing.

Parameters
inan input stream containing the data set's tokens
Exceptions
logic_errorif there is a parse error
void Attributes::setClassIndex ( int  classIndex)
throw (logic_error
)

Sets the class index for this set of attributes.

Parameters
classIndexthe new class index
Exceptions
logic_errorif the index is out of range

Friends And Related Function Documentation

ostream& operator<< ( ostream &  out,
const Attributes a 
)
friend

Writes the specified attributes to the output stream and returns it.

Parameters
outthe output stream for writing
athe specified attribute for writing
Returns
the modified output stream

Member Data Documentation

vector<Attribute *> Attributes::attributes
private

a vector of attributes

int Attributes::classIndex
private

stores the position of the class label

bool Attributes::hasNominalAttributes
private

a flag indicating that the data set has one or more nominal attributes

bool Attributes::hasNumericAttributes
private

a flag indicating that the data set has one or more numeric attributes


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