Skip to content

hidekatsu-izuno/darts-clone-java

Repository files navigation

License Maven Central

darts-clone-java

Double-ARray Trie System clone written in Java.

This library is based on Darts Clone that known as a fast and efficient library.

Getting Started

Setup

To add a dependency using Maven, use the following:

<dependency>
  <groupId>net.arnx</groupId>
  <artifactId>darts-clone-java</artifactId>
  <version>0.6.0</version>
</dependency>

Usage

import net.arnx.dartsclone.DoubleArrayTrie;

// Build index
DoubleArrayTrie.Builder dab = new DoubleArrayTrie.Builder();
dab.put("ALGOL", 1);
dab.put("ANSI", 2);
dab.put("ARCO", 3);
dab.put("ARPA", 4);
dab.put("ARPANET", 5);
dab.put("ASCII", 6);
DoubleArrayTrie da = dab.build();

// Gets value by searching in the index
int value = da.get("ALGOL");

// Search values by searching a common prefix
IntStream values = da.findByCommonPrefix("ARPANET");

// Write the index to a file
try (OutputStream out = Files.newOutputStream(Paths.get("./index.dat"))) {
    da.writeTo(out);
}

// Read the index from the file
try (InputStream in = Files.newInputStream(Paths.get("./index.dat"))) {
    da = DoubleArrayTrie.load(in);
}

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

DARTS (Double-ARray Trie System) clone written in Java

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages