Giter VIP home page Giter VIP logo

doublearray-es's Introduction

Double-Array

JavaScript implementation of Double-Array trie.

Usage

Build

Browser example

import { doublearray } from "https://code4fukui.github.io/doublearray-es/doublearray.js";

var words = [
    { k: 'a', v: 1 },
    { k: 'abc', v: 2 },
    { k: '奈良', v: 3 },
    { k: '奈良先端', v: 4 },
    { k: '奈良先端科学技術大学院大学', v: 5 }
];

var trie = doublearray.builder().build(words);

Method chaining

var trie = doublearray
       .builder()
       .append('a', 1)
       .append('abc', 2)
       .append('奈良', 3)
       .append('奈良先端', 4)
       .append('奈良先端科学技術大学院大学', 5)
       .build();

Search

trie.contain('a');  // -> true

trie.lookup('abc');  // -> 2

trie.commonPrefixSearch('奈良先端科学技術大学院大学');
// -> [ { v: 3, k: '奈良' },
//      { v: 4, k: '奈良先端' },
//      { v: 5, k: '奈良先端科学技術大学院大学' } ]

Load

Get BASE or CHECK buffer as Int32Array of typed array

var base_buffer = trie.bc.getBaseBuffer();
var check_buffer = trie.bc.getCheckBuffer();

Load and create a new DoubleArray object from original buffers

var loaded_trie = doublearray.load(base_buffer, check_buffer);

Todo

test for ES modules

Copyright and license

Copyright (c) 2014 Takuya Asano All Rights Reserved.

This software is released under the MIT License. See LICENSE.txt

doublearray-es's People

Contributors

takuyaa avatar taisukef avatar ikawaha avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.