classias::sparse_vector_base< identifier_base, value_base > Class Template Reference


Detailed Description

template<class identifier_base, class value_base>
class classias::sparse_vector_base< identifier_base, value_base >

A template class for sparse vectors.

This class implements a sparse vector as a linear array of elements, pairs of identifiers and values.

Parameters:
identifier_base The type of element identifier.
value_base The type of element values.


Public Types

typedef identifier_base identifier_type
 A type representing an element identifier.
typedef value_base value_type
 A type representing an element value.
typedef std::pair< identifier_type,
value_type
element_type
 A type representing an element, a pair of (identifier, value).
typedef std::vector< element_typecontainer_type
 A type providing a container of (identifier, value) pairs.
typedef container_type::size_type size_type
 A type counting the number of pairs in a container.
typedef container_type::iterator iterator
 A type providing a random-access iterator.
typedef container_type::const_iterator const_iterator
 A type providing a read-only random-access iterator.

Public Member Functions

 sparse_vector_base ()
 Constructs a sparse vector.
virtual ~sparse_vector_base ()
 Destructs the sparse vector.
void clear ()
 Erases all the elements of the vector.
bool empty () const
 Tests if the sparse vector is empty.
size_type size () const
 Returns the number of elements in the vector.
iterator begin ()
 Returns a random-access iterator to the first element.
const_iterator begin () const
 Returns a random-access iterator to the first element.
iterator end ()
 Returns a random-access iterator pointing just beyond the last element.
const_iterator end () const
 Returns a random-access iterator pointing just beyond the last element.
void append (const identifier_type &id, const value_type &value)
 Appends an element (name, value) to the end of the vector.

Protected Attributes

container_type cont
 A container of (identifier, value) pairs.


Member Function Documentation

template<class identifier_base, class value_base>
bool classias::sparse_vector_base< identifier_base, value_base >::empty (  )  const [inline]

Tests if the sparse vector is empty.

Return values:
bool true if the sparse vector is empty, false otherwise.

template<class identifier_base, class value_base>
size_type classias::sparse_vector_base< identifier_base, value_base >::size (  )  const [inline]

Returns the number of elements in the vector.

Return values:
size_type The current size of the sparse vector.

template<class identifier_base, class value_base>
iterator classias::sparse_vector_base< identifier_base, value_base >::begin (  )  [inline]

Returns a random-access iterator to the first element.

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

template<class identifier_base, class value_base>
const_iterator classias::sparse_vector_base< identifier_base, value_base >::begin (  )  const [inline]

Returns a random-access iterator to the first element.

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

template<class identifier_base, class value_base>
iterator classias::sparse_vector_base< identifier_base, value_base >::end (  )  [inline]

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

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

template<class identifier_base, class value_base>
const_iterator classias::sparse_vector_base< identifier_base, value_base >::end (  )  const [inline]

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

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

template<class identifier_base, class value_base>
void classias::sparse_vector_base< identifier_base, value_base >::append ( const identifier_type id,
const value_type value 
) [inline]

Appends an element (name, value) to the end of the vector.

Parameters:
id The element identifier.
value The element value.


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