← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2966: - back to ordinary vector<>:iterator for bodyContainer

 

------------------------------------------------------------
revno: 2966
committer: Bruno Chareyre <bruno.chareyre@xxxxxxxxxxx>
branch nick: trunk
timestamp: Wed 2011-11-23 17:48:27 +0100
message:
  - back to ordinary vector<>:iterator for bodyContainer
modified:
  core/BodyContainer.hpp


--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'core/BodyContainer.hpp'
--- core/BodyContainer.hpp	2011-11-23 12:05:49 +0000
+++ core/BodyContainer.hpp	2011-11-23 16:48:27 +0000
@@ -64,13 +64,19 @@
 		class smart_iterator : public ContainerT::iterator {
 			public:
 			ContainerT::iterator end;
-			smart_iterator& operator++() {do {ContainerT::iterator::operator++();} while (!(this->operator*()) && end!=(*this)); return *this;}
+			smart_iterator& operator++() {
+				ContainerT::iterator::operator++();
+				while (!(this->operator*()) && end!=(*this)){
+					ContainerT::iterator::operator++();}
+				return *this;}
 			smart_iterator operator++(int) {smart_iterator temp(*this); operator++(); return temp;}
 			smart_iterator& operator=(const ContainerT::iterator& rhs) {ContainerT::iterator::operator=(rhs); return *this;}
 		};
 
-		typedef smart_iterator iterator;
-		typedef const smart_iterator const_iterator;
+		typedef ContainerT::iterator iterator;
+		typedef ContainerT::const_iterator const_iterator;
+// 		typedef smart_iterator iterator;
+// 		typedef const smart_iterator const_iterator;
 
 		BodyContainer();
 		virtual ~BodyContainer();
@@ -79,10 +85,15 @@
 	
 		// mimick some STL api
 		void clear();
-		iterator begin() { iterator temp; temp=(body.begin()); temp.end=(body.end()); return temp;}
-		iterator end() { iterator temp; temp= body.end(); return temp;}
-		const_iterator begin() const { return begin();}
-		const_iterator end() const { return end();}
+		iterator begin() { return body.begin(); }
+		iterator end() { return body.end(); }
+		const_iterator begin() const { return body.begin(); }
+		const_iterator end() const { return body.end(); }
+// 		//with smart iterators
+// 		iterator begin() { iterator temp; temp=(body.begin()); temp.end=(body.end()); return temp;}
+// 		iterator end() { iterator temp; temp= body.end(); return temp;}
+// 		const_iterator begin() const { return begin();}
+// 		const_iterator end() const { return end();}
 
 		size_t size() const { return body.size(); }
 		shared_ptr<Body>& operator[](unsigned int id){ return body[id];}