Class MultiInstanceList

  • All Implemented Interfaces:
    AlphabetCarrying, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<Instance>, java.util.Collection<Instance>, java.util.List<Instance>, java.util.RandomAccess

    public class MultiInstanceList
    extends InstanceList
    An implementation of InstanceList that logically combines multiple instance lists so that they appear as one list without copying the original lists. This is useful when running cross-validation experiments with large data sets. Any operation that would modify the size of the list is not supported.
    Author:
    Michael Bond mbond@gmail.com
    See Also:
    InstanceList, Serialized Form
    • Method Detail

      • add

        public boolean add​(Instance instance,
                           double instanceWeight)
        Description copied from class: InstanceList
        Appends the instance to this list without passing it through this InstanceList's pipe, assigning it the specified weight.
        Overrides:
        add in class InstanceList
        Returns:
        true
      • add

        public boolean add​(Instance instance)
        Description copied from class: InstanceList
        Appends the instance to this list without passing the instance through the InstanceList's pipe. The alphabets of this Instance must match the alphabets of this InstanceList.
        Specified by:
        add in interface java.util.Collection<Instance>
        Specified by:
        add in interface java.util.List<Instance>
        Overrides:
        add in class InstanceList
        Returns:
        true
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<Instance>
        Specified by:
        clear in interface java.util.List<Instance>
        Overrides:
        clear in class InstanceList
      • contains

        public boolean contains​(java.lang.Object elem)
        Specified by:
        contains in interface java.util.Collection<Instance>
        Specified by:
        contains in interface java.util.List<Instance>
        Overrides:
        contains in class java.util.ArrayList<Instance>
      • ensureCapacity

        public void ensureCapacity​(int minCapacity)
        Overrides:
        ensureCapacity in class java.util.ArrayList<Instance>
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Collection<Instance>
        Specified by:
        equals in interface java.util.List<Instance>
        Overrides:
        equals in class java.util.ArrayList<Instance>
      • get

        public Instance get​(int index)
        Specified by:
        get in interface java.util.List<Instance>
        Overrides:
        get in class java.util.ArrayList<Instance>
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<Instance>
        Specified by:
        hashCode in interface java.util.List<Instance>
        Overrides:
        hashCode in class java.util.ArrayList<Instance>
      • indexOf

        public int indexOf​(java.lang.Object elem)
        Specified by:
        indexOf in interface java.util.List<Instance>
        Overrides:
        indexOf in class java.util.ArrayList<Instance>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<Instance>
        Specified by:
        isEmpty in interface java.util.List<Instance>
        Overrides:
        isEmpty in class java.util.ArrayList<Instance>
      • iterator

        public java.util.Iterator<Instance> iterator()
        Specified by:
        iterator in interface java.util.Collection<Instance>
        Specified by:
        iterator in interface java.lang.Iterable<Instance>
        Specified by:
        iterator in interface java.util.List<Instance>
        Overrides:
        iterator in class java.util.ArrayList<Instance>
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object elem)
        Specified by:
        lastIndexOf in interface java.util.List<Instance>
        Overrides:
        lastIndexOf in class java.util.ArrayList<Instance>
      • listIterator

        public java.util.ListIterator<Instance> listIterator()
        Specified by:
        listIterator in interface java.util.List<Instance>
        Overrides:
        listIterator in class java.util.ArrayList<Instance>
      • listIterator

        public java.util.ListIterator<Instance> listIterator​(int index)
        Specified by:
        listIterator in interface java.util.List<Instance>
        Overrides:
        listIterator in class java.util.ArrayList<Instance>
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<Instance>
        Specified by:
        remove in interface java.util.List<Instance>
        Overrides:
        remove in class java.util.ArrayList<Instance>
      • setInstance

        public void setInstance​(int index,
                                Instance instance)
        Description copied from class: InstanceList
        Replaces the Instance at position index with a new one.
        Overrides:
        setInstance in class InstanceList
      • shuffle

        public void shuffle​(java.util.Random r)
        Overrides:
        shuffle in class InstanceList
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<Instance>
        Specified by:
        size in interface java.util.List<Instance>
        Overrides:
        size in class java.util.ArrayList<Instance>
      • split

        public InstanceList[] split​(java.util.Random r,
                                    double[] proportions)
        Description copied from class: InstanceList
        Shuffles the elements of this list among several smaller lists.
        Overrides:
        split in class InstanceList
        Parameters:
        r - The source of randomness to use in shuffling.
        proportions - A list of numbers (not necessarily summing to 1) which, when normalized, correspond to the proportion of elements in each returned sublist. This method (and all the split methods) do not transfer the Instance weights to the resulting InstanceLists.
        Returns:
        one InstanceList for each element of proportions
      • splitInOrder

        public InstanceList[] splitInOrder​(double[] proportions)
        Description copied from class: InstanceList
        Chops this list into several sequential sublists.
        Overrides:
        splitInOrder in class InstanceList
        Parameters:
        proportions - A list of numbers corresponding to the proportion of elements in each returned sublist. If not already normalized to sum to 1.0, it will be normalized here.
        Returns:
        one InstanceList for each element of proportions
      • splitInTwoByModulo

        public InstanceList[] splitInTwoByModulo​(int m)
        Description copied from class: InstanceList
        Returns a pair of new lists such that the first list in the pair contains every mth element of this list, starting with the first. The second list contains all remaining elements.
        Overrides:
        splitInTwoByModulo in class InstanceList
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<Instance>
        Specified by:
        toArray in interface java.util.List<Instance>
        Overrides:
        toArray in class java.util.ArrayList<Instance>
      • toArray

        public <T> T[] toArray​(T[] a)
        Specified by:
        toArray in interface java.util.Collection<Instance>
        Specified by:
        toArray in interface java.util.List<Instance>
        Overrides:
        toArray in class java.util.ArrayList<Instance>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.util.AbstractCollection<Instance>
      • trimToSize

        public void trimToSize()
        Overrides:
        trimToSize in class java.util.ArrayList<Instance>