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

com.cogpunk.math.probability.EventGreaterThanSelector 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;

/**
 * Selector for identifying events 'greater than' a given, as defined by Comparable, from a given profile
 * 
 * @param  The event type
 * @param 

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





© 2015 - 2024 Weber Informatics LLC | Privacy Policy