c++boost.gif Sparse Vector

Sparse Vector

Description

The templated class sparse_vector<T, A> is the base container adaptor for sparse vectors. For a n-dimensional sparse vector and 0 <= i < n the non-zero elements v i are mapped to consecutive elements of the associative container, i.e. for elements k = vi 1 and k + 1 = vi 2 of the container holds i 1 < i2.

Example

#include <boost/numeric/ublas/vector_sparse.hpp>
#include <boost/numeric/ublas/io.hpp>

int main () {
using namespace boost::numeric::ublas;
sparse_vector<double> v (3, 3);
for (unsigned i = 0; i < v.size (); ++ i)
v (i) = i;
std::cout << v << std::endl;
}

Definition

Defined in the header vector_sparse.hpp.

Template parameters

Parameter Description Default
T The type of object stored in the sparse vector.  
A The type of the adapted array. [1] map_array<std::size_t, T>

Model of

Vector .

Type requirements

None, except for those imposed by the requirements of Vector .

Public base classes

vector_expression<sparse_vector<T, A> >

Members

Member Description
sparse_vector () Allocates a sparse_vector that holds zero elements.
sparse_vector (size_type size, size_type non_zeros) Allocates a sparse_vector that holds at most size elements.
sparse_vector (const sparse_vector &v) The copy constructor.
template<class AE>
sparse_vector (size_type non_zeros, const vector_expression<AE> &ae)
The extended copy constructor.
void resize (size_type size, size_type non_zeros) Reallocates a sparse_vector to hold at most size elements. The content of the sparse_vector is preserved.
size_type size () const Returns the size of the sparse_vector.
const_reference operator () (size_type i) const Returns the value of the i-th element.
reference operator () (size_type i) Returns a reference of the i-th element.
const_reference operator [] (size_type i) const Returns the value of the i-th element.
reference operator [] (size_type i) Returns a reference of the i-th element.
sparse_vector &operator = (const sparse_vector &v) The assignment operator.
sparse_vector &assign_temporary (sparse_vector &v) Assigns a temporary. May change the sparse vector v .
template<class AE>
sparse_vector &operator = (const vector_expression<AE> &ae)
The extended assignment operator.
template<class AE>
sparse_vector &assign (const vector_expression<AE> &ae)
Assigns a vector expression to the sparse vector. Left and right hand side of the assignment should be independent.
template<class AE>
sparse_vector &operator += (const vector_expression<AE> &ae)
A computed assignment operator. Adds the vector expression to the sparse vector.
template<class AE>
sparse_vector &plus_assign (const vector_expression<AE> &ae)
Adds a vector expression to the sparse vector. Left and right hand side of the assignment should be independent.
template<class AE>
sparse_vector &operator -= (const vector_expression<AE> &ae)
A computed assignment operator. Subtracts the vector expression from the sparse vector.
template<class AE>
sparse_vector &minus_assign (const vector_expression<AE> &ae)
Subtracts a vector expression from the sparse vector. Left and right hand side of the assignment should be independent.
template<class AT>
sparse_vector &operator *= (const AT &at)
A computed assignment operator. Multiplies the sparse vector with a scalar.
template<class AT>
sparse_vector &operator /= (const AT &at)
A computed assignment operator. Divides the sparse vector through a scalar.
void swap (sparse_vector &v) Swaps the contents of the sparse vectors.
void insert (size_type i, const_reference t) Inserts the value t at the i-th element.
void erase (size_type i) Erases the value at the i-th element.
void clear () Clears the sparse vector.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the sparse_vector.
const_iterator end () const Returns a const_iterator pointing to the end of the sparse_vector.
iterator begin () Returns a iterator pointing to the beginning of the sparse_vector.
iterator end () Returns a iterator pointing to the end of the sparse_vector.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed sparse_vector.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the end of the reversed sparse_vector.
reverse_iterator rbegin () Returns a reverse_iterator pointing to the beginning of the reversed sparse_vector.
reverse_iterator rend () Returns a reverse_iterator pointing to the end of the reversed sparse_vector.

