All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jbpt.petri.unfolding.AbstractCoSet Maven / Gradle / Ivy

Go to download

The jBPT code library is a compendium of technologies that support research on design, execution, and evaluation of business processes.

The newest version!
package org.jbpt.petri.unfolding;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.jbpt.petri.IFlow;
import org.jbpt.petri.IMarking;
import org.jbpt.petri.INode;
import org.jbpt.petri.IPlace;
import org.jbpt.petri.ITransition;


public class AbstractCoSet, C extends ICondition, E extends IEvent, F extends IFlow, N extends INode, P extends IPlace, T extends ITransition, M extends IMarking>
	extends HashSet
	implements ICoSet
{

	private static final long serialVersionUID = 1L;

	public AbstractCoSet() {}

	private Map> p2cs = new HashMap>();

	@Override
	public int hashCode() {
		int code = 0;
		for (C c : this) {
			code += c.hashCode();
		}

		return code;
	}

	@Override
	public boolean add(C c) {
		if (this.p2cs.get(c.getPlace())==null) {
			Set cs = new HashSet();
			cs.add(c);
			this.p2cs.put(c.getPlace(),cs);
		}
		else
			this.p2cs.get(c.getPlace()).add(c);

		return super.add(c);
	}

	@Override
	public boolean addAll(Collection cs) {
		boolean result=false;
		for (C c : cs) result |= this.add(c);
		return result;
	}

	@Override
	public boolean remove(Object c) {
		return super.remove(c);
	}

	@Override
	public boolean removeAll(Collection cs) { 
		return super.removeAll(cs);
	}

	@Override
	public Set getConditions(P place) {
		return this.p2cs.get(place);
	}

	@Override
	public Collection

getPlaces() { Collection

result = new ArrayList

(); for (C c : this) result.add(c.getPlace()); return result; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy