Mailinglist Archive: yast-commit (819 mails)

< Previous Next >
[yast-commit] r54506 - in /trunk/core/libycp/src: YCPList.cc YCPMap.cc include/ycp/ycpless.h
  • From: aschnell@xxxxxxxxxxxxxxxx
  • Date: Fri, 09 Jan 2009 13:49:18 -0000
  • Message-id: <E1LLHji-00015W-Rs@xxxxxxxxxxxxxxxx>
Author: aschnell
Date: Fri Jan 9 14:49:18 2009
New Revision: 54506

URL: http://svn.opensuse.org/viewcvs/yast?rev=54506&view=rev
Log:
- added ycp_not_equal_to

Modified:
trunk/core/libycp/src/YCPList.cc
trunk/core/libycp/src/YCPMap.cc
trunk/core/libycp/src/include/ycp/ycpless.h

Modified: trunk/core/libycp/src/YCPList.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPList.cc?rev=54506&r1=54505&r2=54506&view=diff
==============================================================================
--- trunk/core/libycp/src/YCPList.cc (original)
+++ trunk/core/libycp/src/YCPList.cc Fri Jan 9 14:49:18 2009
@@ -110,7 +110,7 @@

bool YCPListRep::contains (const YCPValue& value) const
{
- return find_if(begin(), end(), bind2nd(ycpequal_to(), value)) != end();
+ return find_if(begin(), end(), bind2nd(ycp_equal_to(), value)) != end();
}



Modified: trunk/core/libycp/src/YCPMap.cc
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/YCPMap.cc?rev=54506&r1=54505&r2=54506&view=diff
==============================================================================
--- trunk/core/libycp/src/YCPMap.cc (original)
+++ trunk/core/libycp/src/YCPMap.cc Fri Jan 9 14:49:18 2009
@@ -62,7 +62,7 @@
// default constructor for YCPValue.

YCPMap::iterator pos = stl_map.lower_bound(key);
- if (pos == stl_map.end() || !pos->first->equal(key))
+ if (pos == stl_map.end() || ycp_not_equal_to()(pos->first, key))
{
// pos is just a hint but can avoid a second search through the map
stl_map.insert(pos, YCPMap::value_type(key, value));

Modified: trunk/core/libycp/src/include/ycp/ycpless.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/core/libycp/src/include/ycp/ycpless.h?rev=54506&r1=54505&r2=54506&view=diff
==============================================================================
--- trunk/core/libycp/src/include/ycp/ycpless.h (original)
+++ trunk/core/libycp/src/include/ycp/ycpless.h Fri Jan 9 14:49:18 2009
@@ -57,12 +57,12 @@
* Compares two YCPValues and returns true if they are equal, false otherwise.
* Optionally the comparison is locale aware.
*/
-class ycpequal_to : public std::binary_function<YCPValue, YCPValue, bool>
+class ycp_equal_to : public std::binary_function<YCPValue, YCPValue, bool>
{

public:

- ycpequal_to(bool respect_locale = false) : respect_locale(respect_locale)
{}
+ ycp_equal_to(bool respect_locale = false) : respect_locale(respect_locale)
{}

bool operator()(const YCPValue& x, const YCPValue& y) const
{
@@ -76,4 +76,29 @@
};


+/*
+ * Global comparison functor usable as predicate for STL-algorithms.
+ *
+ * Compares two YCPValues and returns true if they are not equal, false
+ * otherwise. Optionally the comparison is locale aware.
+ */
+class ycp_not_equal_to : public std::binary_function<YCPValue, YCPValue, bool>
+{
+
+public:
+
+ ycp_not_equal_to(bool respect_locale = false) :
respect_locale(respect_locale) {}
+
+ bool operator()(const YCPValue& x, const YCPValue& y) const
+ {
+ return x->compare(y, respect_locale) != YO_EQUAL;
+ }
+
+private:
+
+ const bool respect_locale;
+
+};
+
+
#endif // ycpless_h

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages