Class RectArray<T>

    • Constructor Detail

      • RectArray

        public RectArray​(int dims,
                         int size)
        Setup of a simple array data structure (no indexing).
        Parameters:
        dims - dimensions
        size - size
    • Method Detail

      • insert

        public void insert​(double[] lower,
                           double[] upper,
                           T value)
        Description copied from interface: BoxMap
        Insert a box.
        Specified by:
        insert in interface BoxMap<T>
        Specified by:
        insert in interface BoxMultimap<T>
        Parameters:
        lower - minimum corner
        upper - maximum corner
        value - value
      • remove

        public T remove​(double[] lower,
                        double[] upper)
        Description copied from interface: BoxMap
        Remove an entry.
        Specified by:
        remove in interface BoxMap<T>
        Parameters:
        lower - minimum corner
        upper - maximum corner
        Returns:
        the value of the entry or null if the entry was not found
      • remove

        public boolean remove​(double[] lower,
                              double[] upper,
                              T value)
        Description copied from interface: BoxMultimap
        Remove *one*n entry with the given value.
        Specified by:
        remove in interface BoxMultimap<T>
        Parameters:
        lower - minimum corner
        upper - maximum corner
        value - value
        Returns:
        the value of the entry or null if the entry was not found
      • removeIf

        public boolean removeIf​(double[] lower,
                                double[] upper,
                                Predicate<Index.BoxEntry<T>> condition)
        Description copied from interface: BoxMultimap
        Remove *one* entry with the given condition.
        Specified by:
        removeIf in interface BoxMultimap<T>
        Parameters:
        lower - minimum corner
        upper - maximum corner
        condition - the condition required for removing an entry
        Returns:
        the value of the entry or null if the entry was not found
      • update

        public T update​(double[] lo1,
                        double[] up1,
                        double[] lo2,
                        double[] up2)
        Description copied from interface: BoxMap
        Update the position of an entry.
        Specified by:
        update in interface BoxMap<T>
        Parameters:
        lo1 - old min
        up1 - old max
        lo2 - new min
        up2 - new max
        Returns:
        the value, or null if the entries was not found
      • contains

        public boolean contains​(double[] min,
                                double[] max)
        Description copied from interface: BoxMap
        Lookup an entry, using exact match.
        Specified by:
        contains in interface BoxMap<T>
        Parameters:
        min - minimum corner
        max - maximum corner
        Returns:
        `true` if an entry was found, otherwise `false`.
      • update

        public boolean update​(double[] lo1,
                              double[] up1,
                              double[] lo2,
                              double[] up2,
                              T value)
        Description copied from interface: BoxMultimap
        Update the position of an entry.
        Specified by:
        update in interface BoxMultimap<T>
        Parameters:
        lo1 - old min
        up1 - old max
        lo2 - new min
        up2 - new max
        value - only entries with this value are updated
        Returns:
        the value, or null if the entries was not found
      • queryExact

        public T queryExact​(double[] lower,
                            double[] upper)
        Description copied from interface: BoxMap
        Lookup an entry, using exact match.
        Specified by:
        queryExact in interface BoxMap<T>
        Parameters:
        lower - minimum corner
        upper - maximum corner
        Returns:
        the value of the entry or null if the entry was not found
      • contains

        public boolean contains​(double[] lower,
                                double[] upper,
                                T value)
        Description copied from interface: BoxMultimap
        Lookup an entry, using exact match.
        Specified by:
        contains in interface BoxMultimap<T>
        Parameters:
        lower - minimum corner
        upper - maximum corner
        value - the value
        Returns:
        `true` if an entry was found, otherwise `false`.
      • queryExactBox

        public Index.BoxIterator<T> queryExactBox​(double[] lower,
                                                  double[] upper)
        Description copied from interface: BoxMultimap
        Lookup an entry, using exact match.
        Specified by:
        queryExactBox in interface BoxMultimap<T>
        Parameters:
        lower - minimum corner
        upper - maximum corner
        Returns:
        an iterator over all entries with the exact given box shape
      • queryIntersect

        public Index.BoxIterator<T> queryIntersect​(double[] min,
                                                   double[] max)
        Specified by:
        queryIntersect in interface BoxMap<T>
        Specified by:
        queryIntersect in interface BoxMultimap<T>
        Parameters:
        min - Lower left corner of the query window
        max - Upper right corner of the query window
        Returns:
        All boxes that intersect with the query rectangle.
      • query1nn

        public Index.BoxEntryKnn<T> query1nn​(double[] center)
        Description copied from interface: BoxMap
        Finds the nearest neighbor. This uses Euclidean 'edge distance'. Other distance types can only be specified directly on the index implementations.
        Specified by:
        query1nn in interface BoxMap<T>
        Specified by:
        query1nn in interface BoxMultimap<T>
        Parameters:
        center - center point
        Returns:
        the nearest neighbor
      • queryKnn

        public Index.BoxIteratorKnn<T> queryKnn​(double[] center,
                                                int k)
        Description copied from interface: BoxMap
        Finds the nearest neighbor. This uses Euclidean 'edge distance', i.e. the distance to the edge of a box. Distance is 0 if the box overlaps with the search point. Other distance types can only be specified directly on the index implementations.
        Specified by:
        queryKnn in interface BoxMap<T>
        Specified by:
        queryKnn in interface BoxMultimap<T>
        Parameters:
        center - center point
        k - number of neighbors
        Returns:
        list of nearest neighbors
      • queryKnn

        public Index.BoxIteratorKnn<T> queryKnn​(double[] center,
                                                int k,
                                                BoxDistance distFn)
        Description copied from interface: BoxMultimap
        Finds the nearest neighbor. This uses a custom distance function for distances to boxes.
        Specified by:
        queryKnn in interface BoxMultimap<T>
        Parameters:
        center - center point
        k - number of neighbors
        distFn - distance function
        Returns:
        list of nearest neighbors
      • getDims

        public int getDims()
        Specified by:
        getDims in interface Index
        Returns:
        the number of dimensions
      • size

        public int size()
        Specified by:
        size in interface Index
        Returns:
        the number of entries
      • clear

        public void clear()
        Description copied from interface: Index
        Clear all entries.
        Specified by:
        clear in interface Index
      • getStats

        public Stats getStats()
        Specified by:
        getStats in interface Index
        Returns:
        Collect and return some index statistics. Note that indexes are not required to fill all fields. Also, individual indexes may use subclasses with additional fields.
      • getNodeCount

        public int getNodeCount()
        Specified by:
        getNodeCount in interface Index
      • getDepth

        public int getDepth()
        Specified by:
        getDepth in interface Index
      • toStringTree

        public String toStringTree()
        Specified by:
        toStringTree in interface Index
        Returns:
        a full string output of the tree structure with all entries