https://github.com/rollczi/liteindex
💜 LiteIndex - Fast library for indexing box/area in space by vectors/location/position.
https://github.com/rollczi/liteindex
java optimization optimization-algorithms
Last synced: about 1 year ago
JSON representation
💜 LiteIndex - Fast library for indexing box/area in space by vectors/location/position.
- Host: GitHub
- URL: https://github.com/rollczi/liteindex
- Owner: Rollczi
- Created: 2022-11-20T23:56:06.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-05-03T03:44:30.000Z (about 1 year ago)
- Last Synced: 2025-05-03T04:29:26.625Z (about 1 year ago)
- Topics: java, optimization, optimization-algorithms
- Language: Java
- Homepage:
- Size: 140 KB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LiteIndex
💜 LiteIndex - Fast and extensive library for indexing box/area in space by vectors/location/position based on hash indexing.
### Simple Example
```java
public class Main {
public static void main(String[] args) {
int SPACE_SIZE = 10_000;
int AREA_SIZE = 80;
// create index
SpaceIndex index = SpaceIndex.builder()
.axisX(location -> location.getX())
.axisZ(location -> location.getZ())
.axisY(location -> location.getY())
.space(area -> area.getMin(), area -> area.getMax())
.indexing(IndexingAlgorithm.calculateOptimal(SPACE_SIZE, AREA_SIZE))
.concurrent(false)
.build();
// put areas to index
index.put(new Area(new Location(0, 0, 0), new Location(10, 10, 10)));
index.put(new Area(new Location(3, 3, 3), new Location(7, 7, 7)));
index.put(new Area(new Location(5, 5, 5), new Location(15, 15, 15)));
// fast search
List areas = index.get(new Location(5, 5, 5));
}
}
```
**Variables:**
It's not limit, it's just for optimization and memory saving.
- `MAP_SIZE` - expected maximum size of space
- `AREA_SIZE` - expected maximum size of area
**SpaceIndex builder**
- `axisX` - function for getting **X** coordinate
- `axisZ` - function for getting **Z** coordinate
- `axisY` - function for getting **Y** coordinate
- `space` - function for getting **min** and **max** location from area
- `indexing` - set indexing algorithm (configure for **better performance**)
- `concurrent` - set concurrent mode (if you want to use index in multiple threads)
**SpaceIndex methods**
- `put` - put area to index
- `get` - get areas by location
- `getAll` - get all areas from index
- `getFirst` - get first area by location
- `remove` - remove area from index
- `removeAll` - remove all areas from index
- `contains` - check if index contains area
- `size` - get size of index
**IndexingAlgorithm**
- `calculateOptimal` - calculate optimal indexing algorithm for your space and area size
- `chunk` - create indexing algorithm **(advanced)**
### Gradle
```kotlin
repositories {
maven("https://repo.eternalcode.pl/releases")
}
```
```kotlin
dependencies {
implementation("dev.rollczi:liteindex:1.0.0")
}
```
### Maven
```xml
eternalcode-repo
https://repo.eternalcode.pl/releases
```
```xml
dev.rollczi
liteindex
1.0.0
```