From 52cae605f443e7b3e165ddcdd880d5c8e5fff835 Mon Sep 17 00:00:00 2001 From: Paul Jungeblut Date: Sun, 19 Mar 2017 15:58:59 +0100 Subject: Slight changes to suffix tree and adding implicit cartesian STL tree. --- datastructures/datastructures.tex | 3 +++ datastructures/stlRope.cpp | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 datastructures/stlRope.cpp (limited to 'datastructures') diff --git a/datastructures/datastructures.tex b/datastructures/datastructures.tex index 4267090..9018cd5 100644 --- a/datastructures/datastructures.tex +++ b/datastructures/datastructures.tex @@ -17,3 +17,6 @@ Dazu: Offset in den inneren Knoten des Baums speichern. \subsection{STL-Tree} \lstinputlisting{datastructures/stlTree.cpp} + +\subsection{STL-Rope} +\lstinputlisting{datastructures/stlRope.cpp} diff --git a/datastructures/stlRope.cpp b/datastructures/stlRope.cpp new file mode 100644 index 0000000..9179a60 --- /dev/null +++ b/datastructures/stlRope.cpp @@ -0,0 +1,8 @@ +#include +using namespace __gnu_cxx; +rope v; // Wie normaler Container. +v.push_back(num); // O(log(n)) +rope sub = v.substr(start, length); // O(log(n)) +v.erase(start, length); // O(log(n)) +v.insert(v.mutable_begin() + offset, sub); // O(log(n)) +for(auto it = v.mutable_begin(); it != v.mutable_end(); it++) {...} -- cgit v1.2.3