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<?,?,?,?,?,?>
worldBounds
Bounds 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 boolean
addAll(Collection<? extends P> col)
Iterator<Rectangle2afp<?,?,?,?,?,?>>
boundsIterator()
Replies the bounding rectangles of the internal data-structure elements.void
clear()
int
computeSize()
Force the deep computation of the element count in this set.boolean
contains(Object obj)
boolean
containsAll(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.P
get(int index)
Replies the element at the specified index.P
get(GeoId identifier)
Replies the element which as the specified identifier.P
get(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.N
getTreeNodeAt(double x, double y)
Replies the tree node that is containing the given coordinates.int
indexOf(Object obj)
Replies the index of the first instance the specified element.boolean
isEmpty()
boolean
isTypeRecomputedAfterRemoval()
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.boolean
remove(Object obj)
boolean
removeAll(Collection<?> col)
boolean
retainAll(Collection<?> col)
abstract void
setNodeFactory(GISTreeSetNodeFactory<P,N> factory)
Set the node factory used by this tree.void
setTypeRecomputedAfterRemoval(boolean update)
Set if this informed tree set is trying to compute the best fitting type after a removal.int
size()
boolean
slowContains(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.String
toString()
protected void
updateComponentType(Collection<? extends P> newElements)
Update the component type information with the type of the new array element.protected void
updateComponentType(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:GISTreeSet
Replies the internal tree data structure.- Specified by:
getTree
in 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:GISTreeSet
Set the node factory used by this tree.- Specified by:
setNodeFactory
in 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:GISTreeSet
Replies the node factory used by this tree.- Specified by:
getNodeFactory
in interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>
- Returns:
- the factory
-
isTypeRecomputedAfterRemoval
@Pure public boolean isTypeRecomputedAfterRemoval()
Description copied from interface:GISSet
Replies 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:
isTypeRecomputedAfterRemoval
in interfaceGISSet<P extends GISPrimitive>
- Specified by:
isTypeRecomputedAfterRemoval
in interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>
- Returns:
true
if the type is recomputed after a removal,false
if not.
-
setTypeRecomputedAfterRemoval
public void setTypeRecomputedAfterRemoval(boolean update)
Description copied from interface:GISSet
Set 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:
setTypeRecomputedAfterRemoval
in interfaceGISSet<P extends GISPrimitive>
- Specified by:
setTypeRecomputedAfterRemoval
in interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>
- Parameters:
update
- istrue
if the type is recomputed after a removal,false
if 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:GISSet
Replies the class of the components in this list.- Specified by:
getElementType
in interfaceGISSet<P extends GISPrimitive>
- Specified by:
getElementType
in 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:GISTreeSet
Replies the tree node that is containing the given coordinates.- Specified by:
getTreeNodeAt
in 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
null
if the point is outside all the tree nodes.
-
get
@Pure public P get(GeoId identifier)
Description copied from interface:GISSet
Replies 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:
get
in interfaceGISSet<P extends GISPrimitive>
- Specified by:
get
in interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>
- Parameters:
identifier
- is the identifier to text.- Returns:
- the entity or
null
if none was found.
-
get
@Pure public P get(GeoLocation location)
Description copied from interface:GISSet
Replies the element which as the specified location.- Specified by:
get
in interfaceGISSet<P extends GISPrimitive>
- Specified by:
get
in interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>
- Parameters:
location
- is the location of the element to find.- Returns:
- the entity or
null
if none was found.
-
get
@Pure public P get(int index)
Description copied from interface:GISSet
Replies the element at the specified index.This method iterates until the right index.
- Specified by:
get
in interfaceGISSet<P extends GISPrimitive>
- Specified by:
get
in 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:
clear
in interfaceCollection<P extends GISPrimitive>
- Specified by:
clear
in interfaceSet<P extends GISPrimitive>
-
isEmpty
@Pure public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<P extends GISPrimitive>
- Specified by:
isEmpty
in interfaceSet<P extends GISPrimitive>
-
size
@Pure public int size()
- Specified by:
size
in interfaceCollection<P extends GISPrimitive>
- Specified by:
size
in interfaceSet<P extends GISPrimitive>
-
computeSize
public int computeSize()
Description copied from interface:GISSet
Force the deep computation of the element count in this set.- Specified by:
computeSize
in interfaceGISSet<P extends GISPrimitive>
- Specified by:
computeSize
in 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:
iterator
in interfaceCollection<P extends GISPrimitive>
- Specified by:
iterator
in interfaceIterable<P extends GISPrimitive>
- Specified by:
iterator
in interfaceSet<P extends GISPrimitive>
-
iterator
@Pure public Iterator<P> iterator(Rectangle2afp<?,?,?,?,?,?> clipBounds, int budget)
Description copied from interface:GISSet
Replies 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:
iterator
in interfaceGISSet<P extends GISPrimitive>
- Specified by:
iterator
in 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:GISSet
Replies 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:
iterator
in interfaceGISSet<P extends GISPrimitive>
- Specified by:
iterator
in 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:
toArray
in interfaceCollection<P extends GISPrimitive>
- Specified by:
toArray
in interfaceSet<P extends GISPrimitive>
-
toArray
@Pure public <T> T[] toArray(T[] array)
- Specified by:
toArray
in interfaceCollection<P extends GISPrimitive>
- Specified by:
toArray
in interfaceSet<P extends GISPrimitive>
-
contains
@Pure public boolean contains(Object obj)
- Specified by:
contains
in interfaceCollection<P extends GISPrimitive>
- Specified by:
contains
in interfaceSet<P extends GISPrimitive>
-
slowContains
@Pure public boolean slowContains(Object obj)
Description copied from interface:GISSet
Replies if the given object is inside the set by user a depth-first iteration on the internal tree.- Specified by:
slowContains
in interfaceGISSet<P extends GISPrimitive>
- Specified by:
slowContains
in interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>
- Parameters:
obj
- the object.- Returns:
true
of o is inside, otherwisefalse
- See Also:
Set.contains(Object)
-
containsAll
@Pure public boolean containsAll(Collection<?> col)
- Specified by:
containsAll
in interfaceCollection<P extends GISPrimitive>
- Specified by:
containsAll
in interfaceSet<P extends GISPrimitive>
-
remove
public boolean remove(Object obj)
- Specified by:
remove
in interfaceCollection<P extends GISPrimitive>
- Specified by:
remove
in interfaceSet<P extends GISPrimitive>
-
removeAll
public boolean removeAll(Collection<?> col)
- Specified by:
removeAll
in interfaceCollection<P extends GISPrimitive>
- Specified by:
removeAll
in interfaceSet<P extends GISPrimitive>
-
retainAll
public boolean retainAll(Collection<?> col)
- Specified by:
retainAll
in interfaceCollection<P extends GISPrimitive>
- Specified by:
retainAll
in interfaceSet<P extends GISPrimitive>
-
addAll
public boolean addAll(Collection<? extends P> col)
- Specified by:
addAll
in interfaceCollection<P extends GISPrimitive>
- Specified by:
addAll
in interfaceSet<P extends GISPrimitive>
-
indexOf
@Pure public int indexOf(Object obj)
Description copied from interface:GISSet
Replies the index of the first instance the specified element.This method iterates until the right index.
- Specified by:
indexOf
in interfaceGISSet<P extends GISPrimitive>
- Specified by:
indexOf
in interfaceGISTreeSet<P extends GISPrimitive,N extends AbstractGISTreeSetNode<P,N>>
- Parameters:
obj
- the object to search for.- Returns:
- the index or
-1
if 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:GISSet
Replies the bounding rectangles of the internal data-structure elements.- Specified by:
boundsIterator
in interfaceGISSet<P extends GISPrimitive>
- Specified by:
boundsIterator
in 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:GISSet
Replies 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:
toIterable
in interfaceGISSet<P extends GISPrimitive>
- Specified by:
toIterable
in 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:GISSet
Replies 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:
toIterable
in interfaceGISSet<P extends GISPrimitive>
- Specified by:
toIterable
in 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.
-
-