gov.sandia.cognition.learning.algorithm.ensemble.AbstractUnweightedEnsemble Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cognitive-foundry Show documentation
Show all versions of cognitive-foundry Show documentation
A single jar with all the Cognitive Foundry components.
/*
* File: AbstractUnweightedEnsemble.java
* Authors: Justin Basilico
* Project: Cognitive Foundry Learning Core
*
* Copyright 2011 Cognitive Foundry. All rights reserved.
*/
package gov.sandia.cognition.learning.algorithm.ensemble;
import gov.sandia.cognition.util.AbstractCloneableSerializable;
import gov.sandia.cognition.util.ArgumentChecker;
import gov.sandia.cognition.util.ObjectUtil;
import java.util.ArrayList;
import java.util.List;
/**
* An abstract implementation of the {@code Ensemble} interface for
* unweighted ensembles. Implements the ensemble as a list.
*
* @param
* The type of the ensemble members.
* @author Justin Basilico
* @since 3.3.3
*/
public abstract class AbstractUnweightedEnsemble
extends AbstractCloneableSerializable
implements Ensemble
{
/** The members of the ensemble. */
protected List members;
/**
* Creates a new {@code AbstractUnweightedEnsemble}.
*/
public AbstractUnweightedEnsemble()
{
this(new ArrayList());
}
/**
* Creates a new {@code AbstractUnweightedEnsemble} with the given
* list of members.
*
* @param members
* The list of ensemble members.
*/
public AbstractUnweightedEnsemble(
final List members)
{
super();
this.setMembers(members);
}
@Override
public AbstractUnweightedEnsemble clone()
{
@SuppressWarnings("unchecked")
final AbstractUnweightedEnsemble clone =
(AbstractUnweightedEnsemble) super.clone();
clone.members = ObjectUtil.cloneSmartElementsAsArrayList(this.members);
return clone;
}
/**
* Adds a given member to the ensemble.
*
* @param member
* The ensemble member to add.
*/
public void add(
final MemberType member)
{
ArgumentChecker.assertIsNotNull("member", member);
this.getMembers().add(member);
}
/**
* Gets the number of members in the ensemble.
*
* @return
* The number of members in the ensemble.
*/
public int getMemberCount()
{
return this.getMembers().size();
}
@Override
public List getMembers()
{
return this.members;
}
/**
* Sets the list of ensemble members.
*
* @param members
* The list of ensemble members.
*/
public void setMembers(
final List members)
{
this.members = members;
}
}