]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Introduce IndexSet::get_index_vector().
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 26 Jan 2023 23:07:09 +0000 (16:07 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 26 Jan 2023 23:07:09 +0000 (16:07 -0700)
include/deal.II/base/index_set.h
source/base/index_set.cc

index 500e19260aac3084303eaed1ccf4439f44fd0e0f..a0084d30ef10e786ac24a72721bf78f5ef70f1bd 100644 (file)
@@ -385,8 +385,22 @@ public:
   size_type
   pop_front();
 
+  /**
+   * Return a vector with all indices contained in this IndexSet. This
+   * vector may of course be quite large if the IndexSet stores many
+   * indices. (This may be true even if the IndexSet itself does not
+   * take up much memory: IndexSet stores indices in a compressed
+   * format in which contiguous ranges of indices are only stored using
+   * pairs of indices.)
+   */
+  std::vector<size_type>
+  get_index_vector() const;
+
   /**
    * Fill the given vector with all indices contained in this IndexSet.
+   *
+   * This function is equivalent to calling get_index_vector() and
+   * assigning the result to the @p indices argument.
    */
   void
   fill_index_vector(std::vector<size_type> &indices) const;
index 1a47ae2c019fa6f1c8b0a94d9a0852dcc1f33eac..d6aaab50aca75f79e50c0c24ff6415a12aed4a4c 100644 (file)
@@ -684,12 +684,12 @@ IndexSet::at(const size_type global_index) const
 
 
 
-void
-IndexSet::fill_index_vector(std::vector<size_type> &indices) const
+std::vector<size_type>
+IndexSet::get_index_vector() const
 {
   compress();
 
-  indices.clear();
+  std::vector<size_type> indices;
   indices.reserve(n_elements());
 
   for (const auto &range : ranges)
@@ -697,6 +697,16 @@ IndexSet::fill_index_vector(std::vector<size_type> &indices) const
       indices.push_back(entry);
 
   Assert(indices.size() == n_elements(), ExcInternalError());
+
+  return indices;
+}
+
+
+
+void
+IndexSet::fill_index_vector(std::vector<size_type> &indices) const
+{
+  indices = get_index_vector();
 }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.