*/
Accessor(const DynamicSparsityPattern *sparsity_pattern);
+ /**
+ * Default constructor creating a dummy accessor. This constructor is here
+ * only to be able to store accessors in STL containers such as
+ * `std::vector`.
+ */
+ Accessor();
+
/**
* Row number of the element represented by this object.
*/
operator<(const Accessor &) const;
protected:
+ DeclExceptionMsg(DummyAccessor,
+ "The instance of this class was initialized"
+ " without DynamicSparsityPattern object, which"
+ " means that it is a dummy accessor that can"
+ " not do any operations.");
+
/**
* The sparsity pattern we operate on accessed.
*/
*/
Iterator(const DynamicSparsityPattern *sp);
+ /**
+ * Default constructor creating an invalid iterator. This constructor is
+ * here only to be able to store iterators in STL containers such as
+ * `std::vector`.
+ */
+ Iterator();
+
/**
* Prefix increment.
*/
+ inline Accessor::Accessor()
+ : sparsity_pattern(nullptr)
+ , current_row(numbers::invalid_size_type)
+ , current_entry()
+ , end_of_row()
+ {}
+
+
inline size_type
Accessor::row() const
{
+ Assert(sparsity_pattern != nullptr, DummyAccessor());
Assert(current_row < sparsity_pattern->n_rows(), ExcInternalError());
return current_row;
inline size_type
Accessor::column() const
{
+ Assert(sparsity_pattern != nullptr, DummyAccessor());
Assert(current_row < sparsity_pattern->n_rows(), ExcInternalError());
return *current_entry;
inline size_type
Accessor::index() const
{
+ Assert(sparsity_pattern != nullptr, DummyAccessor());
Assert(current_row < sparsity_pattern->n_rows(), ExcInternalError());
return (current_entry -
inline bool
Accessor::operator==(const Accessor &other) const
{
+ Assert(sparsity_pattern != nullptr, DummyAccessor());
+ Assert(other.sparsity_pattern != nullptr, DummyAccessor());
// compare the sparsity pattern the iterator points into, the
// current row, and the location within this row. ignore the
// latter if the row is past-the-end because in that case the
inline bool
Accessor::operator<(const Accessor &other) const
{
+ Assert(sparsity_pattern != nullptr, DummyAccessor());
+ Assert(other.sparsity_pattern != nullptr, DummyAccessor());
Assert(sparsity_pattern == other.sparsity_pattern, ExcInternalError());
// if *this is past-the-end, then it is less than no one
inline void
Accessor::advance()
{
+ Assert(sparsity_pattern != nullptr, DummyAccessor());
Assert(current_row < sparsity_pattern->n_rows(), ExcInternalError());
// move to the next element in this row
+ inline Iterator::Iterator()
+ : accessor()
+ {}
+
+
+
inline Iterator &
Iterator::operator++()
{
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2017 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+
+// test that DynamicSparsityPattern::iterator can be used
+// inside STL containers (i.e. check default constructor)
+
+#include <deal.II/lac/dynamic_sparsity_pattern.h>
+
+#include "../tests.h"
+
+
+void
+test()
+{
+ DynamicSparsityPattern sp;
+ // put nothing into the sparsity pattern
+ sp.compress();
+
+ std::vector<std::pair<DynamicSparsityPattern::const_iterator,
+ DynamicSparsityPattern::const_iterator>>
+ iterators(1);
+ iterators[0].first = sp.begin();
+ iterators[0].second = sp.end();
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main()
+{
+ initlog();
+
+ test();
+}