Author: aschnell
Date: Wed Jan 7 12:38:39 2009
New Revision: 54418
URL: http://svn.opensuse.org/viewcvs/yast?rev=54418&view=rev
Log:
- replace class YCPListIterator with typedef
Modified:
trunk/core/libycp/src/YCPList.cc
trunk/core/libycp/src/include/ycp/YCPList.h
Modified: trunk/core/libycp/src/YCPList.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPList.cc?rev=54418&r1=54417&r2=54418&view=diff
==============================================================================
--- trunk/core/libycp/src/YCPList.cc (original)
+++ trunk/core/libycp/src/YCPList.cc Wed Jan 7 12:38:39 2009
@@ -182,14 +182,14 @@
}
-YCPListIterator
+YCPListRep::const_iterator
YCPListRep::begin() const
{
return elements.begin();
}
-YCPListIterator
+YCPListRep::const_iterator
YCPListRep::end() const
{
return elements.end();
Modified: trunk/core/libycp/src/include/ycp/YCPList.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/YCPList.h?rev=54418&r1=54417&r2=54418&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/YCPList.h (original)
+++ trunk/core/libycp/src/include/ycp/YCPList.h Wed Jan 7 12:38:39 2009
@@ -10,10 +10,11 @@
| (C) SuSE GmbH |
\----------------------------------------------------------------------/
- File: YCPList.h
+ File: YCPList.h
- Author: Mathias Kettner
- Maintainer: Thomas Roelz
+ Author: Mathias Kettner
+ Arvin Schnell
+ Maintainer: Thomas Roelz
/-*/
// -*- c++ -*-
@@ -22,12 +23,9 @@
#define YCPList_h
-#include <iterator>
#include "YCPValue.h"
-typedef vector<YCPValue> YCPValueList;
-class YCPListIterator;
class YCPCodeCompare;
@@ -45,10 +43,20 @@
*/
class YCPListRep : public YCPValueRep
{
+protected:
+
+ typedef vector<YCPValue> YCPValueList;
+
+ typedef YCPValueList::iterator iterator;
+ typedef YCPValueList::const_iterator const_iterator;
+
+ friend class YCPList;
+
+private:
+
YCPValueList elements;
protected:
- friend class YCPList;
/**
* Creates a new and empty list of type [ value ]
@@ -61,6 +69,7 @@
~YCPListRep() {}
public:
+
/**
* Returns the number of elements in the list.
*/
@@ -144,18 +153,16 @@
YCPValue value(int n) const;
/**
- * Returns a bidirectional STL iterator for the YCPList that
- * is positioned at the first value pair in the list.
- * (suitable for iterating over all entries)
+ * Returns a random access iterator for the YCPList that
+ * is positioned at the first value in the list.
*/
- YCPListIterator begin() const;
+ const_iterator begin() const;
/**
- * Returns a bidirectional STL iterator for the YCPList that
- * is positioned BEHIND the last value pair in the list.
- * (suitable for iterating over all entries)
+ * Returns a random access iterator for the YCPList that
+ * is positioned behind the last value in the list.
*/
- YCPListIterator end() const;
+ const_iterator end() const;
/**
* Compares two YCPLists for equality, greaterness or smallerness.
@@ -204,58 +211,6 @@
};
-/**
- * @short Iterator for YCPList values.
- */
-class YCPListIterator
-{
- friend class YCPListRep;
-
- YCPValueList::const_iterator position;
-
-public:
-
- typedef std::bidirectional_iterator_tag iterator_category;
- typedef ptrdiff_t difference_type;
- typedef const YCPValue value_type;
- typedef const YCPValue* pointer;
- typedef const YCPValue& reference;
-
-protected:
-
- YCPListIterator(YCPValueList::const_iterator position)
- : position(position) {}
-
-public:
-
- /**
- * Return the value of the current position.
- */
- reference operator*() const { return position.operator*(); }
-
- /**
- * Check for equality.
- */
- friend bool operator==(const YCPListIterator &x, const YCPListIterator &y) {
- return x.position == y.position;
- }
-
- /**
- * Check for inequality.
- */
- friend bool operator!=(const YCPListIterator &x, const YCPListIterator &y) {
- return !(x == y);
- }
-
- /**
- * Advance to the next position.
- */
- void operator++() { ++position; }
- void operator++(int) { ++position; }
-
-};
-
-
#define CONST_ELEMENT (static_cast(element))
#define ELEMENT (const_cast(static_cast(this->writeCopy())))
@@ -268,7 +223,12 @@
class YCPList : public YCPValue
{
DEF_COW_COMMON(List, Value);
+
public:
+
+ typedef YCPListRep::YCPValueList::iterator iterator;
+ typedef YCPListRep::YCPValueList::const_iterator const_iterator;
+
YCPList() : YCPValue(new YCPListRep()) {}
YCPList(bytecodeistream & str);
@@ -287,8 +247,8 @@
YCPList functionalAdd(const YCPValue& value, bool prepend = false) const
{ return CONST_ELEMENT->functionalAdd (value, prepend); }
YCPValue value(int n) const { return CONST_ELEMENT->value (n); }
- YCPListIterator begin() const { return CONST_ELEMENT->begin(); }
- YCPListIterator end() const { return CONST_ELEMENT->end(); }
+ const_iterator begin() const { return CONST_ELEMENT->begin(); }
+ const_iterator end() const { return CONST_ELEMENT->end(); }
string commaList() const { return CONST_ELEMENT->commaList (); }
};
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org