Public Types | Public Member Functions | Protected Types | Protected Attributes | Private Types | List of all members
vbl_sparse_array_2d< T > Class Template Reference

Sparse 2D array allowing space efficient access of the form s(300,700) =2. More...

#include <vbl_fwd.h>

Inheritance diagram for vbl_sparse_array_2d< T >:
Inheritance graph
[legend]

Public Types

typedef vbl_sparse_array_base< T, std::pair< unsigned, unsigned > >::const_iterator const_iterator
 
typedef std::size_t size_type
 
typedef T T_type
 The type of values stored by the sparse array. More...
 
typedef Map::value_type sequence_value_type
 The type of values of the controlled sequence. More...
 

Public Member Functions

bool put (unsigned i, unsigned j, const T &t)
 Put a value into location (i,j). More...
 
T & operator() (unsigned i, unsigned j)
 Return contents of location (i,j). More...
 
const T & operator() (unsigned i, unsigned j) const
 Return contents of (i,j). Assertion failure if not yet filled. More...
 
void erase (unsigned i, unsigned j)
 Erase element at location (i,j). Assertion failure if not yet filled. More...
 
bool fullp (unsigned i, unsigned j) const
 Return true if location (i,j) has been filled. More...
 
T * get_addr (unsigned i, unsigned j)
 Return the address of location (i,j). 0 if not yet filled. More...
 
std::ostream & print (std::ostream &out) const
 Print the Array to a stream in "(i,j): value" format. More...
 
T & operator() (std::pair< unsigned, unsigned > i)
 Return contents at (i). More...
 
T const & operator() (std::pair< unsigned, unsigned > i) const
 Return contents at (i). Asserts that (i) is non-empty. More...
 
void erase (std::pair< unsigned, unsigned >)
 Erase element at location (i). Assertion failure if not yet filled. More...
 
bool fullp (std::pair< unsigned, unsigned >) const
 Return true if location (i) has been filled. More...
 
bool put (std::pair< unsigned, unsigned >, const T &)
 Put a value into location (i). More...
 
T * get_addr (std::pair< unsigned, unsigned >)
 Return the address of location (i). 0 if not yet filled. More...
 
void clear ()
 Empty the sparse matrix. More...
 
size_type count_nonempty () const
 Return number of locations that have been assigned a value using "put". More...
 
const_iterator begin () const
 A bidirectional iterator pointing at the first non-empty element. More...
 
const_iterator end () const
 A bidirectional iterator pointing just beyond last non-empty element. More...
 

Protected Types

typedef std::map< std::pair< unsigned, unsigned >, T, std::less< std::pair< unsigned, unsigned > > > Map
 The type of the storage. More...
 

Protected Attributes

Map storage_
 This stores a compact list of the values. More...
 

Private Types

typedef vbl_sparse_array_base< T, std::pair< unsigned, unsigned > >::Index_type Index_type
 

Detailed Description

template<class T>
class vbl_sparse_array_2d< T >

Sparse 2D array allowing space efficient access of the form s(300,700) =2.

Definition at line 9 of file vbl_fwd.h.

Member Typedef Documentation

◆ const_iterator

template<class T>
typedef vbl_sparse_array_base<T,std::pair<unsigned,unsigned> >::const_iterator vbl_sparse_array_2d< T >::const_iterator

Definition at line 34 of file vbl_sparse_array_2d.h.

◆ Index_type

template<class T>
typedef vbl_sparse_array_base<T,std::pair<unsigned,unsigned> >::Index_type vbl_sparse_array_2d< T >::Index_type
private

Definition at line 32 of file vbl_sparse_array_2d.h.

◆ Map

typedef std::map<std::pair< unsigned, unsigned > , T, std::less<std::pair< unsigned, unsigned > > > vbl_sparse_array_base< T, std::pair< unsigned, unsigned > >::Map
protectedinherited

The type of the storage.

Definition at line 41 of file vbl_sparse_array_base.h.

◆ sequence_value_type

typedef Map::value_type vbl_sparse_array_base< T, std::pair< unsigned, unsigned > >::sequence_value_type
inherited

The type of values of the controlled sequence.

The value_type is a std::pair<Index_type, typename T_type>

Definition at line 84 of file vbl_sparse_array_base.h.

◆ size_type

typedef std::size_t vbl_sparse_array_base< T, std::pair< unsigned, unsigned > >::size_type
inherited

Definition at line 47 of file vbl_sparse_array_base.h.

◆ T_type

typedef T vbl_sparse_array_base< T, std::pair< unsigned, unsigned > >::T_type
inherited

The type of values stored by the sparse array.

Definition at line 80 of file vbl_sparse_array_base.h.

Member Function Documentation

◆ begin()

const_iterator vbl_sparse_array_base< T, std::pair< unsigned, unsigned > >::begin ( ) const
inlineinherited

A bidirectional iterator pointing at the first non-empty element.

If the array is empty it points just beyond the end.

Definition at line 88 of file vbl_sparse_array_base.h.

◆ clear()

void vbl_sparse_array_base< T, std::pair< unsigned, unsigned > >::clear ( )
inherited

Empty the sparse matrix.

Definition at line 18 of file vbl_sparse_array_base.hxx.

◆ count_nonempty()

size_type vbl_sparse_array_base< T, std::pair< unsigned, unsigned > >::count_nonempty ( ) const
inlineinherited

Return number of locations that have been assigned a value using "put".

Definition at line 74 of file vbl_sparse_array_base.h.

◆ end()

const_iterator vbl_sparse_array_base< T, std::pair< unsigned, unsigned > >::end ( ) const
inlineinherited

A bidirectional iterator pointing just beyond last non-empty element.

Definition at line 91 of file vbl_sparse_array_base.h.

◆ erase() [1/2]

void vbl_sparse_array_base< T, std::pair< unsigned, unsigned > >::erase ( std::pair< unsigned, unsigned >  i)
inherited

Erase element at location (i). Assertion failure if not yet filled.

Definition at line 36 of file vbl_sparse_array_base.hxx.

◆ erase() [2/2]

template<class T>
void vbl_sparse_array_2d< T >::erase ( unsigned  i,
unsigned  j 
)
inline

Erase element at location (i,j). Assertion failure if not yet filled.

Definition at line 57 of file vbl_sparse_array_2d.h.

◆ fullp() [1/2]

bool vbl_sparse_array_base< T, std::pair< unsigned, unsigned > >::fullp ( std::pair< unsigned, unsigned >  i) const
inherited

Return true if location (i) has been filled.

Definition at line 59 of file vbl_sparse_array_base.hxx.

◆ fullp() [2/2]

template<class T>
bool vbl_sparse_array_2d< T >::fullp ( unsigned  i,
unsigned  j 
) const
inline

Return true if location (i,j) has been filled.

Definition at line 62 of file vbl_sparse_array_2d.h.

◆ get_addr() [1/2]

T * vbl_sparse_array_base< T, std::pair< unsigned, unsigned > >::get_addr ( std::pair< unsigned, unsigned >  i)
inherited

Return the address of location (i). 0 if not yet filled.

Return the memory address of location (i). 0 if not yet filled.

Definition at line 47 of file vbl_sparse_array_base.hxx.

◆ get_addr() [2/2]

template<class T>
T* vbl_sparse_array_2d< T >::get_addr ( unsigned  i,
unsigned  j 
)
inline

Return the address of location (i,j). 0 if not yet filled.

Definition at line 68 of file vbl_sparse_array_2d.h.

◆ operator()() [1/4]

template<class T>
T& vbl_sparse_array_2d< T >::operator() ( unsigned  i,
unsigned  j 
)
inline

Return contents of location (i,j).

Returns an undefined value (in fact a T()) if location (i,j) has not been filled with a value.

Definition at line 45 of file vbl_sparse_array_2d.h.

◆ operator()() [2/4]

T& vbl_sparse_array_base< T, std::pair< unsigned, unsigned > >::operator() ( std::pair< unsigned, unsigned >  i)
inlineinherited

Return contents at (i).

Definition at line 50 of file vbl_sparse_array_base.h.

◆ operator()() [3/4]

template<class T>
const T& vbl_sparse_array_2d< T >::operator() ( unsigned  i,
unsigned  j 
) const
inline

Return contents of (i,j). Assertion failure if not yet filled.

Definition at line 51 of file vbl_sparse_array_2d.h.

◆ operator()() [4/4]

T const & vbl_sparse_array_base< T, std::pair< unsigned, unsigned > >::operator() ( std::pair< unsigned, unsigned >  i) const
inherited

Return contents at (i). Asserts that (i) is non-empty.

Return contents of (i). Assertion failure if not yet filled.

Definition at line 25 of file vbl_sparse_array_base.hxx.

◆ print()

template<class T>
std::ostream& vbl_sparse_array_2d< T >::print ( std::ostream &  out) const
inline

Print the Array to a stream in "(i,j): value" format.

Definition at line 74 of file vbl_sparse_array_2d.h.

◆ put() [1/2]

template<class T>
bool vbl_sparse_array_2d< T >::put ( unsigned  i,
unsigned  j,
const T &  t 
)
inline

Put a value into location (i,j).

Definition at line 37 of file vbl_sparse_array_2d.h.

◆ put() [2/2]

bool vbl_sparse_array_base< T, std::pair< unsigned, unsigned > >::put ( std::pair< unsigned, unsigned >  i,
const T &  t 
)
inherited

Put a value into location (i).

Definition at line 66 of file vbl_sparse_array_base.hxx.

Member Data Documentation

◆ storage_

Map vbl_sparse_array_base< T, std::pair< unsigned, unsigned > >::storage_
protectedinherited

This stores a compact list of the values.

Definition at line 43 of file vbl_sparse_array_base.h.


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