From c730d59f8a37e45dcbd2ae02886af11c3987f86c Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Tue, 14 Jun 2016 19:42:58 +0200 Subject: [PATCH] remove unnecessary copy/move ctors/opers= --- .../directed/AdjacencyListDirectedGraph.cpp | 53 +--------------- .../directed/AdjacencyListDirectedGraph.h | 6 -- .../directed/AdjacencyMatrixDirectedGraph.cpp | 53 +--------------- .../directed/AdjacencyMatrixDirectedGraph.h | 6 -- .../src/graph/directed/DirectedGraph.cpp | 46 +------------- alib2data/src/graph/directed/DirectedGraph.h | 6 -- .../AdjacencyListUndirectedGraph.cpp | 61 ++----------------- .../undirected/AdjacencyListUndirectedGraph.h | 6 -- .../AdjacencyMatrixUndirectedGraph.cpp | 61 ++----------------- .../AdjacencyMatrixUndirectedGraph.h | 6 -- .../src/graph/undirected/UndirectedGraph.cpp | 47 +------------- .../src/graph/undirected/UndirectedGraph.h | 6 -- 12 files changed, 16 insertions(+), 341 deletions(-) diff --git a/alib2data/src/graph/directed/AdjacencyListDirectedGraph.cpp b/alib2data/src/graph/directed/AdjacencyListDirectedGraph.cpp index b0f41f710f..c665d665fe 100644 --- a/alib2data/src/graph/directed/AdjacencyListDirectedGraph.cpp +++ b/alib2data/src/graph/directed/AdjacencyListDirectedGraph.cpp @@ -27,58 +27,7 @@ inline void listRemoveOne(std::list<T> &lst, const T &item) lst.erase(std::find(lst.begin(), lst.end(), item)); } -AdjacencyListDirectedGraph::AdjacencyListDirectedGraph() - - : DirectedGraph() -{ -} - -AdjacencyListDirectedGraph::~AdjacencyListDirectedGraph() noexcept -{ -} - -AdjacencyListDirectedGraph::AdjacencyListDirectedGraph( const AdjacencyListDirectedGraph & orig ) - - : DirectedGraph( orig ) - , succ( orig.succ ) - , pred( orig.pred ) - , edges( orig.edges ) -{ -} - -AdjacencyListDirectedGraph::AdjacencyListDirectedGraph( AdjacencyListDirectedGraph && orig ) - - : DirectedGraph( orig ) - , succ( std::move( orig.succ ) ) - , pred( std::move( orig.pred ) ) - , edges( std::move( orig.edges ) ) -{ -} - -AdjacencyListDirectedGraph & AdjacencyListDirectedGraph::operator=( const AdjacencyListDirectedGraph & orig ) -{ - if (this == &orig) - return *this; - - DirectedGraph::operator=( orig ); - this->succ = orig.succ; - this->pred = orig.pred; - this->edges = orig.edges; - - return *this; -} - -AdjacencyListDirectedGraph & AdjacencyListDirectedGraph::operator=( AdjacencyListDirectedGraph && orig ) -{ - if (this == &orig) - return *this; - - DirectedGraph::operator=( orig ); - this->succ = std::move( orig.succ ); - this->pred = std::move( orig.pred ); - this->edges = std::move( orig.edges ); - - return *this; +AdjacencyListDirectedGraph::AdjacencyListDirectedGraph() : DirectedGraph() { } AdjacencyListDirectedGraph::AdjacencyListDirectedGraph( const DirectedGraph & graph ) diff --git a/alib2data/src/graph/directed/AdjacencyListDirectedGraph.h b/alib2data/src/graph/directed/AdjacencyListDirectedGraph.h index a6367dedfb..9fefb96406 100644 --- a/alib2data/src/graph/directed/AdjacencyListDirectedGraph.h +++ b/alib2data/src/graph/directed/AdjacencyListDirectedGraph.h @@ -38,12 +38,6 @@ class AdjacencyListDirectedGraph : public DirectedGraph { public: AdjacencyListDirectedGraph(); - virtual ~AdjacencyListDirectedGraph() noexcept; - - AdjacencyListDirectedGraph( const AdjacencyListDirectedGraph & orig ); - AdjacencyListDirectedGraph( AdjacencyListDirectedGraph && orig ); - AdjacencyListDirectedGraph & operator=( const AdjacencyListDirectedGraph & orig ); - AdjacencyListDirectedGraph & operator=( AdjacencyListDirectedGraph && orig ); /// constructs an directed adjacency list from any representation of directed graph AdjacencyListDirectedGraph( const DirectedGraph & graph ); diff --git a/alib2data/src/graph/directed/AdjacencyMatrixDirectedGraph.cpp b/alib2data/src/graph/directed/AdjacencyMatrixDirectedGraph.cpp index 194e245b0e..130c858dc6 100644 --- a/alib2data/src/graph/directed/AdjacencyMatrixDirectedGraph.cpp +++ b/alib2data/src/graph/directed/AdjacencyMatrixDirectedGraph.cpp @@ -21,61 +21,14 @@ namespace graph { -AdjacencyMatrixDirectedGraph::AdjacencyMatrixDirectedGraph() - - : DirectedGraph() -{ -} - -AdjacencyMatrixDirectedGraph::~AdjacencyMatrixDirectedGraph() noexcept -{ -} - -AdjacencyMatrixDirectedGraph::AdjacencyMatrixDirectedGraph( const AdjacencyMatrixDirectedGraph & orig ) - - : DirectedGraph( orig ) - , adj( orig.adj ) - , edges( orig.edges ) -{ -} - -AdjacencyMatrixDirectedGraph::AdjacencyMatrixDirectedGraph( AdjacencyMatrixDirectedGraph && orig ) - - : DirectedGraph( orig ) - , adj( std::move( orig.adj ) ) - , edges( std::move( orig.edges ) ) -{ +AdjacencyMatrixDirectedGraph::AdjacencyMatrixDirectedGraph() : DirectedGraph() { } -AdjacencyMatrixDirectedGraph & AdjacencyMatrixDirectedGraph::operator=( const AdjacencyMatrixDirectedGraph & orig ) -{ - if (this == &orig) - return *this; - - this->adj = orig.adj; - this->edges = orig.edges; - - return *this; -} - -AdjacencyMatrixDirectedGraph & AdjacencyMatrixDirectedGraph::operator=( AdjacencyMatrixDirectedGraph && orig ) -{ - if (this == &orig) - return *this; - - this->adj = std::move( orig.adj ); - this->edges = std::move( orig.edges ); - - return *this; -} - -AdjacencyMatrixDirectedGraph::AdjacencyMatrixDirectedGraph( const DirectedGraph & graph ) -{ +AdjacencyMatrixDirectedGraph::AdjacencyMatrixDirectedGraph( const DirectedGraph & graph ) { DirectedGraph::fromDirected( graph ); } -AdjacencyMatrixDirectedGraph::AdjacencyMatrixDirectedGraph( const UndirectedGraph & ugraph ) -{ +AdjacencyMatrixDirectedGraph::AdjacencyMatrixDirectedGraph( const UndirectedGraph & ugraph ) { DirectedGraph::fromUndirected( ugraph ); } diff --git a/alib2data/src/graph/directed/AdjacencyMatrixDirectedGraph.h b/alib2data/src/graph/directed/AdjacencyMatrixDirectedGraph.h index 6631a9005a..a33a25f5b1 100644 --- a/alib2data/src/graph/directed/AdjacencyMatrixDirectedGraph.h +++ b/alib2data/src/graph/directed/AdjacencyMatrixDirectedGraph.h @@ -42,12 +42,6 @@ class AdjacencyMatrixDirectedGraph : public DirectedGraph { public: AdjacencyMatrixDirectedGraph(); - virtual ~AdjacencyMatrixDirectedGraph() noexcept; - - AdjacencyMatrixDirectedGraph( const AdjacencyMatrixDirectedGraph & orig ); - AdjacencyMatrixDirectedGraph( AdjacencyMatrixDirectedGraph && orig ); - AdjacencyMatrixDirectedGraph & operator=( const AdjacencyMatrixDirectedGraph & orig ); - AdjacencyMatrixDirectedGraph & operator=( AdjacencyMatrixDirectedGraph && orig ); /// constructs an directed adjacency matrix from any representation of directed graph AdjacencyMatrixDirectedGraph( const DirectedGraph & graph ); diff --git a/alib2data/src/graph/directed/DirectedGraph.cpp b/alib2data/src/graph/directed/DirectedGraph.cpp index 82e6398e2a..11859b97f7 100644 --- a/alib2data/src/graph/directed/DirectedGraph.cpp +++ b/alib2data/src/graph/directed/DirectedGraph.cpp @@ -25,53 +25,9 @@ namespace graph { -DirectedGraph::DirectedGraph() -{ -} - -DirectedGraph::~DirectedGraph() noexcept -{ +DirectedGraph::DirectedGraph() { } -DirectedGraph::DirectedGraph( const DirectedGraph & orig ) - - : nodeValues( orig.nodeValues ) - , edgeValues( orig.edgeValues ) - , embedding( orig.embedding ) -{ -} - -DirectedGraph::DirectedGraph( DirectedGraph && orig ) noexcept - - : nodeValues( std::move( orig.nodeValues ) ) - , edgeValues( std::move( orig.edgeValues ) ) - , embedding( std::move( orig.embedding ) ) -{ -} - -DirectedGraph & DirectedGraph::operator=( const DirectedGraph & orig ) -{ - if (this == &orig) - return *this; - - nodeValues = orig.nodeValues; - edgeValues = orig.edgeValues; - embedding = orig.embedding; - - return *this; -} - -DirectedGraph & DirectedGraph::operator=( DirectedGraph && orig ) noexcept -{ - if (this == &orig) - return *this; - - nodeValues = std::move( orig.nodeValues ); - edgeValues = std::move( orig.edgeValues ); - embedding = std::move( orig.embedding ); - - return *this; -} void DirectedGraph::fromDirected( const DirectedGraph & orig ) { int value; diff --git a/alib2data/src/graph/directed/DirectedGraph.h b/alib2data/src/graph/directed/DirectedGraph.h index 6785a0d16e..98a93aa092 100644 --- a/alib2data/src/graph/directed/DirectedGraph.h +++ b/alib2data/src/graph/directed/DirectedGraph.h @@ -28,12 +28,6 @@ class DirectedGraph : public GraphBase { public: DirectedGraph(); - virtual ~DirectedGraph() noexcept; - - DirectedGraph( const DirectedGraph & orig ); - DirectedGraph( DirectedGraph && orig ) noexcept; - DirectedGraph & operator=( const DirectedGraph & orig ); - DirectedGraph & operator=( DirectedGraph && orig ) noexcept; virtual GRAPH_TYPE getType() const override; virtual REPRESENTATION getRepresentation() const override = 0 ; diff --git a/alib2data/src/graph/undirected/AdjacencyListUndirectedGraph.cpp b/alib2data/src/graph/undirected/AdjacencyListUndirectedGraph.cpp index 071bbee0b7..e4266c1e0b 100644 --- a/alib2data/src/graph/undirected/AdjacencyListUndirectedGraph.cpp +++ b/alib2data/src/graph/undirected/AdjacencyListUndirectedGraph.cpp @@ -21,73 +21,22 @@ namespace graph { -AdjacencyListUndirectedGraph::AdjacencyListUndirectedGraph() - - : UndirectedGraph() -{ -} - -AdjacencyListUndirectedGraph::~AdjacencyListUndirectedGraph() noexcept -{ -} - -AdjacencyListUndirectedGraph::AdjacencyListUndirectedGraph( const AdjacencyListUndirectedGraph & orig ) - - : UndirectedGraph( orig ) - , adj( orig.adj ) - , edges( orig.edges ) -{ +AdjacencyListUndirectedGraph::AdjacencyListUndirectedGraph() : UndirectedGraph() { } -AdjacencyListUndirectedGraph::AdjacencyListUndirectedGraph( AdjacencyListUndirectedGraph && orig ) - - : UndirectedGraph( orig ) - , adj( std::move( orig.adj ) ) - , edges( std::move( orig.edges ) ) -{ -} - -AdjacencyListUndirectedGraph & AdjacencyListUndirectedGraph::operator=( const AdjacencyListUndirectedGraph & orig ) -{ - if (this == &orig) - return *this; - - UndirectedGraph::operator=( orig ); - this->adj = orig.adj; - this->edges = orig.edges; - - return *this; -} - -AdjacencyListUndirectedGraph & AdjacencyListUndirectedGraph::operator=( AdjacencyListUndirectedGraph && orig ) -{ - if (this == &orig) - return *this; - - UndirectedGraph::operator=( orig ); - this->adj = orig.adj; - this->edges = orig.edges; - - return *this; -} - -AdjacencyListUndirectedGraph::AdjacencyListUndirectedGraph( const UndirectedGraph & graph ) -{ +AdjacencyListUndirectedGraph::AdjacencyListUndirectedGraph( const UndirectedGraph & graph ) { UndirectedGraph::fromUndirected( graph ); } -AdjacencyListUndirectedGraph::AdjacencyListUndirectedGraph( const DirectedGraph & dgraph ) -{ +AdjacencyListUndirectedGraph::AdjacencyListUndirectedGraph( const DirectedGraph & dgraph ) { UndirectedGraph::fromDirected( dgraph ); } -GraphBase * AdjacencyListUndirectedGraph::clone() const -{ +GraphBase * AdjacencyListUndirectedGraph::clone() const { return new AdjacencyListUndirectedGraph( *this ); } -GraphBase * AdjacencyListUndirectedGraph::plunder() && -{ +GraphBase * AdjacencyListUndirectedGraph::plunder() && { return new AdjacencyListUndirectedGraph( std::move( *this ) ); } diff --git a/alib2data/src/graph/undirected/AdjacencyListUndirectedGraph.h b/alib2data/src/graph/undirected/AdjacencyListUndirectedGraph.h index 7537c4d48b..71adfad12f 100644 --- a/alib2data/src/graph/undirected/AdjacencyListUndirectedGraph.h +++ b/alib2data/src/graph/undirected/AdjacencyListUndirectedGraph.h @@ -41,12 +41,6 @@ class AdjacencyListUndirectedGraph : public UndirectedGraph { public: AdjacencyListUndirectedGraph(); - virtual ~AdjacencyListUndirectedGraph() noexcept; - - AdjacencyListUndirectedGraph( const AdjacencyListUndirectedGraph & orig ); - AdjacencyListUndirectedGraph( AdjacencyListUndirectedGraph && orig ); - AdjacencyListUndirectedGraph & operator=( const AdjacencyListUndirectedGraph & orig ); - AdjacencyListUndirectedGraph & operator=( AdjacencyListUndirectedGraph && orig ); /// constructs an undirected adjacency list from any representation of undirected graph AdjacencyListUndirectedGraph( const UndirectedGraph & graph ); diff --git a/alib2data/src/graph/undirected/AdjacencyMatrixUndirectedGraph.cpp b/alib2data/src/graph/undirected/AdjacencyMatrixUndirectedGraph.cpp index 0cc4ee2ad7..1fcd0ecbff 100644 --- a/alib2data/src/graph/undirected/AdjacencyMatrixUndirectedGraph.cpp +++ b/alib2data/src/graph/undirected/AdjacencyMatrixUndirectedGraph.cpp @@ -21,73 +21,22 @@ namespace graph { -AdjacencyMatrixUndirectedGraph::AdjacencyMatrixUndirectedGraph() - - : UndirectedGraph() -{ -} - -AdjacencyMatrixUndirectedGraph::~AdjacencyMatrixUndirectedGraph() noexcept -{ -} - -AdjacencyMatrixUndirectedGraph::AdjacencyMatrixUndirectedGraph( const AdjacencyMatrixUndirectedGraph & orig ) - - : UndirectedGraph( orig ) - , adj( orig.adj ) - , edges( orig.edges ) -{ +AdjacencyMatrixUndirectedGraph::AdjacencyMatrixUndirectedGraph() : UndirectedGraph() { } -AdjacencyMatrixUndirectedGraph::AdjacencyMatrixUndirectedGraph( AdjacencyMatrixUndirectedGraph && orig ) - - : UndirectedGraph( orig ) - , adj( std::move( orig.adj ) ) - , edges( std::move( orig.edges ) ) -{ -} - -AdjacencyMatrixUndirectedGraph & AdjacencyMatrixUndirectedGraph::operator=( const AdjacencyMatrixUndirectedGraph & orig ) -{ - if (this == &orig) - return *this; - - UndirectedGraph::operator=( orig ); - this->adj = orig.adj; - this->edges = orig.edges; - - return *this; -} - -AdjacencyMatrixUndirectedGraph & AdjacencyMatrixUndirectedGraph::operator=( AdjacencyMatrixUndirectedGraph && orig ) -{ - if (this == &orig) - return *this; - - UndirectedGraph::operator=( orig ); - this->adj = std::move( orig.adj ); - this->edges = std::move( orig.edges ); - - return *this; -} - -AdjacencyMatrixUndirectedGraph::AdjacencyMatrixUndirectedGraph( const UndirectedGraph & graph ) -{ +AdjacencyMatrixUndirectedGraph::AdjacencyMatrixUndirectedGraph( const UndirectedGraph & graph ) { UndirectedGraph::fromUndirected( graph ); } -AdjacencyMatrixUndirectedGraph::AdjacencyMatrixUndirectedGraph( const DirectedGraph & dgraph ) -{ +AdjacencyMatrixUndirectedGraph::AdjacencyMatrixUndirectedGraph( const DirectedGraph & dgraph ) { UndirectedGraph::fromDirected( dgraph ); } -GraphBase * AdjacencyMatrixUndirectedGraph::clone() const -{ +GraphBase * AdjacencyMatrixUndirectedGraph::clone() const { return new AdjacencyMatrixUndirectedGraph( *this ); } -GraphBase * AdjacencyMatrixUndirectedGraph::plunder() && -{ +GraphBase * AdjacencyMatrixUndirectedGraph::plunder() && { return new AdjacencyMatrixUndirectedGraph( std::move( *this ) ); } diff --git a/alib2data/src/graph/undirected/AdjacencyMatrixUndirectedGraph.h b/alib2data/src/graph/undirected/AdjacencyMatrixUndirectedGraph.h index 8b72bb6fd0..778bd684a7 100644 --- a/alib2data/src/graph/undirected/AdjacencyMatrixUndirectedGraph.h +++ b/alib2data/src/graph/undirected/AdjacencyMatrixUndirectedGraph.h @@ -44,12 +44,6 @@ class AdjacencyMatrixUndirectedGraph : public UndirectedGraph { public: AdjacencyMatrixUndirectedGraph(); - virtual ~AdjacencyMatrixUndirectedGraph() noexcept; - - AdjacencyMatrixUndirectedGraph( const AdjacencyMatrixUndirectedGraph & orig ); - AdjacencyMatrixUndirectedGraph( AdjacencyMatrixUndirectedGraph && orig ); - AdjacencyMatrixUndirectedGraph & operator=( const AdjacencyMatrixUndirectedGraph & orig ); - AdjacencyMatrixUndirectedGraph & operator=( AdjacencyMatrixUndirectedGraph && orig ); /// constructs an undirected adjacency matrix from any representation of undirected graph AdjacencyMatrixUndirectedGraph( const UndirectedGraph & graph ); diff --git a/alib2data/src/graph/undirected/UndirectedGraph.cpp b/alib2data/src/graph/undirected/UndirectedGraph.cpp index 2eb52bf99a..46807fb29c 100644 --- a/alib2data/src/graph/undirected/UndirectedGraph.cpp +++ b/alib2data/src/graph/undirected/UndirectedGraph.cpp @@ -26,52 +26,7 @@ namespace graph { -UndirectedGraph::UndirectedGraph() -{ -} - -UndirectedGraph::~UndirectedGraph() noexcept -{ -} - -UndirectedGraph::UndirectedGraph( const UndirectedGraph & orig ) - - : nodeValues( orig.nodeValues ) - , edgeValues( orig.edgeValues ) - , embedding( orig.embedding ) -{ -} - -UndirectedGraph::UndirectedGraph( UndirectedGraph && orig ) noexcept - - : nodeValues( std::move( orig.nodeValues ) ) - , edgeValues( std::move( orig.edgeValues ) ) - , embedding( std::move( orig.embedding ) ) -{ -} - -UndirectedGraph & UndirectedGraph::operator=( const UndirectedGraph & orig ) -{ - if (this == &orig) - return *this; - - this->nodeValues = orig.nodeValues; - this->edgeValues = orig.edgeValues; - this->embedding = orig.embedding; - - return *this; -} - -UndirectedGraph & UndirectedGraph::operator=( UndirectedGraph && orig ) noexcept -{ - if (this == &orig) - return *this; - - this->nodeValues = std::move( orig.nodeValues ); - this->edgeValues = std::move( orig.edgeValues ); - this->embedding = std::move( orig.embedding ); - - return *this; +UndirectedGraph::UndirectedGraph() { } GRAPH_TYPE UndirectedGraph::getType() const diff --git a/alib2data/src/graph/undirected/UndirectedGraph.h b/alib2data/src/graph/undirected/UndirectedGraph.h index 18e2197729..2bb99b472a 100644 --- a/alib2data/src/graph/undirected/UndirectedGraph.h +++ b/alib2data/src/graph/undirected/UndirectedGraph.h @@ -28,12 +28,6 @@ class UndirectedGraph : public GraphBase { public: UndirectedGraph(); - virtual ~UndirectedGraph() noexcept; - - UndirectedGraph( const UndirectedGraph & orig ); - UndirectedGraph( UndirectedGraph && orig ) noexcept; - UndirectedGraph & operator=( const UndirectedGraph & orig ); - UndirectedGraph & operator=( UndirectedGraph && orig ) noexcept; virtual GRAPH_TYPE getType() const override; virtual REPRESENTATION getRepresentation() const override = 0; -- GitLab