classias::candidate_instance_base< attributes_tmpl, weight_tmpl, group_tmpl > Class Template Reference

Inheritance diagram for classias::candidate_instance_base< attributes_tmpl, weight_tmpl, group_tmpl >:

classias::weight_base classias::group_base

Detailed Description

template<class attributes_tmpl, class weight_tmpl = weight_base, class group_tmpl = group_base>
class classias::candidate_instance_base< attributes_tmpl, weight_tmpl, group_tmpl >

A template class for candidate instances.

This class implements an instance for candidate classification. An instance for candidate classification consists of multiple candidates each of which consists of a feature vector (implemented by attributes_tmpl). The true candidate is specified by a candidate index (implemented in this class). In addition, an instance class exposes the interfaces for instance weighting (implemented by weight_tmpl) and instance group numbers (implemented by group_tmpl).

Parameters:
attributes_tmpl The type of an attribute vector.
weight_tmpl The base class implementing instance weighting. By default, this class uses weight_base.
group_tmpl The base class implementing group numbers. By default, this class uses group_base.
See also:
sparse_vector_base, weight_base, group_base.


Public Types

typedef attributes_tmpl attributes_type
 A type representing an attribute vector.
typedef attributes_type candidate_type
 A type representing a candidate (a synonym of attributes_type).
typedef std::vector< candidate_typecandidates_type
 A type providing a container of all candidates.
typedef candidates_type::size_type size_type
 A type counting the number of candidates in the instance.
typedef candidates_type::iterator iterator
 A type providing a random-access iterator for candidates.
typedef candidates_type::const_iterator const_iterator
 A type providing a read-only random-access iterator for candidates.
typedef attributes_type::identifier_type attribute_type
 The type of an attribute identifier.
typedef attributes_type::value_type value_type
 The type of an attribute value.

Public Member Functions

 candidate_instance_base ()
 Constructs an object.
virtual ~candidate_instance_base ()
 Destructs the object.
void clear ()
 Erases all the candidates in the object.
bool empty () const
 Tests if the object has no candidate.
size_type size () const
 Returns the number of candidates.
iterator begin ()
 Returns a random-access iterator to the first candidate.
const_iterator begin () const
 Returns a random-access iterator to the first candidate.
iterator end ()
 Returns a random-access iterator pointing just beyond the last candidate.
const_iterator end () const
 Returns a random-access iterator pointing just beyond the last candidate.
void append (const candidate_type &candidate)
 Adds an candidate to the object.
candidate_typenew_element ()
 Creates a new candidate.
void set_label (int i)
 Sets the index of the reference candidate.
int get_label () const
 Gets the index of the reference candidate.
int num_candidates (const int L) const
 Returns the number of candidates associated with the instance.
const candidate_typeattributes (int i) const
 Returns a read-only access to the attribute vector of a candidate.
candidate_typeattributes (int i)
 Returns an access to the attribute vector of a candidate.

Protected Attributes

candidates_type candidates
 A container of all candidates associated with the instance.
int m_label
 The label of this instance.


Member Function Documentation

template<class attributes_tmpl, class weight_tmpl = weight_base, class group_tmpl = group_base>
bool classias::candidate_instance_base< attributes_tmpl, weight_tmpl, group_tmpl >::empty (  )  const [inline]

Tests if the object has no candidate.

Return values:
bool true if the object has no candidate, false otherwise.

template<class attributes_tmpl, class weight_tmpl = weight_base, class group_tmpl = group_base>
size_type classias::candidate_instance_base< attributes_tmpl, weight_tmpl, group_tmpl >::size (  )  const [inline]

Returns the number of candidates.

Return values:
int The number of candidates associated with the instance.

template<class attributes_tmpl, class weight_tmpl = weight_base, class group_tmpl = group_base>
iterator classias::candidate_instance_base< attributes_tmpl, weight_tmpl, group_tmpl >::begin (  )  [inline]

Returns a random-access iterator to the first candidate.

Return values:
iterator A random-access iterator (for read/write) addressing the first candidate or to the location succeeding an empty candidate.

template<class attributes_tmpl, class weight_tmpl = weight_base, class group_tmpl = group_base>
const_iterator classias::candidate_instance_base< attributes_tmpl, weight_tmpl, group_tmpl >::begin (  )  const [inline]

Returns a random-access iterator to the first candidate.

Return values:
iterator A random-access iterator (for read-only) addressing the first candidate or to the location succeeding an empty candidate.

template<class attributes_tmpl, class weight_tmpl = weight_base, class group_tmpl = group_base>
iterator classias::candidate_instance_base< attributes_tmpl, weight_tmpl, group_tmpl >::end (  )  [inline]

Returns a random-access iterator pointing just beyond the last candidate.

Return values:
iterator A random-access iterator (for read/write) addressing the end of the candidates.

template<class attributes_tmpl, class weight_tmpl = weight_base, class group_tmpl = group_base>
const_iterator classias::candidate_instance_base< attributes_tmpl, weight_tmpl, group_tmpl >::end (  )  const [inline]

Returns a random-access iterator pointing just beyond the last candidate.

Return values:
iterator A random-access iterator (for read-only) addressing the end of the candidates.

template<class attributes_tmpl, class weight_tmpl = weight_base, class group_tmpl = group_base>
void classias::candidate_instance_base< attributes_tmpl, weight_tmpl, group_tmpl >::append ( const candidate_type candidate  )  [inline]

Adds an candidate to the object.

Parameters:
candidate The candidate to be inserted to this object.

template<class attributes_tmpl, class weight_tmpl = weight_base, class group_tmpl = group_base>
candidate_type& classias::candidate_instance_base< attributes_tmpl, weight_tmpl, group_tmpl >::new_element (  )  [inline]

Creates a new candidate.

Return values:
attributes_type& The reference to the new candidate.

template<class attributes_tmpl, class weight_tmpl = weight_base, class group_tmpl = group_base>
void classias::candidate_instance_base< attributes_tmpl, weight_tmpl, group_tmpl >::set_label ( int  i  )  [inline]

Sets the index of the reference candidate.

Parameters:
i The index number of the reference candidate.

template<class attributes_tmpl, class weight_tmpl = weight_base, class group_tmpl = group_base>
int classias::candidate_instance_base< attributes_tmpl, weight_tmpl, group_tmpl >::get_label (  )  const [inline]

Gets the index of the reference candidate.

Returns:
bool The index number of the reference candidate.

template<class attributes_tmpl, class weight_tmpl = weight_base, class group_tmpl = group_base>
int classias::candidate_instance_base< attributes_tmpl, weight_tmpl, group_tmpl >::num_candidates ( const int  L  )  const [inline]

Returns the number of candidates associated with the instance.

Parameters:
L Ignored. Reserved only for the compatibility with multi_instance_base class.
Returns:
int The number of candidates associated with this instance.

template<class attributes_tmpl, class weight_tmpl = weight_base, class group_tmpl = group_base>
const candidate_type& classias::candidate_instance_base< attributes_tmpl, weight_tmpl, group_tmpl >::attributes ( int  i  )  const [inline]

Returns a read-only access to the attribute vector of a candidate.

Parameters:
i The candidate label (index).
Returns:
const attributes_type& The reference to the attribute vector associated for the candidate l.

template<class attributes_tmpl, class weight_tmpl = weight_base, class group_tmpl = group_base>
candidate_type& classias::candidate_instance_base< attributes_tmpl, weight_tmpl, group_tmpl >::attributes ( int  i  )  [inline]

Returns an access to the attribute vector of a candidate.

Parameters:
i Reserved only for the compatibility with candidate_instance_base class.
Returns:
attributes_type& The reference to the attribute vector associated for the candidate l.


Copyright (c) 2002-2009 by Naoaki Okazaki
Mon Dec 28 23:41:05 2009