Interface UniformGrid<K,V>

Type Parameters:
K - grid's dimension, i.e., Point2d, Point3d, Point4d, etc.
V - the type of elements to be stored in the grid
All Known Subinterfaces:
UniformGrid3d<V>, UniformGrid4d<V>
All Known Implementing Classes:
UniformGrid3dImpl, UniformGrid4dImpl, UniformGridImpl

public interface UniformGrid<K,V>
Infinite multidimensional uniform grid with the given cell size.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clear the grid, i.e., removes all stored values.
    get(K loc)
    Returns objects stored in the cell of given location in space.
    Returns all objects stored in the grid.
    double
    Returns cell size.
    Returns all objects that can be closer that the cell size.
    Returns non-empty cells (in random order)
    int
    Returns number of non-empty cells.
    boolean
    remove(K loc, V object)
    Removes an object located in the space
    void
    store(Collection<V> objects, Function<? super V,? extends K> mapFunc)
    Stores given objects into the grid.
    void
    store(K loc, V object)
    Stores an object located in given 3D position in the grid.
  • Method Details

    • getCellSize

      double getCellSize()
      Returns cell size.
      Returns:
      cell size
    • numOccupiedCells

      int numOccupiedCells()
      Returns number of non-empty cells.
      Returns:
      number of non-empty cells.
    • getNonEmptyCells

      List<List<V>> getNonEmptyCells()
      Returns non-empty cells (in random order)
      Returns:
      non-empty cells
    • clear

      void clear()
      Clear the grid, i.e., removes all stored values.
    • store

      void store(K loc, V object)
      Stores an object located in given 3D position in the grid.
      Parameters:
      loc - 3D location of the object. Must not be null
      object - Object to store.
    • store

      void store(Collection<V> objects, Function<? super V,? extends K> mapFunc)
      Stores given objects into the grid. As the mapping function, use (MeshPoint mp) -> mp.getPosition() or (Point3d p) -> p, for instance.
      Parameters:
      objects - Objects to be stored
      mapFunc - A function that computes a space location from an object
    • get

      List<V> get(K loc)
      Returns objects stored in the cell of given location in space.
      Parameters:
      loc - location in space
      Returns:
      objects stored in the cell or empty collection
    • getAll

      List<V> getAll()
      Returns all objects stored in the grid.
      Returns:
      all objects stored in the grid
    • remove

      boolean remove(K loc, V object)
      Removes an object located in the space
      Parameters:
      loc - Object's location in space
      object - Object to be removed
      Returns:
      true if the objects was found and removed, false otherwise.
    • getClosest

      List<V> getClosest(K loc)
      Returns all objects that can be closer that the cell size.
      Parameters:
      loc - location in space
      Returns:
      objects that can be closer that the cell size or empty collection.