Notes

[1] Supported parameters for the adapted array are map_array<std::size_t, T> and std::map<std::size_t, T>.

Interface

    // Array based sparse vector class
template<class T, class A>
class sparse_vector:
public vector_expression<sparse_vector<T, A> > {
public:
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef T value_type;
typedef const T &const_reference;
typedef T &reference;
typedef const T *const_pointer;
typedef T *pointer;
typedef A array_type;
typedef const A const_array_type;
typedef const sparse_vector<T, A> const_self_type;
typedef sparse_vector<T, A> self_type;
typedef const vector_const_reference<const_self_type> const_closure_type;
typedef vector_reference<self_type> closure_type;
typedef typename A::const_iterator const_iterator_type;
typedef typename A::iterator iterator_type;
typedef sparse_tag storage_category;

// Construction and destruction
sparse_vector ();
sparse_vector (size_type size, size_type non_zeros = 0);
sparse_vector (const sparse_vector &v);
template<class AE>
sparse_vector (const vector_expression<AE> &ae, size_type non_zeros = 0);

// Accessors
size_type size () const;
size_type non_zeros () const;
const_array_type &data () const;
array_type &data ();

// Resizing
void resize (size_type size, size_type non_zeros = 0);

// Element access
const_reference operator () (size_type i) const;
reference operator () (size_type i);

const_reference operator [] (size_type i) const;
reference operator [] (size_type i);

// Assignment
sparse_vector &operator = (const sparse_vector &v);
sparse_vector &assign_temporary (sparse_vector &v);
template<class AE>
sparse_vector &operator = (const vector_expression<AE> &ae);
template<class AE>
sparse_vector &reset (const vector_expression<AE> &ae);
template<class AE>
sparse_vector &assign (const vector_expression<AE> &ae);
template<class AE>
sparse_vector &operator += (const vector_expression<AE> &ae);
template<class AE>
sparse_vector &plus_assign (const vector_expression<AE> &ae);
template<class AE>
sparse_vector &operator -= (const vector_expression<AE> &ae);
template<class AE>
sparse_vector &minus_assign (const vector_expression<AE> &ae);
template<class AT>
sparse_vector &operator *= (const AT &at);
template<class AT>
sparse_vector &operator /= (const AT &at);

// Swapping
void swap (sparse_vector &v);
friend void swap (sparse_vector &v1, sparse_vector &v2);

// Element insertion and erasure
void insert (size_type i, const_reference t);
void erase (size_type i);
void clear ();

class const_iterator;
class iterator;

// Element lookup
const_iterator find (size_type i) const;
iterator find (size_type i);
const_iterator find_first (size_type i) const;
iterator find_first (size_type i);
const_iterator find_last (size_type i) const;
iterator find_last (size_type i);

// Iterators simply are pointers.

class const_iterator:
public container_const_reference<sparse_vector>,
public bidirectional_iterator_base<const_iterator, value_type> {
public:
typedef sparse_bidirectional_iterator_tag iterator_category;
typedef typename sparse_vector::difference_type difference_type;
typedef typename sparse_vector::value_type value_type;
typedef typename sparse_vector::const_reference reference;
typedef typename sparse_vector::const_pointer pointer;

// Construction and destruction
const_iterator ();
const_iterator (const sparse_vector &v, const const_iterator_type &it);
const_iterator (const iterator &it);

// Arithmetic
const_iterator &operator ++ ();
const_iterator &operator -- ();

// Dereference
reference operator * () const;

// Index
size_type index () const;

// Assignment
const_iterator &operator = (const const_iterator &it);

// Comparison
bool operator == (const const_iterator &it) const;
};

const_iterator begin () const;
const_iterator end () const;

class iterator:
public container_reference<sparse_vector>,
public bidirectional_iterator_base<iterator, value_type> {
public:
typedef sparse_bidirectional_iterator_tag iterator_category;
typedef typename sparse_vector::difference_type difference_type;
typedef typename sparse_vector::value_type value_type;
typedef typename sparse_vector::reference reference;
typedef typename sparse_vector::pointer pointer;

// Construction and destruction
iterator ();
iterator (sparse_vector &v, const iterator_type &it);

// Arithmetic
iterator &operator ++ ();
iterator &operator -- ();

// Dereference
reference operator * () const;

// Index
size_type index () const;

// Assignment
iterator &operator = (const iterator &it);

// Comparison
bool operator == (const iterator &it) const;
};

iterator begin ();
iterator end ();

// Reverse iterator

typedef reverse_iterator_base<const_iterator> const_reverse_iterator;

const_reverse_iterator rbegin () const;
const_reverse_iterator rend () const;

typedef reverse_iterator_base<iterator> reverse_iterator;

reverse_iterator rbegin ();
reverse_iterator rend ();
};

