Example usage for org.apache.commons.collections.functors OnePredicate getInstance

List of usage examples for org.apache.commons.collections.functors OnePredicate getInstance

Introduction

In this page you can find the example usage for org.apache.commons.collections.functors OnePredicate getInstance.

Prototype

public static Predicate getInstance(Collection predicates) 

Source Link

Document

Factory to create the predicate.

Usage

From source file:edu.uci.ics.jung.graph.predicates.KPartiteEdgePredicate.java

public KPartiteEdgePredicate(Collection vertex_partitions) {
    // used to make sure that each vertex satisfies only one predicate
    mutex = OnePredicate.getInstance(vertex_partitions);
    this.vertex_partitions = vertex_partitions;
}

From source file:edu.uci.ics.jung.graph.impl.KPartiteSparseGraph.java

/**
 * Creates a KPartiteSparseGraph whose partitions are specified by
 * the predicates in the <code>partitions</code> array.  If the 
 * <code>subsets</code> argument is true, creates a subset for
 * each partition.//  w  ww.ja  v a2  s  .  co  m
 */
public KPartiteSparseGraph(Collection partitions, boolean subsets) {
    super();
    if (partitions.size() < 2)
        throw new IllegalArgumentException("Constructor must " + "specify >= 2 vertex partition predicates");
    this.partitions = partitions;

    // each vertex added must satisfy exactly 1 partition-specific predicate
    getVertexConstraints().add(OnePredicate.getInstance(partitions));

    // each edge added must connect vertices in distinct partitions
    //        user_edge_requirements.add(new KPartiteEdgePredicate(partitions));
    getEdgeConstraints().add(new KPartiteEdgePredicate(partitions));

    // create a subset for each vertex predicate
    if (subsets) {
        SubsetManager sm = SubsetManager.getInstance(this);
        for (Iterator p_iter = partitions.iterator(); p_iter.hasNext();)
            sm.addVertexSubset((Predicate) p_iter.next());
    }
}