SparseArraySigned< 1, T > Class Template Reference

A sparse array of type T in 1 dimension. More...

#include <SparseArraySigned1.h>

Inheritance diagram for SparseArraySigned< 1, T >:
SparseArray< 1, T > ArrayContainer< T >

List of all members.

Public Types

typedef Types::value_type value_type
 The element type of the array.
typedef Types::parameter_type parameter_type
 The parameter type.
typedef
Types::unqualified_value_type 
unqualified_value_type
 The unqualified value type.
typedef Types::pointer pointer
 A pointer to an array element.
typedef Types::const_pointer const_pointer
 A pointer to a constant array element.
typedef Types::iterator iterator
 An iterator in the array.
typedef Types::const_iterator const_iterator
 A iterator on constant elements in the array.
typedef Types::reference reference
 A reference to an array element.
typedef Types::const_reference const_reference
 A reference to a constant array element.
typedef Types::size_type size_type
 The size type is a signed integer.
typedef Types::difference_type difference_type
 Pointer difference type.
typedef int index_type
 An index into the array.

Public Member Functions

Constructors etc.

 SparseArraySigned (parameter_type nullValue=std::numeric_limits< value_type >::max())
 Default constructor.
template<typename IndexForwardIter , typename ValueForwardIter >
 SparseArraySigned (IndexForwardIter indicesBeginning, IndexForwardIter indicesEnd, ValueForwardIter valuesBeginning, ValueForwardIter valuesEnd, parameter_type nullValue=std::numeric_limits< value_type >::max())
 Construct a 1-D array sparse array from the values and indices.
template<typename T2 , bool A>
 SparseArraySigned (const Array< 1, T2, A > &array, parameter_type nullValue)
 Construct a 1-D sparse array from a 1-D dense array.
 SparseArraySigned (const SparseArraySigned &other)
 Copy constructor. Deep copy.
 ~SparseArraySigned ()
 Destructor.
Assignment operators.

SparseArraySigned & operator= (const SparseArraySigned &other)
 Assignment operator.
Accessors.

int getSign () const
 Return the sign.
size_type getMemoryUsage () const
 Return the memory size.
value_type operator() (const int i) const
 Return the specified element.
bool operator== (const SparseArraySigned &x) const
 Return true if this sparse array is equal to the argument.
template<typename T2 , bool A>
void fill (ads::Array< 1, T2, A > *array) const
 Fill a dense array with the elements from this sparse array.
Manipulators.

void swap (SparseArraySigned &x)
 Swaps data with another SparseArraySigned.
void negate ()
 Negate each component.
void setSign (const int sign)
 Set the sign.
Assignment operators with scalar operand.

These need to be defined to get the correct return type. I can't just inherit the functions from the base class.

SparseArraySigned & operator= (parameter_type x)
 Set each component to x.
SparseArraySigned & operator+= (parameter_type x)
 Add x to each component.
SparseArraySigned & operator-= (parameter_type x)
 Subtract x from each component.
SparseArraySigned & operator*= (parameter_type x)
 Multiply each component by x.
SparseArraySigned & operator/= (parameter_type x)
 Divide each component by x.
SparseArraySigned & operator%= (parameter_type x)
 Mod each component by x.
File I/O.

void put (std::ostream &out) const
 Write the array to a file stream in ascii format.
void get (std::istream &in)
 Read from a file stream in ascii format.

Protected Attributes

int _sign
 The sign. This is used if there are no non-null elements.

Friends

void merge (const SparseArraySigned< 1, T > &a, const SparseArraySigned< 1, T > &b, SparseArraySigned< 1, T > *c)
 Merge two arrays.
void removeUnecessaryElements (SparseArraySigned< 1, T > *a)
 Remove the unecessary elements in an array.
void computeUnion (const SparseArraySigned< 1, T > &a, const SparseArraySigned< 1, T > &b, SparseArraySigned< 1, T > *c)
 Compute the union of two implicit functions.
void computeIntersection (const SparseArraySigned< 1, T > &a, const SparseArraySigned< 1, T > &b, SparseArraySigned< 1, T > *c)
 Compute the intersection of two implicit functions.

Detailed Description

template<typename T>
class SparseArraySigned< 1, T >

A sparse array of type T in 1 dimension.

Parameters:
T is the value type. By default it is double.

The free functions are grouped into the following categories.

Note that operator[] is container indexing. a[i] is the i_th non-null element. However, operator() is array indexing. a(i) is the element with index i.


Member Typedef Documentation

template<typename T >
typedef Types::parameter_type SparseArraySigned< 1, T >::parameter_type

The parameter type.

This is used for passing the value type as an argument.

Reimplemented from SparseArray< 1, T >.

template<typename T >
typedef Types::size_type SparseArraySigned< 1, T >::size_type

The size type is a signed integer.

Having std::size_t (which is an unsigned integer) as the size type causes minor problems. Consult "Large Scale C++ Software Design" by John Lakos for a discussion of using unsigned integers in a class interface.

Reimplemented from SparseArray< 1, T >.

template<typename T >
typedef Types::unqualified_value_type SparseArraySigned< 1, T >::unqualified_value_type

The unqualified value type.

The value type with top level const and volatile qualifiers removed.

Reimplemented from SparseArray< 1, T >.


The documentation for this class was generated from the following file:
Generated on Thu Jun 30 02:14:52 2016 for Algorithms and Data Structures Package by  doxygen 1.6.3