当前位置: 首页>>代码示例>>C#>>正文


C# Predicate.evaluate方法代码示例

本文整理汇总了C#中Predicate.evaluate方法的典型用法代码示例。如果您正苦于以下问题:C# Predicate.evaluate方法的具体用法?C# Predicate.evaluate怎么用?C# Predicate.evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Predicate的用法示例。


在下文中一共展示了Predicate.evaluate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: find

 /**
  * Finds the first element in the given collection which matches the given predicate.
  * <p>
  * If the input collection or predicate is null, or no element of the collection
  * matches the predicate, null is returned.
  *
  * @param collection  the collection to search, may be null
  * @param predicate  the predicate to use, may be null
  * @return the first element of the collection which matches the predicate or null if none could be found
  */
 public static Object find(java.util.Collection<Object> collection, Predicate predicate)
 {
     if (collection != null && predicate != null)
     {
         for (java.util.Iterator<Object> iter = collection.iterator(); iter.hasNext(); )
         {
             Object item = iter.next();
             if (predicate.evaluate(item))
             {
                 return item;
             }
         }
     }
     return null;
 }
开发者ID:gadfly,项目名称:nofs,代码行数:25,代码来源:org.apache.commons.collections.CollectionUtils.cs

示例2: filter

 /**
  * Filter the collection by applying a Predicate to each element. If the
  * predicate returns false, remove the element.
  * <p>
  * If the input collection or predicate is null, there is no change made.
  *
  * @param collection  the collection to get the input from, may be null
  * @param predicate  the predicate to use as a filter, may be null
  */
 public static void filter(java.util.Collection<Object> collection, Predicate predicate)
 {
     if (collection != null && predicate != null)
     {
         for (java.util.Iterator<Object> it = collection.iterator(); it.hasNext(); )
         {
             if (predicate.evaluate(it.next()) == false)
             {
                 it.remove();
             }
         }
     }
 }
开发者ID:gadfly,项目名称:nofs,代码行数:22,代码来源:org.apache.commons.collections.CollectionUtils.cs

示例3: countMatches

 /**
  * Counts the number of elements in the input collection that match the predicate.
  * <p>
  * A <code>null</code> collection or predicate matches no elements.
  *
  * @param inputCollection  the collection to get the input from, may be null
  * @param predicate  the predicate to use, may be null
  * @return the number of matches for the predicate in the collection
  */
 public static int countMatches(java.util.Collection<Object> inputCollection, Predicate predicate)
 {
     int count = 0;
     if (inputCollection != null && predicate != null)
     {
         for (java.util.Iterator<Object> it = inputCollection.iterator(); it.hasNext(); )
         {
             if (predicate.evaluate(it.next()))
             {
                 count++;
             }
         }
     }
     return count;
 }
开发者ID:gadfly,项目名称:nofs,代码行数:24,代码来源:org.apache.commons.collections.CollectionUtils.cs

示例4: exists

 /**
  * Answers true if a predicate is true for at least one element of a collection.
  * <p>
  * A <code>null</code> collection or predicate returns false.
  *
  * @param collection the collection to get the input from, may be null
  * @param predicate the predicate to use, may be null
  * @return true if at least one element of the collection matches the predicate
  */
 public static bool exists(java.util.Collection<Object> collection, Predicate predicate)
 {
     if (collection != null && predicate != null)
     {
         for (java.util.Iterator<Object> it = collection.iterator(); it.hasNext(); )
         {
             if (predicate.evaluate(it.next()))
             {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:gadfly,项目名称:nofs,代码行数:23,代码来源:org.apache.commons.collections.CollectionUtils.cs

示例5: selectRejected

 /**
  * Selects all elements from inputCollection which don't match the given predicate
  * and adds them to outputCollection.
  * <p>
  * If the input predicate is <code>null</code>, no elements are added to <code>outputCollection</code>.
  *
  * @param inputCollection  the collection to get the input from, may be null
  * @param predicate  the predicate to use, may be null
  * @param outputCollection  the collection to output into, may not be null
  */
 public static void selectRejected(java.util.Collection<Object> inputCollection, Predicate predicate, java.util.Collection<Object> outputCollection)
 {
     if (inputCollection != null && predicate != null)
     {
         for (java.util.Iterator<Object> iter = inputCollection.iterator(); iter.hasNext(); )
         {
             Object item = iter.next();
             if (predicate.evaluate(item) == false)
             {
                 outputCollection.add(item);
             }
         }
     }
 }
开发者ID:gadfly,项目名称:nofs,代码行数:24,代码来源:org.apache.commons.collections.CollectionUtils.cs


注:本文中的Predicate.evaluate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。