 Sparse Storage
Sparse StorageThe templated class map_std<I, T, ALLOC> provides a
wrapper for the standard library associative container
std::map. The wrapper has one simple purpose. It
allows the definition of a default template parameter (for the
adapted array) when declaring the sparse container types.
#include <boost/numeric/ublas/storage_sparse.hpp>
int main () {
    using namespace boost::numeric::ublas;
    map_std<int, double> a (3);
    for (unsigned i = 0; i < a.size (); ++ i) {
        a [i] = i;
        std::cout << a [i] << std::endl;
    }
}
Defined in the header storage_sparse.hpp.
| Parameter | Description | Default | 
|---|---|---|
| I | The type of index stored in the array. | |
| T | The type of object stored in the array. | |
| ALLOC | An STL Allocator | std::allocator | 
Reversible Container.
None, except for those imposed by the requirements of Reversible Container.
std::map
The templated class map_array<I, T, ALLOC> implements a std::map like associative container as a sorted array. It therefore some of the Associative Container interface without having the same semantics as an std::map.
At any time the map_array has a capacity up to which new element can be inserted.
If insert would cause the size of the map_array to exceeds its capactity then it is reallocated. Iterators and reference are invalidated.
The capacity can be directly control using the reserve member function.
#include <boost/numeric/ublas/storage_sparse.hpp>
int main () {
    using namespace boost::numeric::ublas;
    map_array<int, double> a (3);
    for (unsigned i = 0; i < a.size (); ++ i) {
        a [i] = i;
        std::cout << a [i] << std::endl;
    }
}
Defined in the header storage_sparse.hpp.
| Parameter | Description | Default | 
|---|---|---|
| I | The type of index stored in the array. | |
| T | The type of object stored in the array. | |
| ALLOC | An STL Allocator | std::allocator | 
Reversible Container.
None, except for those imposed by the requirements of Reversible Container.
None.
| Member | Description | 
|---|---|
| map_array (ALLOC &a = ALLOC()) | Allocates a map_arraythat holds at most zero
elements. | 
| map_array (const map_array &c) | The copy constructor. | 
| ~map_array () | Deallocates the map_arrayitself. | 
| void reserve (size_type capacity) | Changes the map_arraycapacity. It can hold at mostcapacityelements without reallocation. The capacity can be reduced such thatcapacity >= size(). The content of themap_arrayis preserved. | 
| size_type size () const | Returns the size of the map_array. | 
| size_type size () const | Returns the capacity of the map_array. | 
| data_reference operator [] (index_type i) | Returns a reference of the element that is associated with a
particular index. If the map_arraydoes not already
contain such an element,operator[]inserts the
defaultT (). | 
| map_array &operator = (const map_array
&a) | The assignment operator. | 
| map_array &assign_temporary (map_array
&a) | Assigns a temporary. May change the array a. | 
| void swap (map_array &a) | Swaps the contents of the arrays. | 
| std::pair | Inserts pinto the array. The second part of the return value istrueifpwas inserted andfalseif was not inserted because it was aleady
present. | 
| iterator insert (iterator it, const value_type
&p) | Inserts pinto the array, usingitas
a hint to where it will be inserted. | 
| void erase (iterator it) | Erases the value at it. | 
| void clear () | Clears the array. | 
| const_iterator find (index_type i) const | Finds an element whose index is i. | 
| iterator find (index_type i) | Finds an element whose index is i. | 
| const_iterator lower_bound (index_type i)
const | Finds the first element whose index is not less than i. | 
| iterator lower_bound (index_type i) | Finds the first element whose index is not less than i. | 
| const_iterator upper_bound (index_type i)
const | Finds the first element whose index is greater than i. | 
| iterator upper_bound (index_type i) | Finds the first element whose index is greater than i. | 
| const_iterator begin () const | Returns a const_iteratorpointing to the beginning
of themap_array. | 
| const_iterator end () const | Returns a const_iteratorpointing to the end of
themap_array. | 
| iterator begin () | Returns a iteratorpointing to the beginning of
themap_array. | 
| iterator end () | Returns a iteratorpointing to the end of themap_array. | 
| const_reverse_iterator rbegin () const | Returns a const_reverse_iteratorpointing to the
beginning of the reversedmap_array. | 
| const_reverse_iterator rend () const | Returns a const_reverse_iteratorpointing to the
end of the reversedmap_array. | 
| reverse_iterator rbegin () | Returns a reverse_iteratorpointing to the
beginning of the reversedmap_array. | 
| reverse_iterator rend () | Returns a reverse_iteratorpointing to the end of
the reversedmap_array. | 
Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
   Use, modification and distribution are subject to the
   Boost Software License, Version 1.0.
   (See accompanying file LICENSE_1_0.txt
   or copy at 
      http://www.boost.org/LICENSE_1_0.txt
   ).