/DAT.js

Double Array Trie implemented in Javascript

Primary LanguageJavaScriptMIT LicenseMIT

DAT.js

This library implements a Double Array Trie (DAT) System in JavaScript. A Double-Array Trie is a structure designed to make the size compact while maintaining fast access with algorithms for retrieval. Read more about it here.

Designed as a library to support my DAT-AC algorithm, this library naturally provides support for the aho-corasick algorithm, but keeps the more traditionally linked list trie when building the double array trie. ##Install

npm install datjs

##Instructions ####Node.js

var doublearray = require('datjs');

var data = new doublearray(
{
    'redundant': 1,
    'rambunctious': 2,
    'pies': 3,
    'puncture': 4,
    'whistle': 5
 });

####Bower.js

var data = new doublearray(
{
    'redundant': 1,
    'rambunctious': 2,
    'pies': 3,
    'puncture': 4,
    'whistle': 5
 });

####With Source

var doublearray = require('./dat.js');
var data = new doublearray(
{
    'redundant': 1,
    'rambunctious': 2,
    'pies': 3,
    'puncture': 4,
    'whistle': 5
 });

##Usage ####Insert Data

data.insert('apples');
data.insert('dudes');

####Query Data

trie.contains('redundant');
trie.contains('eggs');

####Delete Data

trie.delete('rambunctious');
trie.delete('pies');