Compressed Vector

Description

The templated class compressed_vector<T, IB, IA, TA> is the base container adaptor for compressed vectors. For a n-dimensional compressed vector and 0 <= i < n the non-zero elements vi are mapped to consecutive elements of the index and value container, i.e. for elements k = vi 1 and k + 1 = vi 2 of these containers holds i 1 < i2.

Example

#include <boost/numeric/ublas/vector_sparse.hpp>
#include <boost/numeric/ublas/io.hpp>

int main () {
using namespace boost::numeric::ublas;
compressed_vector<double> v (3, 3);
for (unsigned i = 0; i < v.size (); ++ i)
v (i) = i;
std::cout << v << std::endl;
}

Definition

Defined in the header vector_sparse.hpp.

Template parameters

Parameter Description Default
T The type of object stored in the compressed vector.  
IB The index base of the compressed vector. [1] 0
IA The type of the adapted array for indices. [2] unbounded_array<std::size_t>
TA The type of the adapted array for values. [2] unbounded_array<T>

Model of

Vector .

Type requirements

None, except for those imposed by the requirements of Vector .

Public base classes

vector_expression<compressed_vector<T, IB, IA, TA> >

Members

Member Description
compressed_vector () Allocates a compressed_vector that holds zero elements.
compressed_vector (size_type size, size_type non_zeros) Allocates a compressed_vector that holds at most size elements.
compressed_vector (const compressed_vector &v) The copy constructor.
template<class AE>
compressed_vector (size_type non_zeros, const vector_expression<AE> &ae)
The extended copy constructor.
void resize (size_type size, size_type non_zeros) Reallocates a compressed_vector to hold at most size elements. The content of the compressed_vector is preserved.
size_type size () const Returns the size of the compressed_vector.
const_reference operator () (size_type i) const Returns the value of the i-th element.
reference operator () (size_type i) Returns a reference of the i-th element.
const_reference operator [] (size_type i) const Returns the value of the i-th element.
reference operator [] (size_type i) Returns a reference of the i-th element.
compressed_vector &operator = (const compressed_vector &v) The assignment operator.
compressed_vector &assign_temporary (compressed_vector &v) Assigns a temporary. May change the compressed vector v.
template<class AE>
compressed_vector &operator = (const vector_expression<AE> &ae)
The extended assignment operator.
template<class AE>
compressed_vector &assign (const vector_expression<AE> &ae)
Assigns a vector expression to the compressed vector. Left and right hand side of the assignment should be independent.
template<class AE>
compressed_vector &operator += (const vector_expression<AE> &ae)
A computed assignment operator. Adds the vector expression to the compressed vector.
template<class AE>
compressed_vector &plus_assign (const vector_expression<AE> &ae)
Adds a vector expression to the compressed vector. Left and right hand side of the assignment should be independent.
template<class AE>
compressed_vector &operator -= (const vector_expression<AE> &ae)
A computed assignment operator. Subtracts the vector expression from the compressed vector.
template<class AE>
compressed_vector &minus_assign (const vector_expression<AE> &ae)
Subtracts a vector expression from the compressed vector. Left and right hand side of the assignment should be independent.
template<class AT>
compressed_vector &operator *= (const AT &at)
A computed assignment operator. Multiplies the compressed vector with a scalar.
template<class AT>
compressed_vector &operator /= (const AT &at)
A computed assignment operator. Divides the compressed vector through a scalar.
void swap (compressed_vector &v) Swaps the contents of the compressed vectors.
void insert (size_type i, const_reference t) Inserts the value t at the i-th element.
void erase (size_type i) Erases the value at the i-th element.
void clear () Clears the compressed vector.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the compressed_vector.
const_iterator end () const Returns a const_iterator pointing to the end of the compressed_vector.
iterator begin () Returns a iterator pointing to the beginning of the compressed_vector.
iterator end () Returns a iterator pointing to the end of the compressed_vector.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed compressed_vector.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the end of the reversed compressed_vector.
reverse_iterator rbegin () Returns a reverse_iterator pointing to the beginning of the reversed compressed_vector.
reverse_iterator rend () Returns a reverse_iterator pointing to the end of the reversed compressed_vector.

Notes

[1] Supported parameters for the index base are 0 and 1 at least.

[2] Supported parameters for the adapted array are unbounded_array<> , bounded_array<> and std::vector<> .

Interface

    // Array based sparse vector class
template<class T, std::size_t IB, class IA, class TA>
class compressed_vector:
public vector_expression<compressed_vector<T, IB, IA, TA> > {
public:
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef T value_type;
typedef const T &const_reference;
typedef T &reference;
typedef const T *const_pointer;
typedef T *pointer;
typedef IA index_array_type;
typedef TA value_array_type;
typedef const compressed_vector<T, IB, IA, TA> const_self_type;
typedef compressed_vector<T, IB, IA, TA> self_type;
typedef const vector_const_reference<const_self_type> const_closure_type;
typedef vector_reference<self_type> closure_type;
typedef typename IA::const_iterator const_iterator_type;
typedef typename IA::iterator iterator_type;
typedef sparse_tag storage_category;

// Construction and destruction
compressed_vector ();
compressed_vector (size_type size, size_type non_zeros = 0);
compressed_vector (const compressed_vector &v);
template<class AE>
compressed_vector (const vector_expression<AE> &ae, size_type non_zeros = 0);

// Accessors
size_type size () const;
size_type non_zeros () const;
static size_type index_base ();
const index_array_type &index_data () const;
index_array_type &index_data ();
const value_array_type &value_data () const;
value_array_type &value_data ();

// Resizing
void resize (size_type size, size_type non_zeros = 0);

// Element access
const_reference operator () (size_type i) const;
reference operator () (size_type i);

const_reference operator [] (size_type i) const;
reference operator [] (size_type i);

// Assignment
compressed_vector &operator = (const compressed_vector &v);
compressed_vector &assign_temporary (compressed_vector &v);
template<class AE>
compressed_vector &operator = (const vector_expression<AE> &ae);
template<class AE>
compressed_vector &reset (const vector_expression<AE> &ae);
template<class AE>
compressed_vector &assign (const vector_expression<AE> &ae);
template<class AE>
compressed_vector &operator += (const vector_expression<AE> &ae);
template<class AE>
compressed_vector &plus_assign (const vector_expression<AE> &ae);
template<class AE>
compressed_vector &operator -= (const vector_expression<AE> &ae);
template<class AE>
compressed_vector &minus_assign (const vector_expression<AE> &ae);
template<class AT>
compressed_vector &operator *= (const AT &at);
template<class AT>
compressed_vector &operator /= (const AT &at);

// Swapping
void swap (compressed_vector &v);
friend void swap (compressed_vector &v1, compressed_vector &v2);

// Element insertion and erasure
void insert (size_type i, const_reference t);
void erase (size_type i);
void clear ();

class const_iterator;
class iterator;

// Element lookup
const_iterator find (size_type i) const;
iterator find (size_type i);
const_iterator find_first (size_type i) const;
iterator find_first (size_type i);
const_iterator find_last (size_type i) const;
iterator find_last (size_type i);

// Iterators simply are pointers.

class const_iterator:
public container_const_reference<compressed_vector>,
public bidirectional_iterator_base<const_iterator, value_type> {
public:
typedef sparse_bidirectional_iterator_tag iterator_category;
typedef typename compressed_vector::difference_type difference_type;
typedef typename compressed_vector::value_type value_type;
typedef typename compressed_vector::const_reference reference;
typedef typename compressed_vector::const_pointer pointer;

// Construction and destruction
const_iterator ();
const_iterator (const compressed_vector &v, const const_iterator_type &it);
const_iterator (const iterator &it);

// Arithmetic
const_iterator &operator ++ ();
const_iterator &operator -- ();

// Dereference
reference operator * () const;

// Index
size_type index () const;

// Assignment
const_iterator &operator = (const const_iterator &it);

// Comparison
bool operator == (const const_iterator &it) const;
};

const_iterator begin () const;
const_iterator end () const;

class iterator:
public container_reference<compressed_vector>,
public bidirectional_iterator_base<iterator, value_type> {
public:
typedef sparse_bidirectional_iterator_tag iterator_category;
typedef typename compressed_vector::difference_type difference_type;
typedef typename compressed_vector::value_type value_type;
typedef typename compressed_vector::reference reference;
typedef typename compressed_vector::pointer pointer;

// Construction and destruction
iterator ();
iterator (compressed_vector &v, const iterator_type &it);

// Arithmetic
iterator &operator ++ ();
iterator &operator -- ();

// Dereference
reference operator * () const;

// Index
size_type index () const;

// Assignment
iterator &operator = (const iterator &it);

// Comparison
bool operator == (const iterator &it) const;
};

iterator begin ();
iterator end ();

// Reverse iterator

typedef reverse_iterator_base<const_iterator> const_reverse_iterator;

const_reverse_iterator rbegin () const;
const_reverse_iterator rend () const;

typedef reverse_iterator_base<iterator> reverse_iterator;

reverse_iterator rbegin ();
reverse_iterator rend ();
};

Coordinate Vector

Description

The templated class coordinate_vector<T, IB, IA, TA> is the base container adaptor for compressed vectors. For a n-dimensional sorted coordinate vector and 0 <= i < n the non-zero elements vi are mapped to consecutive elements of the index and value container, i.e. for elements k = v i1 and k + 1 = vi2 of these containers holds i1 < i2.

Example

#include <boost/numeric/ublas/vector_sparse.hpp>
#include <boost/numeric/ublas/io.hpp>

int main () {
using namespace boost::numeric::ublas;
coordinate_vector<double> v (3, 3);
for (unsigned i = 0; i < v.size (); ++ i)
v (i) = i;
std::cout << v << std::endl;
}

Definition

Defined in the header vector_sparse.hpp.

Template parameters

Parameter Description Default
T The type of object stored in the coordinate vector.  
IB The index base of the coordinate vector. [1] 0
IA The type of the adapted array for indices. [2] unbounded_array<std::size_t>
TA The type of the adapted array for values. [2] unbounded_array<T>

Model of

Vector .

Type requirements

None, except for those imposed by the requirements of Vector .

Public base classes

vector_expression<coordinate_vector<T, IB, IA, TA> >

Members

Member Description
coordinate_vector () Allocates a coordinate_vector that holds zero elements.
coordinate_vector (size_type size, size_type non_zeros) Allocates a coordinate_vector that holds at most size elements.
coordinate_vector (const coordinate_vector &v) The copy constructor.
template<class AE>
coordinate_vector (size_type non_zeros, const vector_expression<AE> &ae)
The extended copy constructor.
void resize (size_type size, size_type non_zeros) Reallocates a coordinate_vector to hold at most size elements. The content of the coordinate_vector is preserved.
size_type size () const Returns the size of the coordinate_vector.
const_reference operator () (size_type i) const Returns the value of the i-th element.
reference operator () (size_type i) Returns a reference of the i-th element.
const_reference operator [] (size_type i) const Returns the value of the i-th element.
reference operator [] (size_type i) Returns a reference of the i-th element.
coordinate_vector &operator = (const coordinate_vector &v) The assignment operator.
coordinate_vector &assign_temporary (coordinate_vector &v) Assigns a temporary. May change the coordinate vector v.
template<class AE>
coordinate_vector &operator = (const vector_expression<AE> &ae)
The extended assignment operator.
template<class AE>
coordinate_vector &assign (const vector_expression<AE> &ae)
Assigns a vector expression to the coordinate vector. Left and right hand side of the assignment should be independent.
template<class AE>
coordinate_vector &operator += (const vector_expression<AE> &ae)
A computed assignment operator. Adds the vector expression to the coordinate vector.
template<class AE>
coordinate_vector &plus_assign (const vector_expression<AE> &ae)
Adds a vector expression to the coordinate vector. Left and right hand side of the assignment should be independent.
template<class AE>
coordinate_vector &operator -= (const vector_expression<AE> &ae)
A computed assignment operator. Subtracts the vector expression from the coordinate vector.
template<class AE>
coordinate_vector &minus_assign (const vector_expression<AE> &ae)
Subtracts a vector expression from the coordinate vector. Left and right hand side of the assignment should be independent.
template<class AT>
coordinate_vector &operator *= (const AT &at)
A computed assignment operator. Multiplies the coordinate vector with a scalar.
template<class AT>
coordinate_vector &operator /= (const AT &at)
A computed assignment operator. Divides the coordinate vector through a scalar.
void swap (coordinate_vector &v) Swaps the contents of the coordinate vectors.
void insert (size_type i, const_reference t) Inserts the value t at the i-th element.
void erase (size_type i) Erases the value at the i-th element.
void clear () Clears the coordinate vector.
const_iterator begin () const Returns a const_iterator pointing to the beginning of the coordinate_vector.
const_iterator end () const Returns a const_iterator pointing to the end of the coordinate_vector.
iterator begin () Returns a iterator pointing to the beginning of the coordinate_vector.
iterator end () Returns a iterator pointing to the end of the coordinate_vector.
const_reverse_iterator rbegin () const Returns a const_reverse_iterator pointing to the beginning of the reversed coordinate_vector.
const_reverse_iterator rend () const Returns a const_reverse_iterator pointing to the end of the reversed coordinate_vector.
reverse_iterator rbegin () Returns a reverse_iterator pointing to the beginning of the reversed coordinate_vector.
reverse_iterator rend () Returns a reverse_iterator pointing to the end of the reversed coordinate_vector.

Notes

[1] Supported parameters for the index base are 0 and 1 at least.

[2] Supported parameters for the adapted array are unbounded_array<> , bounded_array<> and std::vector<> .

Interface

    // Array based sparse vector class
template<class T, std::size_t IB, class IA, class TA>
class coordinate_vector:
public vector_expression<coordinate_vector<T, IB, IA, TA> > {
public:
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef T value_type;
typedef const T &const_reference;
typedef T &reference;
typedef const T *const_pointer;
typedef T *pointer;
typedef IA index_array_type;
typedef TA value_array_type;
typedef const coordinate_vector<T, IB, IA, TA> const_self_type;
typedef coordinate_vector<T, IB, IA, TA> self_type;
typedef const vector_const_reference<const_self_type> const_closure_type;
typedef vector_reference<self_type> closure_type;
typedef typename IA::const_iterator const_iterator_type;
typedef typename IA::iterator iterator_type;
typedef sparse_tag storage_category;

// Construction and destruction
coordinate_vector ();
coordinate_vector (size_type size, size_type non_zeros = 0);
coordinate_vector (const coordinate_vector &v);
template<class AE>
coordinate_vector (const vector_expression<AE> &ae, size_type non_zeros = 0);

// Accessors
size_type size () const;
size_type non_zeros () const;
static size_type index_base ();
const index_array_type &index_data () const;
index_array_type &index_data ();
const value_array_type &value_data () const;
value_array_type &value_data ();

// Resizing
void resize (size_type size, size_type non_zeros = 0);

// Element access
const_reference operator () (size_type i) const;
reference operator () (size_type i);

const_reference operator [] (size_type i) const;
reference operator [] (size_type i);

// Assignment
coordinate_vector &operator = (const coordinate_vector &v);
coordinate_vector &assign_temporary (coordinate_vector &v);
template<class AE>
coordinate_vector &operator = (const vector_expression<AE> &ae);
template<class AE>
coordinate_vector &reset (const vector_expression<AE> &ae);
template<class AE>
coordinate_vector &assign (const vector_expression<AE> &ae);
template<class AE>
coordinate_vector &operator += (const vector_expression<AE> &ae);
template<class AE>
coordinate_vector &plus_assign (const vector_expression<AE> &ae);
template<class AE>
coordinate_vector &operator -= (const vector_expression<AE> &ae);
template<class AE>
coordinate_vector &minus_assign (const vector_expression<AE> &ae);
template<class AT>
coordinate_vector &operator *= (const AT &at);
template<class AT>
coordinate_vector &operator /= (const AT &at);

// Swapping
void swap (coordinate_vector &v);
friend void swap (coordinate_vector &v1, coordinate_vector &v2);

// Element insertion and erasure
void insert (size_type i, const_reference t);
void erase (size_type i);
void clear ();

class const_iterator;
class iterator;

// Element lookup
const_iterator find (size_type i) const;
iterator find (size_type i);
const_iterator find_first (size_type i) const;
iterator find_first (size_type i);
const_iterator find_last (size_type i) const;
iterator find_last (size_type i);

// Iterators simply are pointers.

class const_iterator:
public container_const_reference<coordinate_vector>,
public bidirectional_iterator_base<const_iterator, value_type> {
public:
typedef sparse_bidirectional_iterator_tag iterator_category;
typedef typename coordinate_vector::difference_type difference_type;
typedef typename coordinate_vector::value_type value_type;
typedef typename coordinate_vector::const_reference reference;
typedef typename coordinate_vector::const_pointer pointer;

// Construction and destruction
const_iterator ();
const_iterator (const coordinate_vector &v, const const_iterator_type &it);
const_iterator (const iterator &it);

// Arithmetic
const_iterator &operator ++ ();
const_iterator &operator -- ();

// Dereference
reference operator * () const;

// Index
size_type index () const;

// Assignment
const_iterator &operator = (const const_iterator &it);

// Comparison
bool operator == (const const_iterator &it) const;
};

const_iterator begin () const;
const_iterator end () const;

class iterator:
public container_reference<coordinate_vector>,
public bidirectional_iterator_base<iterator, value_type> {
public:
typedef sparse_bidirectional_iterator_tag iterator_category;
typedef typename coordinate_vector::difference_type difference_type;
typedef typename coordinate_vector::value_type value_type;
typedef typename coordinate_vector::reference reference;
typedef typename coordinate_vector::pointer pointer;

// Construction and destruction
iterator ();
iterator (coordinate_vector &v, const iterator_type &it);

// Arithmetic
iterator &operator ++ ();
iterator &operator -- ();

// Dereference
reference operator * () const;

// Index
size_type index () const;

// Assignment
iterator &operator = (const iterator &it);

// Comparison
bool operator == (const iterator &it) const;
};

iterator begin ();
iterator end ();

// Reverse iterator

typedef reverse_iterator_base<const_iterator> const_reverse_iterator;

const_reverse_iterator rbegin () const;
const_reverse_iterator rend () const;

typedef reverse_iterator_base<iterator> reverse_iterator;

reverse_iterator rbegin ();
reverse_iterator rend ();
};

Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided ``as is'' without express or implied warranty, and with no claim as to its suitability for any purpose.

Last revised: 1/15/2003

s