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

com.cogpunk.math.probability.EventLessThanSelector Maven / Gradle / Ivy

There is a newer version: 1.0.4
Show newest version
package com.cogpunk.math.probability;

import java.util.Set;
import java.util.TreeMap;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.EqualsBuilder;

/**
 * Selectors for defining those less than the defined event, as defined by the comparable
 * 
 * @param  Event type
 * @param 

Probability type */ public class EventLessThanSelector , P extends Number> implements EventSelector { private E threshold; public EventLessThanSelector(E threshold) { this.threshold = threshold; } @Override public Set selectEvents(EventProbabilityProfile profile) { TreeMap map = new TreeMap(); map.putAll(profile.map()); return map.headMap(threshold, false).keySet(); } /** * {@inheritDoc} */ @Override public boolean equals(final Object other) { if (!(other instanceof EventLessThanSelector)) { return false; } EventLessThanSelector castOther = (EventLessThanSelector) other; return new EqualsBuilder().append(threshold, castOther.threshold).isEquals(); } /** * {@inheritDoc} */ @Override public int hashCode() { return new HashCodeBuilder().append(threshold).toHashCode(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy