001package org.clafer.ir;
002
003import gnu.trove.TIntCollection;
004import gnu.trove.iterator.TIntIterator;
005
006/**
007 * Integer domain.
008 *
009 * @author jimmy
010 */
011public interface IrDomain {
012
013    /**
014     * Checks if this domain is defined as a lower and upper bound. If the
015     * domain is bounded then it contains every value between its lower and
016     * upper bound.
017     *
018     * @return {@code true} if and only if this domain is a contiguous interval,
019     * {@code false} otherwise
020     */
021    public boolean isBounded();
022
023    /**
024     * Checks if a value is within this domain.
025     *
026     * @param value test this value
027     * @return {@code true} if and only if this domain contains the {@code value},
028     *         {@code false} otherwise
029     */
030    public boolean contains(int value);
031
032    /**
033     * Returns the smallest integer contained in this domain. Undefined if this
034     * domain is empty.
035     *
036     * @return the smallest integer contained in this domain
037     */
038    public int getLowBound();
039
040    /**
041     * Returns the largest integer contained in this domain. Undefined if this
042     * domain is empty.
043     *
044     * @return the largest integer contained in this domain
045     */
046    public int getHighBound();
047
048    /**
049     * Checks if this domain contains any values.
050     *
051     * @return {@code true} if and only if the size of this domain is zero,
052     * {@code false} otherwise
053     */
054    public boolean isEmpty();
055
056    /**
057     * Returns how many values are contained in this domain.
058     *
059     * @return the size of this domain
060     */
061    public int size();
062
063    /**
064     * Returns all the values contained in this domain.
065     *
066     * @return values contained in this domain
067     */
068    public int[] getValues();
069
070    /**
071     * Iterate over the domain in increasing order.
072     *
073     * @return an iterator over the values in this domain in increasing order
074     */
075    public TIntIterator iterator();
076
077    /**
078     * Iterate over the domain in the specified order.
079     *
080     * @param increasing increasing or decreasing order
081     * @return an iterator over the values in this domain in the order specified
082     */
083    public TIntIterator iterator(boolean increasing);
084
085    /**
086     * Put the contents of this domain inside the collection.
087     *
088     * @param collection the collection
089     */
090    public void transferTo(TIntCollection collection);
091}