From 412cfd323518b0b56f0900e72a932b409dfb707a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6=20Fahlke?= <jorrit@jorrit.de>
Date: Mon, 14 May 2018 15:36:59 +0200
Subject: [PATCH] [cleanup] Remove base_array and base_array_window.

These classes are internal to ISTL and used nowhere in ISTL.

Note: `base_array_unmanaged` is used internally by `BlockVector`, `Matrix`,
and `VariableBlockVector` and is thus not removed.
---
 dune/istl/basearray.hh          | 242 --------------------------------
 dune/istl/test/CMakeLists.txt   |   2 -
 dune/istl/test/basearraytest.cc |  18 ---
 3 files changed, 262 deletions(-)
 delete mode 100644 dune/istl/test/basearraytest.cc

diff --git a/dune/istl/basearray.hh b/dune/istl/basearray.hh
index cce76e362..fbbff85a7 100644
--- a/dune/istl/basearray.hh
+++ b/dune/istl/basearray.hh
@@ -279,248 +279,6 @@ namespace Imp {
 
 
 
-  /**  \brief Extend base_array_unmanaged by functions to manipulate
-
-           This container has *NO* memory management at all,
-           copy constuctor, assignment and destructor are all default.
-           A container can be constructed as empty or from a given pointer
-       and size. This class is used to implement a view into a larger
-       array.
-
-           You can copy such an object to a base_array to make a real copy.
-
-           Error checking: no error checking is provided normally.
-           Setting the compile time switch DUNE_ISTL_WITH_CHECKING
-           enables error checking.
-   \internal This class is an implementation detail, and should not be used outside of dune-istl.
-   */
-  template<class B, class A=std::allocator<B> >
-  class base_array_window : public base_array_unmanaged<B,A>
-  {
-  public:
-
-    //===== type definitions and constants
-
-    //! export the type representing the components
-    typedef B member_type;
-
-    //! export the allocator type
-    typedef A allocator_type;
-
-    //! make iterators available as types
-    typedef typename base_array_unmanaged<B,A>::iterator iterator;
-
-    //! make iterators available as types
-    typedef typename base_array_unmanaged<B,A>::const_iterator const_iterator;
-
-    //! The type used for the index access
-    typedef typename base_array_unmanaged<B,A>::size_type size_type;
-
-    //! The type used for the difference between two iterator positions
-    typedef typename A::difference_type difference_type;
-
-    //===== constructors and such
-
-    //! makes empty array
-    base_array_window ()
-      : base_array_unmanaged<B,A>()
-    {   }
-
-    //! make array from given pointer and size
-    base_array_window (B* _p, size_type _n)
-      : base_array_unmanaged<B,A>(_n ,_p)
-    {}
-
-    //===== window manipulation methods
-
-    //! set pointer and length
-    void set (size_type _n, B* _p)
-    {
-      this->n = _n;
-      this->p = _p;
-    }
-
-    //! advance pointer by newsize elements and then set size to new size
-    void advance (difference_type newsize)
-    {
-      this->p += this->n;
-      this->n = newsize;
-    }
-
-    //! increment pointer by offset and set size
-    void move (difference_type offset, size_type newsize)
-    {
-      this->p += offset;
-      this->n = newsize;
-    }
-
-    //! increment pointer by offset, leave size
-    void move (difference_type offset)
-    {
-      this->p += offset;
-    }
-
-    //! return the pointer
-    B* getptr ()
-    {
-      return this->p;
-    }
-  };
-
-
-
-  /**  \brief  This container extends base_array_unmanaged by memory management
-        with the usual copy semantics providing the full range of
-        copy constructor, destructor and assignment operators.
-
-            You can make
-
-        - empty array
-        - array with n components dynamically allocated
-        - resize an array with complete loss of data
-        - assign/construct from a base_array_window to make a copy of the data
-
-            Error checking: no error checking is provided normally.
-            Setting the compile time switch DUNE_ISTL_WITH_CHECKING
-            enables error checking.
-   \internal This class is an implementation detail, and should not be used outside of dune-istl.
-   */
-  template<class B, class A=std::allocator<B> >
-  class base_array : public base_array_unmanaged<B,A>
-  {
-  public:
-
-    //===== type definitions and constants
-
-    //! export the type representing the components
-    typedef B member_type;
-
-    //! export the allocator type
-    typedef A allocator_type;
-
-    //! make iterators available as types
-    typedef typename base_array_unmanaged<B,A>::iterator iterator;
-
-    //! make iterators available as types
-    typedef typename base_array_unmanaged<B,A>::const_iterator const_iterator;
-
-    //! The type used for the index access
-    typedef typename base_array_unmanaged<B,A>::size_type size_type;
-
-    //! The type used for the difference between two iterator positions
-    typedef typename A::difference_type difference_type;
-
-    //===== constructors and such
-
-    //! makes empty array
-    base_array ()
-      : base_array_unmanaged<B,A>()
-    {}
-
-    //! make array with _n components
-    base_array (size_type _n)
-      : base_array_unmanaged<B,A>(_n, 0)
-    {
-      if (this->n>0) {
-        this->p = allocator_.allocate(this->n);
-        new (this->p)B[this->n];
-      } else
-      {
-        this->n = 0;
-        this->p = 0;
-      }
-    }
-
-    //! copy constructor
-    base_array (const base_array& a)
-    {
-      // allocate memory with same size as a
-      this->n = a.n;
-
-      if (this->n>0) {
-        this->p = allocator_.allocate(this->n);
-        new (this->p)B[this->n];
-      } else
-      {
-        this->n = 0;
-        this->p = 0;
-      }
-
-      // and copy elements
-      for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
-    }
-
-    //! free dynamic memory
-    ~base_array ()
-    {
-      if (this->n>0) {
-        int i=this->n;
-        while (i)
-          this->p[--i].~B();
-        allocator_.deallocate(this->p,this->n);
-      }
-    }
-
-    //! reallocate array to given size, any data is lost
-    void resize (size_type _n)
-    {
-      if (this->n==_n) return;
-
-      if (this->n>0) {
-        int i=this->n;
-        while (i)
-          this->p[--i].~B();
-        allocator_.deallocate(this->p,this->n);
-      }
-      this->n = _n;
-      if (this->n>0) {
-        this->p = allocator_.allocate(this->n);
-        new (this->p)B[this->n];
-      } else
-      {
-        this->n = 0;
-        this->p = 0;
-      }
-    }
-
-    //! assignment
-    base_array& operator= (const base_array& a)
-    {
-      if (&a!=this)     // check if this and a are different objects
-      {
-        // adjust size of array
-        if (this->n!=a.n)           // check if size is different
-        {
-          if (this->n>0) {
-            int i=this->n;
-            while (i)
-              this->p[--i].~B();
-            allocator_.deallocate(this->p,this->n);                     // delete old memory
-          }
-          this->n = a.n;
-          if (this->n>0) {
-            this->p = allocator_.allocate(this->n);
-            new (this->p)B[this->n];
-          } else
-          {
-            this->n = 0;
-            this->p = 0;
-          }
-        }
-        // copy data
-        for (size_type i=0; i<this->n; i++) this->p[i]=a.p[i];
-      }
-      return *this;
-    }
-
-  protected:
-
-    A allocator_;
-  };
-
-
-
-
   /** \brief A simple array container with non-consecutive index set.
 
        Elements in the array are of type B. This class provides
diff --git a/dune/istl/test/CMakeLists.txt b/dune/istl/test/CMakeLists.txt
index af89a6b57..58a511fb4 100644
--- a/dune/istl/test/CMakeLists.txt
+++ b/dune/istl/test/CMakeLists.txt
@@ -2,8 +2,6 @@
 install(FILES vectortest.hh
         DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/istl/test)
 
-dune_add_test(SOURCES basearraytest.cc)
-
 dune_add_test(SOURCES bcrsassigntest.cc)
 
 dune_add_test(SOURCES bcrsnormtest.cc)
diff --git a/dune/istl/test/basearraytest.cc b/dune/istl/test/basearraytest.cc
deleted file mode 100644
index aab13c5e7..000000000
--- a/dune/istl/test/basearraytest.cc
+++ /dev/null
@@ -1,18 +0,0 @@
-// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
-// vi: set et ts=4 sw=2 sts=2:
-#include "config.h"
-
-#include <dune/istl/basearray.hh>
-
-using namespace Dune;
-
-int main()
-{
-  Imp::base_array<double> v1(10);
-  Imp::base_array<double> v2 = v1;
-
-  v1.resize(20);
-
-  v1 = v2;
-
-}
-- 
GitLab