Module org.arakhne.afc.gis.giscore
Package org.arakhne.afc.gis.tree
Class AbstractGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>
- java.lang.Object
-
- org.arakhne.afc.gis.tree.AbstractGISTreeSet<P,N>
-
- Type Parameters:
P- is the type of the user data inside the node.N- is the type of the nodes.
- All Implemented Interfaces:
Iterable<P>,Collection<P>,Set<P>,GISSet<P>,GISTreeSet<P,N>
- Direct Known Subclasses:
StandardGISTreeSet,WeakGISTreeSet
abstract class AbstractGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>> extends Object implements GISSet<P>, GISTreeSet<P,N>
This class describes a quad tree that contains GIS primitives and thatp permits to find them according to there geo-location.- Since:
- 14.0
- Version:
- 17.0 2020-01-04 14:41:53
- Author:
- Stéphane GALLAND
- See Also:
GISPrimitive- Maven Group Id:
- org.arakhne.afc.gis
- Maven Artifact Id:
- giscore
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Rectangle2afp<?,?,?,?,?,?>worldBoundsBounds of the all the data in the tree.
-
Constructor Summary
Constructors Constructor Description AbstractGISTreeSet()Create an empty tree.AbstractGISTreeSet(double boundsX, double boundsY, double boundsWidth, double boundsHeight)Constructor.AbstractGISTreeSet(Rectangle2afp<?,?,?,?,?,?> bounds)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanaddAll(Collection<? extends P> col)Iterator<Rectangle2afp<?,?,?,?,?,?>>boundsIterator()Replies the bounding rectangles of the internal data-structure elements.voidclear()intcomputeSize()Force the deep computation of the element count in this set.booleancontains(Object obj)booleancontainsAll(Collection<?> col)protected static <E> Class<? extends E>extractClassFrom(Collection<? extends E> collection)Extract the upper class that contains all the elements of this array.Pget(int index)Replies the element at the specified index.Pget(GeoId identifier)Replies the element which as the specified identifier.Pget(GeoLocation location)Replies the element which as the specified location.Class<? extends P>getElementType()Replies the class of the components in this list.abstract GISTreeSetNodeFactory<P,N>getNodeFactory()Replies the node factory used by this tree.Tree<P,N>getTree()Replies the internal tree data structure.NgetTreeNodeAt(double x, double y)Replies the tree node that is containing the given coordinates.intindexOf(Object obj)Replies the index of the first instance the specified element.booleanisEmpty()booleanisTypeRecomputedAfterRemoval()Replies if this informed tree set is trying to compute the best fitting type after a removal.Iterator<P>iterator()Iterator<P>iterator(Rectangle2afp<?,?,?,?,?,?> clipBounds)Replies the set of elements that have an intersection with the specified rectangle.Iterator<P>iterator(Rectangle2afp<?,?,?,?,?,?> clipBounds, int budget)Replies the set of elements that have an intersection with the specified rectangle.(package private) Iterator<N>nodeIterator(Rectangle2afp<?,?,?,?,?,?> clipBounds)Replies the set of nodes that have an intersection with the specified rectangle.booleanremove(Object obj)booleanremoveAll(Collection<?> col)booleanretainAll(Collection<?> col)abstract voidsetNodeFactory(GISTreeSetNodeFactory<P,N> factory)Set the node factory used by this tree.voidsetTypeRecomputedAfterRemoval(boolean update)Set if this informed tree set is trying to compute the best fitting type after a removal.intsize()booleanslowContains(Object obj)Replies if the given object is inside the set by user a depth-first iteration on the internal tree.Object[]toArray()<T> T[]toArray(T[] array)Iterable<P>toIterable(Rectangle2afp<?,?,?,?,?,?> clipBounds)Replies the set of elements that have an intersection with the specified rectangle.Iterable<P>toIterable(Rectangle2afp<?,?,?,?,?,?> clipBounds, int budget)Replies the set of elements that have an intersection with the specified rectangle.StringtoString()protected voidupdateComponentType(Collection<? extends P> newElements)Update the component type information with the type of the new array element.protected voidupdateComponentType(P newElement)Update the component type information with the type of the new array element.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
add, equals, hashCode, spliterator
-
-
-
-
Field Detail
-
worldBounds
Rectangle2afp<?,?,?,?,?,?> worldBounds
Bounds of the all the data in the tree.
-
-
Constructor Detail
-
AbstractGISTreeSet
AbstractGISTreeSet()
Create an empty tree.
-
AbstractGISTreeSet
AbstractGISTreeSet(Rectangle2afp<?,?,?,?,?,?> bounds)
Constructor.- Parameters:
bounds- are the bounds of the scene stored inside this tree.
-
AbstractGISTreeSet
AbstractGISTreeSet(double boundsX, double boundsY, double boundsWidth, double boundsHeight)Constructor.- Parameters:
boundsX- is the bounds of the scene.boundsY- is the bounds of the scene.boundsWidth- is the bounds of the scene.boundsHeight- is the bounds of the scene.
-
-
Method Detail
-
extractClassFrom
@Pure protected static <E> Class<? extends E> extractClassFrom(Collection<? extends E> collection)
Extract the upper class that contains all the elements of this array.- Type Parameters:
E- is the type of the list's elements.- Parameters:
collection- is the collection to scan- Returns:
- the top class of all the elements.
-
getTree
@Pure public Tree<P,N> getTree()
Description copied from interface:GISTreeSetReplies the internal tree data structure.- Specified by:
getTreein interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>- Returns:
- the internal tree data structure.
-
setNodeFactory
public abstract void setNodeFactory(GISTreeSetNodeFactory<P,N> factory)
Description copied from interface:GISTreeSetSet the node factory used by this tree.- Specified by:
setNodeFactoryin interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>- Parameters:
factory- the factory.
-
getNodeFactory
@Pure public abstract GISTreeSetNodeFactory<P,N> getNodeFactory()
Description copied from interface:GISTreeSetReplies the node factory used by this tree.- Specified by:
getNodeFactoryin interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>- Returns:
- the factory
-
isTypeRecomputedAfterRemoval
@Pure public boolean isTypeRecomputedAfterRemoval()
Description copied from interface:GISSetReplies if this informed tree set is trying to compute the best fitting type after a removal. Iffalse, this class will keep unchanged the previously computed type.- Specified by:
isTypeRecomputedAfterRemovalin interfaceGISSet<P extends GISPrimitive>- Specified by:
isTypeRecomputedAfterRemovalin interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>- Returns:
trueif the type is recomputed after a removal,falseif not.
-
setTypeRecomputedAfterRemoval
public void setTypeRecomputedAfterRemoval(boolean update)
Description copied from interface:GISSetSet if this informed tree set is trying to compute the best fitting type after a removal. Iffalse, this class will keep unchanged the previously computed type.- Specified by:
setTypeRecomputedAfterRemovalin interfaceGISSet<P extends GISPrimitive>- Specified by:
setTypeRecomputedAfterRemovalin interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>- Parameters:
update- istrueif the type is recomputed after a removal,falseif not.
-
updateComponentType
protected final void updateComponentType(P newElement)
Update the component type information with the type of the new array element.- Parameters:
newElement- is the element for which the known top type in this array must be eventually updated.
-
updateComponentType
protected final void updateComponentType(Collection<? extends P> newElements)
Update the component type information with the type of the new array element.- Parameters:
newElements- are the elements for which the known top type in this array must be eventually updated.
-
getElementType
@Pure public Class<? extends P> getElementType()
Description copied from interface:GISSetReplies the class of the components in this list.- Specified by:
getElementTypein interfaceGISSet<P extends GISPrimitive>- Specified by:
getElementTypein interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>- Returns:
- the top most type of the array's elements.
-
getTreeNodeAt
@Pure public N getTreeNodeAt(double x, double y)
Description copied from interface:GISTreeSetReplies the tree node that is containing the given coordinates.- Specified by:
getTreeNodeAtin interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>- Parameters:
x- x coordinate.y- y coordinate.- Returns:
- the tree node with the givne point inside, or
nullif the point is outside all the tree nodes.
-
get
@Pure public P get(GeoId identifier)
Description copied from interface:GISSetReplies the element which as the specified identifier.This function is time consuming because the location of the primitive could not be retreived from the geoId.
- Specified by:
getin interfaceGISSet<P extends GISPrimitive>- Specified by:
getin interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>- Parameters:
identifier- is the identifier to text.- Returns:
- the entity or
nullif none was found.
-
get
@Pure public P get(GeoLocation location)
Description copied from interface:GISSetReplies the element which as the specified location.- Specified by:
getin interfaceGISSet<P extends GISPrimitive>- Specified by:
getin interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>- Parameters:
location- is the location of the element to find.- Returns:
- the entity or
nullif none was found.
-
get
@Pure public P get(int index)
Description copied from interface:GISSetReplies the element at the specified index.This method iterates until the right index.
- Specified by:
getin interfaceGISSet<P extends GISPrimitive>- Specified by:
getin interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>- Parameters:
index- the index.- Returns:
- the element at the given index.
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<P extends GISPrimitive>- Specified by:
clearin interfaceSet<P extends GISPrimitive>
-
isEmpty
@Pure public boolean isEmpty()
- Specified by:
isEmptyin interfaceCollection<P extends GISPrimitive>- Specified by:
isEmptyin interfaceSet<P extends GISPrimitive>
-
size
@Pure public int size()
- Specified by:
sizein interfaceCollection<P extends GISPrimitive>- Specified by:
sizein interfaceSet<P extends GISPrimitive>
-
computeSize
public int computeSize()
Description copied from interface:GISSetForce the deep computation of the element count in this set.- Specified by:
computeSizein interfaceGISSet<P extends GISPrimitive>- Specified by:
computeSizein interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>- Returns:
- the count of elements inside the tree.
-
iterator
@Pure public Iterator<P> iterator()
- Specified by:
iteratorin interfaceCollection<P extends GISPrimitive>- Specified by:
iteratorin interfaceIterable<P extends GISPrimitive>- Specified by:
iteratorin interfaceSet<P extends GISPrimitive>
-
iterator
@Pure public Iterator<P> iterator(Rectangle2afp<?,?,?,?,?,?> clipBounds, int budget)
Description copied from interface:GISSetReplies the set of elements that have an intersection with the specified rectangle.This function replies the elements with a broad-first iteration on the elements' tree.
- Specified by:
iteratorin interfaceGISSet<P extends GISPrimitive>- Specified by:
iteratorin interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>- Parameters:
clipBounds- is the bounds outside which the elements will not be repliedbudget- is the maximal size of the replied list. If this value is negative, all the elements will be replied.- Returns:
- the elements inside the specified bounds.
-
iterator
@Pure public Iterator<P> iterator(Rectangle2afp<?,?,?,?,?,?> clipBounds)
Description copied from interface:GISSetReplies the set of elements that have an intersection with the specified rectangle.This function replies the elements with a broad-first iteration on the elements' tree.
- Specified by:
iteratorin interfaceGISSet<P extends GISPrimitive>- Specified by:
iteratorin interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>- Parameters:
clipBounds- is the bounds outside which the elements will not be replied- Returns:
- the elements inside the specified bounds.
-
toArray
@Pure public Object[] toArray()
- Specified by:
toArrayin interfaceCollection<P extends GISPrimitive>- Specified by:
toArrayin interfaceSet<P extends GISPrimitive>
-
toArray
@Pure public <T> T[] toArray(T[] array)
- Specified by:
toArrayin interfaceCollection<P extends GISPrimitive>- Specified by:
toArrayin interfaceSet<P extends GISPrimitive>
-
contains
@Pure public boolean contains(Object obj)
- Specified by:
containsin interfaceCollection<P extends GISPrimitive>- Specified by:
containsin interfaceSet<P extends GISPrimitive>
-
slowContains
@Pure public boolean slowContains(Object obj)
Description copied from interface:GISSetReplies if the given object is inside the set by user a depth-first iteration on the internal tree.- Specified by:
slowContainsin interfaceGISSet<P extends GISPrimitive>- Specified by:
slowContainsin interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>- Parameters:
obj- the object.- Returns:
trueof o is inside, otherwisefalse- See Also:
Set.contains(Object)
-
containsAll
@Pure public boolean containsAll(Collection<?> col)
- Specified by:
containsAllin interfaceCollection<P extends GISPrimitive>- Specified by:
containsAllin interfaceSet<P extends GISPrimitive>
-
remove
public boolean remove(Object obj)
- Specified by:
removein interfaceCollection<P extends GISPrimitive>- Specified by:
removein interfaceSet<P extends GISPrimitive>
-
removeAll
public boolean removeAll(Collection<?> col)
- Specified by:
removeAllin interfaceCollection<P extends GISPrimitive>- Specified by:
removeAllin interfaceSet<P extends GISPrimitive>
-
retainAll
public boolean retainAll(Collection<?> col)
- Specified by:
retainAllin interfaceCollection<P extends GISPrimitive>- Specified by:
retainAllin interfaceSet<P extends GISPrimitive>
-
addAll
public boolean addAll(Collection<? extends P> col)
- Specified by:
addAllin interfaceCollection<P extends GISPrimitive>- Specified by:
addAllin interfaceSet<P extends GISPrimitive>
-
indexOf
@Pure public int indexOf(Object obj)
Description copied from interface:GISSetReplies the index of the first instance the specified element.This method iterates until the right index.
- Specified by:
indexOfin interfaceGISSet<P extends GISPrimitive>- Specified by:
indexOfin interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>- Parameters:
obj- the object to search for.- Returns:
- the index or
-1if the object was not inside this set.
-
nodeIterator
@Pure Iterator<N> nodeIterator(Rectangle2afp<?,?,?,?,?,?> clipBounds)
Replies the set of nodes that have an intersection with the specified rectangle.This function replies the nodes with a broad-first iteration on the elements' tree.
- Parameters:
clipBounds- is the bounds outside which the nodes will not be replied- Returns:
- the nodes inside the specified bounds.
-
boundsIterator
@Pure public Iterator<Rectangle2afp<?,?,?,?,?,?>> boundsIterator()
Description copied from interface:GISSetReplies the bounding rectangles of the internal data-structure elements.- Specified by:
boundsIteratorin interfaceGISSet<P extends GISPrimitive>- Specified by:
boundsIteratorin interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>- Returns:
- the bounding boxes in the data-structure.
-
toIterable
@Pure public Iterable<P> toIterable(Rectangle2afp<?,?,?,?,?,?> clipBounds)
Description copied from interface:GISSetReplies the set of elements that have an intersection with the specified rectangle.This function replies the elements with a broad-first iteration on the elements' tree.
- Specified by:
toIterablein interfaceGISSet<P extends GISPrimitive>- Specified by:
toIterablein interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>- Parameters:
clipBounds- is the bounds outside which the elements will not be replied- Returns:
- the elements inside the specified bounds.
-
toIterable
@Pure public Iterable<P> toIterable(Rectangle2afp<?,?,?,?,?,?> clipBounds, int budget)
Description copied from interface:GISSetReplies the set of elements that have an intersection with the specified rectangle.This function replies the elements with a broad-first iteration on the elements' tree.
- Specified by:
toIterablein interfaceGISSet<P extends GISPrimitive>- Specified by:
toIterablein interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>- Parameters:
clipBounds- is the bounds outside which the elements will not be repliedbudget- is the maximal size of the replied list. If this value is negative, all the elements will be replied.- Returns:
- the elements inside the specified bounds.
-
-