Documentation of 'jsat.linear.vectorcollection.VectorArray' Java class
VectorArray
jsat.linear.vectorcollection

Class VectorArray<V extends Vec>

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<V>, java.util.Collection<V>, java.util.List<V>, java.util.RandomAccess, IncrementalCollection<V>, VectorCollection<V>


    public class VectorArray<V extends Vec>
    extends java.util.ArrayList<V>
    implements IncrementalCollection<V>
    This is the naive implementation of a Vector collection. Construction time is O(n) only to clone the n elements, and all queries are O(n)

    Removing elements from the vector array will result in the destruction of any acceleration cache
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean add(V e) 
      boolean addAll(java.util.Collection<? extends V> c) 
      void build(boolean parallel, java.util.List<V> collection, DistanceMetric dm)
      Builds this metric index from the given collection of points using the given distance metric.
      void clear() 
      VectorArray<V> clone() 
      java.util.List<java.lang.Double> getAccelerationCache() 
      DistanceMetric getDistanceMetric() 
      void insert(V x)
      Incrementally adds the given datapoint into the collection
      V remove(int index) 
      void search(Vec query, double range, java.util.List<java.lang.Integer> neighbors, java.util.List<java.lang.Double> distances)
      Performs a range search of the current collection.
      void search(Vec query, int numNeighbors, java.util.List<java.lang.Integer> neighbors, java.util.List<java.lang.Double> distances)
      Performs k-Nearest Neighbor search of the current collection.
      void setDistanceMetric(DistanceMetric distanceMetric)
      Sets the distance metric used for this collection.
      • Methods inherited from class java.util.ArrayList

        add, addAll, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeAll, removeIf, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
      • Methods inherited from class java.util.AbstractList

        equals, hashCode
      • Methods inherited from class java.util.AbstractCollection

        containsAll, toString
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.List

        containsAll, equals, hashCode
      • Methods inherited from interface java.util.Collection

        parallelStream, stream
    • Constructor Detail

      • VectorArray

        public VectorArray()
      • VectorArray

        public VectorArray(DistanceMetric distanceMetric,
                           int initialCapacity)
      • VectorArray

        public VectorArray(DistanceMetric distanceMetric,
                           java.util.Collection<? extends V> c)
    • Method Detail

      • insert

        public void insert(V x)
        Description copied from interface: IncrementalCollection
        Incrementally adds the given datapoint into the collection
        Specified by:
        insert in interface IncrementalCollection<V extends Vec>
        Parameters:
        x - the vector to add to the collection
      • add

        public boolean add(V e)
        Specified by:
        add in interface java.util.Collection<V extends Vec>
        Specified by:
        add in interface java.util.List<V extends Vec>
        Overrides:
        add in class java.util.ArrayList<V extends Vec>
      • addAll

        public boolean addAll(java.util.Collection<? extends V> c)
        Specified by:
        addAll in interface java.util.Collection<V extends Vec>
        Specified by:
        addAll in interface java.util.List<V extends Vec>
        Overrides:
        addAll in class java.util.ArrayList<V extends Vec>
      • remove

        public V remove(int index)
        Specified by:
        remove in interface java.util.List<V extends Vec>
        Overrides:
        remove in class java.util.ArrayList<V extends Vec>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<V extends Vec>
        Specified by:
        clear in interface java.util.List<V extends Vec>
        Overrides:
        clear in class java.util.ArrayList<V extends Vec>
      • search

        public void search(Vec query,
                           double range,
                           java.util.List<java.lang.Integer> neighbors,
                           java.util.List<java.lang.Double> distances)
        Description copied from interface: VectorCollection
        Performs a range search of the current collection. The index and distance of each found neighbor will be placed into the given Lists.
        Specified by:
        search in interface VectorCollection<V extends Vec>
        Parameters:
        query - the point to search for the neighbors within a given radius.
        range - the radius to search for all the neighbors with a distance ≤ range.
        neighbors - the list to store the index of the neighbors in. Will be sorted by distance to the query, and paired with the values in distances.
        distances - the list to store the distance of the neighbors to the query in. Will be sorted, and paired with the values in neighbors.
      • search

        public void search(Vec query,
                           int numNeighbors,
                           java.util.List<java.lang.Integer> neighbors,
                           java.util.List<java.lang.Double> distances)
        Description copied from interface: VectorCollection
        Performs k-Nearest Neighbor search of the current collection. The index and distance of each found neighbor will be placed into the given Lists.
        Specified by:
        search in interface VectorCollection<V extends Vec>
        Parameters:
        query - the point to search for the k-nearest neighbors of
        numNeighbors - the number of neighbors k to search for.
        neighbors - the list to store the index of the neighbors in. Will be sorted by distance to the query, and paired with the values in distances.
        distances - the list to store the distance of the neighbors to the query in. Will be sorted, and paired with the values in neighbors.
      • build

        public void build(boolean parallel,
                          java.util.List<V> collection,
                          DistanceMetric dm)
        Description copied from interface: VectorCollection
        Builds this metric index from the given collection of points using the given distance metric.
        Specified by:
        build in interface VectorCollection<V extends Vec>
        Parameters:
        parallel - true if the index should be built in parallel, or false if it should be done in a single thread.
        collection - the list of vectors to put into the index
        dm - the distance metric to build the index using.

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.