/* IntervalAccessor */
inline
-IndexSet::IntervalAccessor::IntervalAccessor(const IndexSet *idxset, const IndexSet::size_type range_idx)
- : index_set(idxset), range_idx(range_idx)
+IndexSet::IntervalAccessor::
+IntervalAccessor(const IndexSet *idxset,
+ const IndexSet::size_type range_idx)
+ :
+ index_set(idxset),
+ range_idx(range_idx)
{
Assert(range_idx < idxset->n_intervals(), ExcInternalError("Invalid range index"));
}
+
+
inline
-IndexSet::IntervalAccessor::IntervalAccessor(const IndexSet *idxset)
- : index_set(idxset), range_idx(numbers::invalid_dof_index)
+IndexSet::IntervalAccessor::
+IntervalAccessor(const IndexSet *idxset)
+ :
+ index_set(idxset),
+ range_idx(numbers::invalid_dof_index)
{}
+
+
inline
-IndexSet::size_type IndexSet::IntervalAccessor::n_elements() const
+IndexSet::IntervalAccessor::
+IntervalAccessor(const IndexSet::IntervalAccessor &other)
+ :
+ index_set (other.index_set),
+ range_idx(other.range_idx)
+{
+ Assert( range_idx == numbers::invalid_dof_index || is_valid(),
+ ExcMessage("invalid iterator"));
+}
+
+
+
+inline
+IndexSet::size_type
+IndexSet::IntervalAccessor::n_elements() const
{
Assert(is_valid(), ExcMessage("invalid iterator"));
return index_set->ranges[range_idx].end - index_set->ranges[range_idx].begin;
}
+
+
inline
-bool IndexSet::IntervalAccessor::is_valid() const
+bool
+IndexSet::IntervalAccessor::is_valid() const
{
return index_set != nullptr && range_idx < index_set->n_intervals();
}
+
+
inline
-IndexSet::ElementIterator IndexSet::IntervalAccessor::begin() const
+IndexSet::ElementIterator
+IndexSet::IntervalAccessor::begin() const
{
Assert(is_valid(), ExcMessage("invalid iterator"));
- return IndexSet::ElementIterator(index_set, range_idx, index_set->ranges[range_idx].begin);
+ return IndexSet::ElementIterator(index_set, range_idx,
+ index_set->ranges[range_idx].begin);
}
+
+
inline
-IndexSet::ElementIterator IndexSet::IntervalAccessor::end() const
+IndexSet::ElementIterator
+IndexSet::IntervalAccessor::end() const
{
Assert(is_valid(), ExcMessage("invalid iterator"));
return index_set->end();
}
+
+
inline
IndexSet::size_type
IndexSet::IntervalAccessor::last() const
return index_set->ranges[range_idx].end-1;
}
-inline
-IndexSet::IntervalAccessor::IntervalAccessor(const IndexSet::IntervalAccessor &other)
- : index_set (other.index_set), range_idx(other.range_idx)
-{
- Assert( range_idx == numbers::invalid_dof_index || is_valid(), ExcMessage("invalid iterator"));
-}
+
inline
IndexSet::IntervalAccessor &
{
index_set = other.index_set;
range_idx = other.range_idx;
- Assert( range_idx == numbers::invalid_dof_index || is_valid(), ExcMessage("invalid iterator"));
+ Assert( range_idx == numbers::invalid_dof_index || is_valid(),
+ ExcMessage("invalid iterator"));
return *this;
}
+
+
inline
-bool IndexSet::IntervalAccessor::operator == (const IndexSet::IntervalAccessor &other) const
+bool
+IndexSet::IntervalAccessor::operator == (const IndexSet::IntervalAccessor &other) const
{
- Assert (index_set == other.index_set, ExcMessage("Can not compare accessors pointing to different IndexSets"));
+ Assert (index_set == other.index_set,
+ ExcMessage("Can not compare accessors pointing to different IndexSets"));
return range_idx == other.range_idx;
}
+
+
inline
-bool IndexSet::IntervalAccessor::operator < (const IndexSet::IntervalAccessor &other) const
+bool
+IndexSet::IntervalAccessor::operator < (const IndexSet::IntervalAccessor &other) const
{
- Assert (index_set == other.index_set, ExcMessage("Can not compare accessors pointing to different IndexSets"));
+ Assert (index_set == other.index_set,
+ ExcMessage("Can not compare accessors pointing to different IndexSets"));
return range_idx < other.range_idx;
}
+
+
inline
void IndexSet::IntervalAccessor::advance ()
{
- Assert(is_valid(), ExcMessage("Impossible to advance an IndexSet::IntervalIterator that is invalid"));
+ Assert (is_valid(),
+ ExcMessage("Impossible to advance an IndexSet::IntervalIterator that is invalid"));
++range_idx;
// set ourselves to invalid if we walk off the end
range_idx = numbers::invalid_dof_index;
}
+
/* IntervalIterator */
inline
-IndexSet::IntervalIterator::IntervalIterator(const IndexSet *idxset, const IndexSet::size_type range_idx)
- : accessor(idxset, range_idx)
+IndexSet::IntervalIterator::IntervalIterator(const IndexSet *idxset,
+ const IndexSet::size_type range_idx)
+ :
+ accessor(idxset, range_idx)
{}
+
+
inline
IndexSet::IntervalIterator::IntervalIterator()
- : accessor(nullptr)
+ :
+ accessor(nullptr)
{}
+
+
inline
IndexSet::IntervalIterator::IntervalIterator(const IndexSet *idxset)
- : accessor(idxset)
+ :
+ accessor(idxset)
{}
+
+
inline
IndexSet::IntervalIterator::IntervalIterator(const IndexSet::IntervalIterator &other)
- : accessor(other.accessor)
+ :
+ accessor(other.accessor)
{}
+
+
inline
IndexSet::IntervalIterator &
IndexSet::IntervalIterator::operator = (const IntervalIterator &other)
}
+
inline
IndexSet::IntervalIterator &
IndexSet::IntervalIterator::operator++ ()
return *this;
}
+
+
inline
IndexSet::IntervalIterator
IndexSet::IntervalIterator::operator++ (int)
return iter;
}
+
+
inline
const IndexSet::IntervalAccessor &
IndexSet::IntervalIterator::operator* () const
return accessor;
}
+
+
inline
const IndexSet::IntervalAccessor *
IndexSet::IntervalIterator::operator-> () const
return &accessor;
}
+
+
inline
-bool IndexSet::IntervalIterator::operator == (const IndexSet::IntervalIterator &other) const
+bool
+IndexSet::IntervalIterator::operator == (const IndexSet::IntervalIterator &other) const
{
return accessor == other.accessor;
}
+
+
inline
-bool IndexSet::IntervalIterator::operator != (const IndexSet::IntervalIterator &other) const
+bool
+IndexSet::IntervalIterator::operator != (const IndexSet::IntervalIterator &other) const
{
return !(*this == other);
}
+
+
inline
-bool IndexSet::IntervalIterator::operator < (const IndexSet::IntervalIterator &other) const
+bool
+IndexSet::IntervalIterator::operator < (const IndexSet::IntervalIterator &other) const
{
return accessor < other.accessor;
}
+
+
inline
-int IndexSet::IntervalIterator::operator - (const IndexSet::IntervalIterator &other) const
+int
+IndexSet::IntervalIterator::operator - (const IndexSet::IntervalIterator &other) const
{
- Assert (accessor.index_set == other.accessor.index_set, ExcMessage("Can not compare iterators belonging to different IndexSets"));
-
- const size_type lhs = (accessor.range_idx == numbers::invalid_dof_index) ? accessor.index_set->ranges.size() : accessor.range_idx;
- const size_type rhs = (other.accessor.range_idx == numbers::invalid_dof_index) ? accessor.index_set->ranges.size() : other.accessor.range_idx;
+ Assert (accessor.index_set == other.accessor.index_set,
+ ExcMessage("Can not compare iterators belonging to different IndexSets"));
+
+ const size_type lhs = (accessor.range_idx == numbers::invalid_dof_index)
+ ?
+ accessor.index_set->ranges.size()
+ :
+ accessor.range_idx;
+ const size_type rhs = (other.accessor.range_idx == numbers::invalid_dof_index)
+ ?
+ accessor.index_set->ranges.size()
+ :
+ other.accessor.range_idx;
if (lhs > rhs)
return static_cast<int>(lhs - rhs);
}
-/* ElementIterator */
-inline
-bool IndexSet::ElementIterator::is_valid() const
-{
- Assert(
- (range_idx == numbers::invalid_dof_index && idx == numbers::invalid_dof_index)
- ||
- (range_idx < index_set->ranges.size() && idx<index_set->ranges[range_idx].end)
- , ExcInternalError("Invalid ElementIterator state."));
-
- return range_idx < index_set->ranges.size() && idx<index_set->ranges[range_idx].end;
-}
+/* ElementIterator */
inline
-IndexSet::ElementIterator::ElementIterator(const IndexSet *idxset, const IndexSet::size_type range_idx, const IndexSet::size_type index)
- : index_set(idxset), range_idx(range_idx), idx(index)
+IndexSet::ElementIterator::
+ElementIterator(const IndexSet *idxset,
+ const IndexSet::size_type range_idx,
+ const IndexSet::size_type index)
+ :
+ index_set(idxset),
+ range_idx(range_idx),
+ idx(index)
{
Assert(range_idx < index_set->ranges.size(),
ExcMessage("Invalid range index for IndexSet::ElementIterator constructor."));
ExcInternalError("Invalid index argument for IndexSet::ElementIterator constructor."));
}
+
+
inline
IndexSet::ElementIterator::ElementIterator(const IndexSet *idxset)
- : index_set(idxset), range_idx(numbers::invalid_dof_index), idx(numbers::invalid_dof_index)
+ :
+ index_set(idxset),
+ range_idx(numbers::invalid_dof_index),
+ idx(numbers::invalid_dof_index)
{}
+
+
+inline
+bool
+IndexSet::ElementIterator::is_valid() const
+{
+ Assert((range_idx == numbers::invalid_dof_index && idx == numbers::invalid_dof_index)
+ ||
+ (range_idx < index_set->ranges.size() && idx<index_set->ranges[range_idx].end),
+ ExcInternalError("Invalid ElementIterator state."));
+
+ return (range_idx < index_set->ranges.size() &&
+ idx<index_set->ranges[range_idx].end);
+}
+
+
+
+
inline
IndexSet::size_type
IndexSet::ElementIterator::operator* () const
{
- Assert(is_valid(), ExcMessage("Impossible to dereference an IndexSet::ElementIterator that is invalid"));
+ Assert (is_valid(),
+ ExcMessage("Impossible to dereference an IndexSet::ElementIterator that is invalid"));
return idx;
}
+
+
inline
-bool IndexSet::ElementIterator::operator == (const IndexSet::ElementIterator &other) const
+bool
+IndexSet::ElementIterator::operator == (const IndexSet::ElementIterator &other) const
{
- Assert (index_set == other.index_set, ExcMessage("Can not compare iterators belonging to different IndexSets"));
+ Assert (index_set == other.index_set,
+ ExcMessage("Can not compare iterators belonging to different IndexSets"));
return range_idx == other.range_idx && idx==other.idx;
}
+
+
inline
-void IndexSet::ElementIterator::advance ()
+void
+IndexSet::ElementIterator::advance ()
{
- Assert(is_valid(), ExcMessage("Impossible to advance an IndexSet::ElementIterator that is invalid"));
+ Assert (is_valid(),
+ ExcMessage("Impossible to advance an IndexSet::ElementIterator that is invalid"));
if (idx < index_set->ranges[range_idx].end)
++idx;
// end of this range?
}
}
+
+
inline
IndexSet::ElementIterator &
IndexSet::ElementIterator::operator++ ()
return *this;
}
+
+
inline
IndexSet::ElementIterator
IndexSet::ElementIterator::operator++ (int)
return it;
}
+
+
inline
bool IndexSet::ElementIterator::operator != (const IndexSet::ElementIterator &other) const
{
return !(*this == other);
}
+
+
inline
bool IndexSet::ElementIterator::operator < (const IndexSet::ElementIterator &other) const
{
- Assert (index_set == other.index_set, ExcMessage("Can not compare iterators belonging to different IndexSets"));
+ Assert (index_set == other.index_set,
+ ExcMessage("Can not compare iterators belonging to different IndexSets"));
return range_idx < other.range_idx || (range_idx == other.range_idx && idx<other.idx);
}
+
+
inline
-std::ptrdiff_t IndexSet::ElementIterator::operator - (const IndexSet::ElementIterator &other) const
+std::ptrdiff_t
+IndexSet::ElementIterator::operator - (const IndexSet::ElementIterator &other) const
{
- Assert (index_set == other.index_set, ExcMessage("Can not compare iterators belonging to different IndexSets"));
+ Assert (index_set == other.index_set,
+ ExcMessage("Can not compare iterators belonging to different IndexSets"));
if (*this == other)
return 0;
if (!(*this < other))
{}
+
inline
IndexSet::Range::Range (const size_type i1,
const size_type i2)
{}
+
/* IndexSet itself */
+inline
+IndexSet::IndexSet ()
+ :
+ is_compressed (true),
+ index_space_size (0),
+ largest_range (numbers::invalid_unsigned_int)
+{}
+
+
+
+inline
+IndexSet::IndexSet (const size_type size)
+ :
+ is_compressed (true),
+ index_space_size (size),
+ largest_range (numbers::invalid_unsigned_int)
+{}
+
+
+
+inline
+IndexSet::IndexSet (IndexSet &&is)
+ :
+ ranges (std::move(is.ranges)),
+ is_compressed (is.is_compressed),
+ index_space_size (is.index_space_size),
+ largest_range (is.largest_range)
+{
+ is.ranges.clear ();
+ is.is_compressed = true;
+ is.index_space_size = 0;
+ is.largest_range = numbers::invalid_unsigned_int;
+
+ compress ();
+}
+
+
+
+inline
+IndexSet &IndexSet::operator= (IndexSet &&is)
+{
+ ranges = std::move (is.ranges);
+ is_compressed = is.is_compressed;
+ index_space_size = is.index_space_size;
+ largest_range = is.largest_range;
+
+ is.ranges.clear ();
+ is.is_compressed = true;
+ is.index_space_size = 0;
+ is.largest_range = numbers::invalid_unsigned_int;
+
+ compress ();
+
+ return *this;
+}
+
+
+
inline
IndexSet::ElementIterator IndexSet::begin() const
{
return end();
}
+
+
inline
IndexSet::ElementIterator IndexSet::at(const size_type global_index) const
{
}
+
inline
-IndexSet::ElementIterator IndexSet::end() const
+IndexSet::ElementIterator
+IndexSet::end() const
{
compress();
return IndexSet::ElementIterator(this);
}
+
inline
-IndexSet::IntervalIterator IndexSet::begin_intervals() const
+IndexSet::IntervalIterator
+IndexSet::begin_intervals() const
{
compress();
if (ranges.size()>0)
return end_intervals();
}
-inline
-IndexSet::IntervalIterator IndexSet::end_intervals() const
-{
- compress();
- return IndexSet::IntervalIterator(this);
-}
-
-
-
-inline
-IndexSet::IndexSet ()
- :
- is_compressed (true),
- index_space_size (0),
- largest_range (numbers::invalid_unsigned_int)
-{}
-
-
-
-inline
-IndexSet::IndexSet (const size_type size)
- :
- is_compressed (true),
- index_space_size (size),
- largest_range (numbers::invalid_unsigned_int)
-{}
-
-
-
-inline
-IndexSet::IndexSet (IndexSet &&is)
- :
- ranges (std::move(is.ranges)),
- is_compressed (is.is_compressed),
- index_space_size (is.index_space_size),
- largest_range (is.largest_range)
-{
- is.ranges.clear ();
- is.is_compressed = true;
- is.index_space_size = 0;
- is.largest_range = numbers::invalid_unsigned_int;
-
- compress ();
-}
-
inline
-IndexSet &IndexSet::operator= (IndexSet &&is)
+IndexSet::IntervalIterator
+IndexSet::end_intervals() const
{
- ranges = std::move (is.ranges);
- is_compressed = is.is_compressed;
- index_space_size = is.index_space_size;
- largest_range = is.largest_range;
-
- is.ranges.clear ();
- is.is_compressed = true;
- is.index_space_size = 0;
- is.largest_range = numbers::invalid_unsigned_int;
-
- compress ();
-
- return *this;
+ compress();
+ return IndexSet::IntervalIterator(this);
}
}
+
inline
bool
IndexSet::is_empty () const
}
+
inline
IndexSet::size_type
IndexSet::index_within_set (const size_type n) const