[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdeedu/kig/misc
From:       Dominique Devriese <devriese () kde ! org>
Date:       2003-08-31 23:07:31
[Download RAW message or body]

CVS commit by domi: 

add some handy algorithms


  M +22 -0     calcpaths.cc   1.13
  M +9 -0      calcpaths.h   1.9


--- kdeedu/kig/misc/calcpaths.cc  #1.12:1.13
@@ -180,2 +180,24 @@ Objects getAllParents( const Objects& ob
   return ret;
 }
+
+Objects getAllParents( Object* obj )
+{
+  return getAllParents( Objects( obj ) );
+}
+
+bool isChild( const Object* o, const Objects& os )
+{
+  using namespace std;
+  Objects cur( o->parents() );
+  while ( ! cur.empty() )
+  {
+    Objects next;
+    for ( Objects::const_iterator i = cur.begin(); i != cur.end(); ++i )
+    {
+      if ( os.contains( *i ) ) return true;
+      next.upush( (*i)->parents() );
+    };
+    cur = next;
+  };
+  return false;
+}

--- kdeedu/kig/misc/calcpaths.h  #1.8:1.9
@@ -55,4 +55,13 @@ Objects sideOfTreePath( const Objects& f
  */
 Objects getAllParents( const Objects& objs );
+/**
+ * @overload
+ */
+Objects getAllParents( Object* obj );
+
+/**
+ * Returns true if o is a descendant of any of the objects in os..
+ */
+bool isChild( const Object* o, const Objects& os );
 
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic