
aima.core.probability.domain.FiniteIntegerDomain Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aima-core Show documentation
Show all versions of aima-core Show documentation
AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.
package aima.core.probability.domain;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
public class FiniteIntegerDomain extends AbstractFiniteDomain {
private Set possibleValues = null;
public FiniteIntegerDomain(Integer... pValues) {
// Keep consistent order
possibleValues = new LinkedHashSet();
for (Integer v : pValues) {
possibleValues.add(v);
}
// Ensure cannot be modified
possibleValues = Collections.unmodifiableSet(possibleValues);
indexPossibleValues(possibleValues);
}
//
// START-Domain
@Override
public int size() {
return possibleValues.size();
}
@Override
public boolean isOrdered() {
return true;
}
// END-Domain
//
//
// START-DiscreteDomain
@Override
public Set getPossibleValues() {
return possibleValues;
}
// END-DiscreteDomain
//
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof FiniteIntegerDomain)) {
return false;
}
FiniteIntegerDomain other = (FiniteIntegerDomain) o;
return this.possibleValues.equals(other.possibleValues);
}
@Override
public int hashCode() {
return possibleValues.hashCode();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy