001/*
002 * Copyright (c) 2015-2020, Oracle and/or its affiliates. All rights reserved.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.tribuo;
018
019import com.oracle.labs.mlrg.olcut.util.Pair;
020
021/**
022 * An {@link OutputInfo} that is fixed, and contains an id number for each valid output.
023 * <p>
024 * In the case of real valued outputs, the id number represents the dimension.
025 */
026public interface ImmutableOutputInfo<T extends Output<T>> extends OutputInfo<T>, Iterable<Pair<Integer,T>> {
027
028    /**
029     * Return the id number associated with this output, or -1 if the output is unknown.
030     * @param output An output
031     * @return A non-negative integer if the output is known, or -1 if the output is unknown.
032     */
033    public int getID(T output);
034
035    /**
036     * Returns the output associated with this id, or null if the id is unknown.
037     * @param id A non-negative integer.
038     * @return An output object or null if it's unknown.
039     */
040    public T getOutput(int id);
041
042    /**
043     * Returns the total number of observed outputs seen by this ImmutableOutputInfo.
044     * @return The number of observed outputs.
045     */
046    public long getTotalObservations();
047
048}