dune-istl 2.12-git
Loading...
Searching...
No Matches
Dune::Experimental::SparseIndexRanges< I, A > Class Template Reference

Compact storage of multiple sorted sparse index sets sharing a single allocation. More...

#include <dune/istl/experimental/sparseindexranges.hh>

Inheritance diagram for Dune::Experimental::SparseIndexRanges< I, A >:
Inheritance graph

Classes

class  IndexIterator
 
class  IndexRangeView
 Read-only view of a single index set inside a SparseIndexRanges. More...
 
class  Iterator
 Random-access iterator over the index sets of a SparseIndexRanges. More...
 

Public Types

using size_type = typename alloc_traits::size_type
 Type to access the index sets.
 
using index_type = I
 Type of the indices.
 
using allocator_type = A
 Allocator type used for memory management.
 

Public Member Functions

template<class OtherAlloc >
requires std::constructible_from<A, OtherAlloc>
constexpr SparseIndexRanges (SequencedSparseIndexRangeBuilder< OtherAlloc > &&builder)
 Construct from a finished SequencedSparseIndexRangeBuilder, taking ownership of its storage and compressing it.
 
template<class OtherAlloc >
requires std::constructible_from<A, OtherAlloc>
constexpr SparseIndexRanges (UnsequencedSparseIndexRangeBuilder< OtherAlloc > &&builder)
 Construct from a finished UnsequencedSparseIndexRangeBuilder, taking ownership of its storage and compressing it.
 
constexpr SparseIndexRanges (SparseIndexRanges &&other)
 Move-construct, transferring ownership of storage from other. other is left in a valid but empty state.
 
constexpr SparseIndexRanges & operator= (SparseIndexRanges &&other)
 Move-assign, releasing current storage and transferring ownership from other. other is left in a valid but empty state.
 
constexpr void swap (SparseIndexRanges &other)
 Swap contents with other honoring allocator swap propagation traits.
 
constexpr ~SparseIndexRanges ()
 Destroy the index sets and release all allocated memory.
 
constexpr size_type size () const noexcept
 Returns the number of index sets (e.g., the number of rows in a sparse matrix).
 
constexpr size_type count () const
 Returns the total number of indices stored across all index sets (sum of all individual set sizes).
 
constexpr IntegralRange< index_type > range () const noexcept
 Returns the integer range [0, n) that every stored index belongs to.
 
constexpr size_type offset (size_type i) const
 
constexpr IndexRangeView operator[] (size_type i) const
 
constexpr Iterator begin () const
 Returns an iterator to the first index set (index set 0).
 
constexpr Iterator end () const
 Returns an iterator past the last index set.
 
std::ostream & print (std::ostream &os) const
 Writes all index sets to os, one per line in the form "[i]: j0 j1 ...". Returns os.
 

Friends

constexpr void swap (SparseIndexRanges &lhs, SparseIndexRanges &rhs)
 Swap contents of lhs and rhs, honoring allocator swap propagation traits.
 
constexpr friend bool operator== (const SparseIndexRanges &p1, const SparseIndexRanges &p2)
 Returns true if p1 and p2 contain identical index sets with identical values.
 

Detailed Description

template<class I = std::uint_least32_t, class A = std::allocator<I>>
class Dune::Experimental::SparseIndexRanges< I, A >

Compact storage of multiple sorted sparse index sets sharing a single allocation.

A SparseIndexRanges<A> stores size() sorted sparse index sets. Each index set is a subset of the integer range given by range().

Construction
Objects are built via one of two builder types and cannot be default-constructed:

After construction the storage is compressed: unused capacity is discarded and indices are stored contiguously.

Access
Iterate over all index sets with begin()/end(), or access individual sets with operator[]. Each element is an IndexRangeView, a lightweight read-only range over the sorted indices of a single index set.
Ownership
The object is move-only; copy construction and copy assignment are disabled.
Template Parameters
AAllocator type (default: std::allocator<I>).

Member Typedef Documentation

◆ allocator_type

template<class I = std::uint_least32_t, class A = std::allocator<I>>
using Dune::Experimental::SparseIndexRanges< I, A >::allocator_type = A

Allocator type used for memory management.

◆ index_type

template<class I = std::uint_least32_t, class A = std::allocator<I>>
using Dune::Experimental::SparseIndexRanges< I, A >::index_type = I

Type of the indices.

◆ size_type

template<class I = std::uint_least32_t, class A = std::allocator<I>>
using Dune::Experimental::SparseIndexRanges< I, A >::size_type = typename alloc_traits::size_type

Type to access the index sets.

Constructor & Destructor Documentation

◆ SparseIndexRanges() [1/3]

