Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        public bool Test(IEdge e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            return(m_EdgePredicate.Test(e) &&
                   m_VertexPredicate.Test(e.Source) &&
                   m_VertexPredicate.Test(e.Target)
                   );
        }
Esempio n. 2
0
            /// <summary>
            /// Moves the cursor to the next Vertex.
            /// </summary>
            /// <returns>True if successful, false if the iteration ended.</returns>
            public bool MoveNext()
            {
                bool ok;

                do
                {
                    ok = m_Enumerator.MoveNext();
                    if (!ok)
                    {
                        return(false);
                    }
                }while(!m_Predicate.Test(m_Enumerator.Current));

                return(true);
            }
Esempio n. 3
0
        /// <summary>
        /// Returns the first vertex of the enumerable that matches the predicate.
        /// </summary>
        /// <param name="vertices">enumerable collection of <see cref="IVertex"/></param>
        /// <param name="pred">vertex predicate</param>
        /// <returns>first vertex if any, otherwise a null reference</returns>
        public static IVertex FirstVertexIf(IVertexEnumerable vertices, IVertexPredicate pred)
        {
            if (vertices == null)
            {
                throw new ArgumentNullException("vertices");
            }
            if (pred == null)
            {
                throw new ArgumentNullException("pred");
            }

            IVertexEnumerator en = vertices.GetEnumerator();

            while (en.MoveNext())
            {
                if (pred.Test(en.Current))
                {
                    return(en.Current);
                }
            }
            return(null);
        }
Esempio n. 4
0
        /// <summary>
        /// Returns the first vertex of the enumerable that matches the predicate.
        /// </summary>
        /// <param name="vertices">enumerable collection of <see cref="IVertex"/></param>
        /// <param name="pred">vertex predicate</param>
        /// <returns>first vertex if any, otherwise a null reference</returns>
        public static IVertex FirstVertexIf(IVertexEnumerable vertices, IVertexPredicate pred)
        {
            if (vertices==null)
                throw new ArgumentNullException("vertices");
            if (pred==null)
                throw new ArgumentNullException("pred");

            IVertexEnumerator en = vertices.GetEnumerator();
            while(en.MoveNext())
            {
                if (pred.Test(en.Current))
                    return en.Current;
            }
            return null;
        }