Package com.fastasyncworldedit.core.math
Class LocalBlockVectorSet
java.lang.Object
com.fastasyncworldedit.core.math.LocalBlockVectorSet
- All Implemented Interfaces:
Iterable<BlockVector3>
,Collection<BlockVector3>
,Set<BlockVector3>
The LocalBlockVectorSet is a Memory and CPU optimized Set for storing BlockVectors which are all in a local region
- All vectors must be in a 2048 * 512 * 2048 area centered around the first entry
- This will use 8 bytes for every 64 BlockVectors (about 800x less than a HashSet)
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionNew LocalBlockVectorSet that will set the offset x and z to the first value givenLocalBlockVectorSet
(int x, int z) New LocalBlockVectorSet with a given offset -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(int x, int y, int z) Add a position to the set if not presentboolean
add
(BlockVector3 vector) Add a position to the set if not presentboolean
addAll
(Collection<? extends BlockVector3> c) boolean
canAdd
(int x, int y, int z) If a position is contained by the bounds of the setvoid
clear()
clone()
boolean
contains
(int x, int y, int z) If the set contains a positionboolean
boolean
containsAll
(Collection<?> c) boolean
containsRadius
(int x, int y, int z, int radius) If a radius is contained by the setvoid
Visit each point contained in the setprotected MutableBlockVector3
getIndex
(int getIndex) boolean
isEmpty()
iterator()
boolean
remove
(int x, int y, int z) Remove a position from the set.boolean
boolean
removeAll
(Collection<?> c) boolean
retainAll
(Collection<?> c) void
setOffset
(int x, int z) Set the offset applied to values when storing and reading to keep the values within -1024 to 1023int
size()
Object[]
toArray()
<T> T[]
toArray
(T[] array) Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.Set
equals, hashCode, spliterator
-
Constructor Details
-
LocalBlockVectorSet
public LocalBlockVectorSet()New LocalBlockVectorSet that will set the offset x and z to the first value given -
LocalBlockVectorSet
public LocalBlockVectorSet(int x, int z) New LocalBlockVectorSet with a given offset- Parameters:
x
- x offsetz
- z offset
-
-
Method Details
-
size
public int size()- Specified by:
size
in interfaceCollection<BlockVector3>
- Specified by:
size
in interfaceSet<BlockVector3>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<BlockVector3>
- Specified by:
isEmpty
in interfaceSet<BlockVector3>
-
contains
public boolean contains(int x, int y, int z) If the set contains a position- Parameters:
x
- x positiony
- y positionz
- z position- Returns:
- if the set contains the position
-
contains
- Specified by:
contains
in interfaceCollection<BlockVector3>
- Specified by:
contains
in interfaceSet<BlockVector3>
-
clone
-
containsRadius
public boolean containsRadius(int x, int y, int z, int radius) If a radius is contained by the set- Parameters:
x
- x radius centery
- y radius centerz
- z radius center- Returns:
- if radius is contained by the set
-
setOffset
public void setOffset(int x, int z) Set the offset applied to values when storing and reading to keep the values within -1024 to 1023- Parameters:
x
- x offsetz
- z offset
-
getIndex
-
iterator
- Specified by:
iterator
in interfaceCollection<BlockVector3>
- Specified by:
iterator
in interfaceIterable<BlockVector3>
- Specified by:
iterator
in interfaceSet<BlockVector3>
-
toArray
- Specified by:
toArray
in interfaceCollection<BlockVector3>
- Specified by:
toArray
in interfaceSet<BlockVector3>
-
toArray
@Nonnull public <T> T[] toArray(T[] array) - Specified by:
toArray
in interfaceCollection<BlockVector3>
- Specified by:
toArray
in interfaceSet<BlockVector3>
-
canAdd
public boolean canAdd(int x, int y, int z) If a position is contained by the bounds of the set- Parameters:
x
- x positiony
- y positionz
- z position- Returns:
- true if position is contained by the bounds of the set
-
add
public boolean add(int x, int y, int z) Add a position to the set if not present- Parameters:
x
- x positiony
- y positionz
- z position- Returns:
- true if not already present
-
add
Add a position to the set if not present- Specified by:
add
in interfaceCollection<BlockVector3>
- Specified by:
add
in interfaceSet<BlockVector3>
- Parameters:
vector
- position- Returns:
- true if not already present
-
remove
public boolean remove(int x, int y, int z) Remove a position from the set.- Parameters:
x
- x posititiony
- y posititionz
- z positition- Returns:
- true if value was present.
-
remove
- Specified by:
remove
in interfaceCollection<BlockVector3>
- Specified by:
remove
in interfaceSet<BlockVector3>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<BlockVector3>
- Specified by:
containsAll
in interfaceSet<BlockVector3>
-
addAll
- Specified by:
addAll
in interfaceCollection<BlockVector3>
- Specified by:
addAll
in interfaceSet<BlockVector3>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<BlockVector3>
- Specified by:
retainAll
in interfaceSet<BlockVector3>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<BlockVector3>
- Specified by:
removeAll
in interfaceSet<BlockVector3>
-
forEach
Visit each point contained in the set- Parameters:
visitor
- visitor to use
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<BlockVector3>
- Specified by:
clear
in interfaceSet<BlockVector3>
-