template<class I , class A >
requires std::constructible_from<A, OtherAlloc>
template<class OtherAlloc >
requires std::constructible_from<A, OtherAlloc>
constexpr Dune::Experimental::SparseIndexRanges< I, A >::SparseIndexRanges ( SequencedSparseIndexRangeBuilder< OtherAlloc > &&  builder)
constexpr

Construct from a finished SequencedSparseIndexRangeBuilder, taking ownership of its storage and compressing it.

◆ SparseIndexRanges() [2/3]

template<class I , class A >
requires std::constructible_from<A, OtherAlloc>
template<class OtherAlloc >
requires std::constructible_from<A, OtherAlloc>
constexpr Dune::Experimental::SparseIndexRanges< I, A >::SparseIndexRanges ( UnsequencedSparseIndexRangeBuilder< OtherAlloc > &&  builder)
constexpr

Construct from a finished UnsequencedSparseIndexRangeBuilder, taking ownership of its storage and compressing it.

◆ SparseIndexRanges() [3/3]

template<class I , class A >
constexpr Dune::Experimental::SparseIndexRanges< I, A >::SparseIndexRanges ( SparseIndexRanges< I, A > &&  other)
constexpr

Move-construct, transferring ownership of storage from other. other is left in a valid but empty state.

◆ ~SparseIndexRanges()

template<class I , class A >
constexpr Dune::Experimental::SparseIndexRanges< I, A >::~SparseIndexRanges ( )
constexpr

Destroy the index sets and release all allocated memory.

Member Function Documentation

◆ begin()

template<class I = std::uint_least32_t, class A = std::allocator<I>>
constexpr Iterator Dune::Experimental::SparseIndexRanges< I, A >::begin ( ) const
inlineconstexpr

Returns an iterator to the first index set (index set 0).

◆ count()

template<class I , class A >
constexpr auto Dune::Experimental::SparseIndexRanges< I, A >::count ( ) const
constexpr

Returns the total number of indices stored across all index sets (sum of all individual set sizes).

◆ end()

template<class I = std::uint_least32_t, class A = std::allocator<I>>
constexpr Iterator Dune::Experimental::SparseIndexRanges< I, A >::end ( ) const
inlineconstexpr

Returns an iterator past the last index set.

◆ offset()

template<class I , class A >
constexpr auto Dune::Experimental::SparseIndexRanges< I, A >::offset ( size_type  i) const
constexpr

Returns the flat-storage offset of the start of the i-th index set.

Parameters
iIndex-set number; 0 <= i <= size(). Pass i == size() to obtain the total index count.

◆ operator=()

template<class I , class A >
constexpr SparseIndexRanges< I, A > & Dune::Experimental::SparseIndexRanges< I, A >::operator= ( SparseIndexRanges< I, A > &&  other)
constexpr

Move-assign, releasing current storage and transferring ownership from other. other is left in a valid but empty state.

◆ operator[]()

template<class I = std::uint_least32_t, class A = std::allocator<I>>
constexpr IndexRangeView Dune::Experimental::SparseIndexRanges< I, A >::operator[] ( size_type  i) const
inlineconstexpr

Returns a read-only view of the i-th index set.

Parameters
iIndex-set number; must satisfy 0 <= i < size().

◆ print()

template<class I , class A >
std::ostream & Dune::Experimental::SparseIndexRanges< I, A >::print ( std::ostream &  os) const

Writes all index sets to os, one per line in the form "[i]: j0 j1 ...". Returns os.

◆ range()

template<class I , class A >
constexpr auto Dune::Experimental::SparseIndexRanges< I, A >::range ( ) const
constexprnoexcept

Returns the integer range [0, n) that every stored index belongs to.

◆ size()

template<class I , class A >
constexpr auto Dune::Experimental::SparseIndexRanges< I, A >::size ( ) const
constexprnoexcept

Returns the number of index sets (e.g., the number of rows in a sparse matrix).

◆ swap()

template<class I , class A >
constexpr void Dune::Experimental::SparseIndexRanges< I, A >::swap ( SparseIndexRanges< I, A > &  other)
constexpr

Swap contents with other honoring allocator swap propagation traits.

Friends And Related Symbol Documentation

◆ operator==

template<class I = std::uint_least32_t, class A = std::allocator<I>>
constexpr friend bool operator== ( const SparseIndexRanges< I, A > &  p1,
const SparseIndexRanges< I, A > &  p2 
)
friend

Returns true if p1 and p2 contain identical index sets with identical values.

◆ swap

template<class I = std::uint_least32_t, class A = std::allocator<I>>
constexpr void swap ( SparseIndexRanges< I, A > &  lhs,
SparseIndexRanges< I, A > &  rhs 
)
friend

Swap contents of lhs and rhs, honoring allocator swap propagation traits.


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