@NotNull
    public static FastVector instanceFields2Attributes(int classIndex, List<? extends Attribute> instanceFields) throws FOSException {
    """
	Converts the given instance fields into a fast vector with <code>Attributes</code>.
	
	@param classIndex     classifier index
	@param instanceFields the list of instance fields that will generate the <code>Attributes</code>
	@return a vector with one <code>Attribute</code> for each instanceFields (in the same order).
    """
        checkNotNull(instanceFields, "Instance fields cannot be null");

        FastVector result = new FastVector(instanceFields.size());
        classIndex = classIndex == -1 ? instanceFields.size() - 1 : classIndex;

        int idx = 0;
        for (Attribute instanceField : instanceFields) {
            weka.core.Attribute attribute;

            Class<?> type = instanceField.getClass();
            if (type == CategoricalAttribute.class) {
                CategoricalAttribute categorical = (CategoricalAttribute) instanceField;
                List<String> instances = categorical.getCategoricalInstances();

                FastVector categoricalInstances = new FastVector(instances.size());
                for (String categoricalInstance : instances) {
                    categoricalInstances.addElement(categoricalInstance);
                }

                attribute = new weka.core.Attribute(instanceField.getName(), categoricalInstances, idx);

            } else if (type == NumericAttribute.class) {
                attribute = new weka.core.Attribute(instanceField.getName(), idx);
            } else {
                throw new FOSException("Unknown instance class");
            }
            result.addElement(attribute);
            idx++;
        }

        return result;
    }
@NotNull
    public static FastVector instanceFields2Attributes(int classIndex, List<? extends Attribute> instanceFields) throws FOSException {
        checkNotNull(instanceFields, "Instance fields cannot be null");

        FastVector result = new FastVector(instanceFields.size());
        classIndex = classIndex == -1 ? instanceFields.size() - 1 : classIndex;

        int idx = 0;
        for (Attribute instanceField : instanceFields) {
            weka.core.Attribute attribute;

            Class<?> type = instanceField.getClass();
            if (type == CategoricalAttribute.class) {
                CategoricalAttribute categorical = (CategoricalAttribute) instanceField;
                List<String> instances = categorical.getCategoricalInstances();

                FastVector categoricalInstances = new FastVector(instances.size());
                for (String categoricalInstance : instances) {
                    categoricalInstances.addElement(categoricalInstance);
                }

                attribute = new weka.core.Attribute(instanceField.getName(), categoricalInstances, idx);

            } else if (type == NumericAttribute.class) {
                attribute = new weka.core.Attribute(instanceField.getName(), idx);
            } else {
                throw new FOSException("Unknown instance class");
            }
            result.addElement(attribute);
            idx++;
        }

        return result;
    }
@ NotNull public static FastVector instanceFields2Attributes ( int classIndex , List < ? extends Attribute > instanceFields ) throws FOSException { checkNotNull ( instanceFields , "Instance fields cannot be null" ) ; FastVector result = new FastVector ( instanceFields . size ( ) ) ; classIndex = classIndex == - 1 ? instanceFields . size ( ) - 1 : classIndex ; int idx = 0 ; for ( Attribute instanceField : instanceFields ) { weka . core . Attribute attribute ; Class < ? > type = instanceField . getClass ( ) ; if ( type == CategoricalAttribute . class ) { CategoricalAttribute categorical = ( CategoricalAttribute ) instanceField ; List < String > instances = categorical . getCategoricalInstances ( ) ; FastVector categoricalInstances = new FastVector ( instances . size ( ) ) ; for ( String categoricalInstance : instances ) { categoricalInstances . addElement ( categoricalInstance ) ; } attribute = new weka . core . Attribute ( instanceField . getName ( ) , categoricalInstances , idx ) ; } else if ( type == NumericAttribute . class ) { attribute = new weka . core . Attribute ( instanceField . getName ( ) , idx ) ; } else { throw new FOSException ( "Unknown instance class" ) ; } result . addElement ( attribute ) ; idx ++ ; } return result ; }
Converts the given instance fields into a fast vector with <code>Attributes</code>.

@param classIndex     classifier index
@param instanceFields the list of instance fields that will generate the <code>Attributes</code>
@return a vector with one <code>Attribute</code> for each instanceFields (in the same order).
Converts the given instance fields into a fast vector with <code > Attributes< / code > .