[PPL-devel] [GIT] ppl/ppl(sparse_matrices): CO_Tree: inline simple methods.

Marco Poletti poletti.marco at gmail.com
Tue Apr 13 22:36:02 CEST 2010


Module: ppl/ppl
Branch: sparse_matrices
Commit: 68851b8fbcc8146aec0dc9b98eee8846793e4267
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=68851b8fbcc8146aec0dc9b98eee8846793e4267

Author: Marco Poletti <poletti.marco at gmail.com>
Date:   Tue Apr 13 18:43:07 2010 +0200

CO_Tree: inline simple methods.

---

 src/CO_Tree.cc         |  101 ------------------------------------------------
 src/CO_Tree.inlines.hh |  100 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 100 insertions(+), 101 deletions(-)

diff --git a/src/CO_Tree.cc b/src/CO_Tree.cc
index bb600bb..d39529a 100644
--- a/src/CO_Tree.cc
+++ b/src/CO_Tree.cc
@@ -26,13 +26,6 @@ site: http://www.cs.unipr.it/ppl/ . */
 
 namespace PPL = Parma_Polyhedra_Library;
 
-PPL::CO_Tree::CO_Tree() {
-
-  init(0);
-
-  PPL_ASSERT(OK());
-}
-
 PPL::CO_Tree::CO_Tree(const std::vector<data_type>& v) {
 
   dimension_type n = 0;
@@ -267,27 +260,6 @@ PPL::CO_Tree::init(dimension_type reserved_size1) {
   PPL_ASSERT(structure_OK());
 }
 
-PPL::CO_Tree::~CO_Tree() {
-
-  PPL_ASSERT(OK());
-
-  if (level != NULL)
-    delete [] level;
-
-  if (data != NULL)
-    delete [] data;
-}
-
-PPL::dimension_type
-PPL::CO_Tree::external_memory_in_bytes() const {
-  dimension_type size = 0;
-  // Adding the size of data[]
-  size += (reserved_size + 1)*sizeof(data[0]);
-  // Adding the size of level[]
-  size += max_depth*sizeof(level[0]);
-  return size;
-}
-
 void
 PPL::CO_Tree::move_data_from(CO_Tree& tree) {
   PPL_ASSERT(size == 0);
@@ -630,24 +602,6 @@ PPL::CO_Tree::rebalance(inorder_iterator& itr, dimension_type key,
   PPL_ASSERT(OK());
 }
 
-bool
-PPL::CO_Tree::erase(dimension_type key) {
-  PPL_ASSERT(key != unused_index);
-
-  if (size == 0)
-    return false;
-
-  inorder_iterator itr(&*this);
-  lower_bound(itr, key);
-
-  if (itr->first != key)
-    return false;
-
-  erase(itr);
-
-  return true;
-}
-
 void
 PPL::CO_Tree::erase(inorder_iterator& itr) {
   PPL_ASSERT(!itr.is_before_begin());
@@ -976,58 +930,3 @@ PPL::CO_Tree
 
   PPL_ASSERT(added_key);
 }
-
-
-PPL::CO_Tree::inorder_iterator&
-PPL::CO_Tree::inorder_iterator::operator=(const inorder_iterator& itr2) {
-  tree = itr2.tree;
-  if (tree != 0) {
-    at_end = itr2.at_end;
-    before_begin = itr2.before_begin;
-    if (!at_end && !before_begin) {
-      d = itr2.d;
-      i = itr2.i;
-      for (dimension_type i = 1; i <= itr2.d; ++i)
-        pos[i] = itr2.pos[i];
-    }
-  }
-
-  return *this;
-}
-
-
-PPL::CO_Tree::inorder_const_iterator&
-PPL::CO_Tree::inorder_const_iterator
-::operator=(const inorder_const_iterator& itr2) {
-  tree = itr2.tree;
-  if (tree != 0) {
-    at_end = itr2.at_end;
-    before_begin = itr2.before_begin;
-    if (!at_end && !before_begin) {
-      d = itr2.d;
-      i = itr2.i;
-      for (dimension_type i = 1; i <= itr2.d; ++i)
-        pos[i] = itr2.pos[i];
-    }
-  }
-
-  return *this;
-}
-
-PPL::CO_Tree::inorder_const_iterator&
-PPL::CO_Tree::inorder_const_iterator
-::operator=(const inorder_iterator& itr2) {
-  tree = itr2.tree;
-  if (tree != 0) {
-    at_end = itr2.at_end;
-    before_begin = itr2.before_begin;
-    if (!at_end && !before_begin) {
-      d = itr2.d;
-      i = itr2.i;
-      for (dimension_type i = 1; i <= itr2.d; ++i)
-        pos[i] = itr2.pos[i];
-    }
-  }
-
-  return *this;
-}
diff --git a/src/CO_Tree.inlines.hh b/src/CO_Tree.inlines.hh
index 77e712a..bfad42f 100644
--- a/src/CO_Tree.inlines.hh
+++ b/src/CO_Tree.inlines.hh
@@ -31,6 +31,13 @@ site: http://www.cs.unipr.it/ppl/ . */
 
 namespace Parma_Polyhedra_Library {
 
+inline
+CO_Tree::CO_Tree() {
+
+  init(0);
+
+  PPL_ASSERT(OK());
+}
 
 inline
 CO_Tree::CO_Tree(const CO_Tree& x) {
@@ -60,6 +67,28 @@ CO_Tree::operator=(const CO_Tree& x) {
   return *this;
 }
 
+inline
+CO_Tree::~CO_Tree() {
+
+  PPL_ASSERT(OK());
+
+  if (level != NULL)
+    delete [] level;
+
+  if (data != NULL)
+    delete [] data;
+}
+
+inline dimension_type
+CO_Tree::external_memory_in_bytes() const {
+  dimension_type size = 0;
+  // Adding the size of data[]
+  size += (reserved_size + 1)*sizeof(data[0]);
+  // Adding the size of level[]
+  size += max_depth*sizeof(level[0]);
+  return size;
+}
+
 inline bool
 CO_Tree::empty() const {
   return size == 0;
@@ -124,6 +153,24 @@ CO_Tree::insert(dimension_type key, const data_type& value) {
   PPL_ASSERT(OK());
 }
 
+inline bool
+CO_Tree::erase(dimension_type key) {
+  PPL_ASSERT(key != unused_index);
+
+  if (size == 0)
+    return false;
+
+  inorder_iterator itr(&*this);
+  lower_bound(itr, key);
+
+  if (itr->first != key)
+    return false;
+
+  erase(itr);
+
+  return true;
+}
+
 inline void
 CO_Tree::rebuild_level_data(dimension_type max_depth) {
   level = new level_data[max_depth];
@@ -609,6 +656,23 @@ CO_Tree::inorder_iterator::get_previous_value() {
   }
 }
 
+inline CO_Tree::inorder_iterator&
+CO_Tree::inorder_iterator::operator=(const inorder_iterator& itr2) {
+  tree = itr2.tree;
+  if (tree != 0) {
+    at_end = itr2.at_end;
+    before_begin = itr2.before_begin;
+    if (!at_end && !before_begin) {
+      d = itr2.d;
+      i = itr2.i;
+      for (dimension_type i = 1; i <= itr2.d; ++i)
+        pos[i] = itr2.pos[i];
+    }
+  }
+
+  return *this;
+}
+
 
 inline
 CO_Tree::inorder_const_iterator::inorder_const_iterator(const CO_Tree* tree1)
@@ -972,6 +1036,42 @@ CO_Tree::inorder_const_iterator::get_previous_value() {
   }
 }
 
+inline CO_Tree::inorder_const_iterator&
+CO_Tree::inorder_const_iterator
+::operator=(const inorder_const_iterator& itr2) {
+  tree = itr2.tree;
+  if (tree != 0) {
+    at_end = itr2.at_end;
+    before_begin = itr2.before_begin;
+    if (!at_end && !before_begin) {
+      d = itr2.d;
+      i = itr2.i;
+      for (dimension_type i = 1; i <= itr2.d; ++i)
+        pos[i] = itr2.pos[i];
+    }
+  }
+
+  return *this;
+}
+
+inline CO_Tree::inorder_const_iterator&
+CO_Tree::inorder_const_iterator
+::operator=(const inorder_iterator& itr2) {
+  tree = itr2.tree;
+  if (tree != 0) {
+    at_end = itr2.at_end;
+    before_begin = itr2.before_begin;
+    if (!at_end && !before_begin) {
+      d = itr2.d;
+      i = itr2.i;
+      for (dimension_type i = 1; i <= itr2.d; ++i)
+        pos[i] = itr2.pos[i];
+    }
+  }
+
+  return *this;
+}
+
 } // namespace Parma_Polyhedra_Library
 
 #endif // !defined(PPL_CO_Tree_inlines_hh)




More information about the PPL-devel mailing list