[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [rocs] RocsCore/DataStructures/LinkedList: List should add new elements as head and not tail.
From: Andreas Cord-Landwehr <cordlandwehr () kde ! org>
Date: 2013-05-21 19:26:12
Message-ID: 20130521192612.79B02A6076 () git ! kde ! org
[Download RAW message or body]
Git commit beaa4e11fb2a0aa0ebdf24a59d00ec11c2544281 by Andreas Cord-Landwehr.
Committed on 20/05/2013 at 23:17.
Pushed by cordlandwehr into branch 'master'.
List should add new elements as head and not tail.
M +4 -23 RocsCore/DataStructures/LinkedList/ListStructure.cpp
http://commits.kde.org/rocs/beaa4e11fb2a0aa0ebdf24a59d00ec11c2544281
diff --git a/RocsCore/DataStructures/LinkedList/ListStructure.cpp \
b/RocsCore/DataStructures/LinkedList/ListStructure.cpp index 4079358..6c788e6 100644
--- a/RocsCore/DataStructures/LinkedList/ListStructure.cpp
+++ b/RocsCore/DataStructures/LinkedList/ListStructure.cpp
@@ -86,15 +86,11 @@ void Rocs::ListStructure::init()
connect(this, SIGNAL(changed()), this, SLOT(arrangeNodes()));
m_animationGroup = new QParallelAnimationGroup(parent());
- //FIXME only default data type considered
if (!dataList(0).isEmpty()) {
m_begin = boost::static_pointer_cast<ListNode>(dataList(0).first());
- } else {
- m_begin = boost::shared_ptr<ListNode>();
}
}
-
Rocs::ListStructure::~ListStructure()
{
// FIXME this is a memory leak, but fix this later
@@ -118,23 +114,11 @@ DataPtr Rocs::ListStructure::createData(const QString& name, \
int dataType)
ListNode::create(getDataStructure(), \
generateUniqueIdentifier(), dataType) );
n->setProperty("name", name);
-
- if (m_building) {
- return addData(n, dataType);;
- }
-
addData(n, dataType);
- if (m_begin) {
- boost::shared_ptr<ListNode> tmp = m_begin;
- while (tmp->next()) {
- tmp = tmp->next();
- }
- if (tmp) {
- tmp->pointTo(n);
- }
- } else {
- m_begin = n;
- }
+
+ // insert node as new head
+ n->pointTo(m_begin);
+ m_begin = n;
return n;
}
@@ -143,9 +127,6 @@ void Rocs::ListStructure::remove(DataPtr n)
if (m_begin == n) {
m_begin = boost::static_pointer_cast<ListNode>(n)->next();
}
- foreach(PointerPtr p, n->inPointerList()) {
- p->remove();
- }
DataStructure::remove(n);
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic