How to use bintrees - 10 common examples

To help you get started, we’ve selected a few bintrees examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glinscott / JSOrderbook / trade-server / book / orderBook.js View on Github external
function OrderBook() {
	var compareLimit = function(l1, l2) {
		return l1.getPrice() - l2.getPrice();
	};
	
	this._bidTree = new Tree(compareLimit);
	this._askTree = new Tree(compareLimit);
	this._highestBid = null;
	this._lowestAsk = null;
	
	// Map from orderId to order
	this._orders = {};
}
github atom / github / lib / models / patch / multi-file-patch.js View on Github external
populateDiffRowOffsetIndices(filePatch) {
    let diffRow = 1;
    const index = new RBTree((a, b) => a.diffRow - b.diffRow);
    this.diffRowOffsetIndices.set(filePatch.getPath(), {startBufferRow: filePatch.getStartRange().start.row, index});

    for (let hunkIndex = 0; hunkIndex < filePatch.getHunks().length; hunkIndex++) {
      const hunk = filePatch.getHunks()[hunkIndex];
      this.hunksByMarker.set(hunk.getMarker(), hunk);

      // Advance past the hunk body
      diffRow += hunk.bufferRowCount();
      index.insert({diffRow, offset: hunkIndex + 1});

      // Advance past the next hunk header
      diffRow++;
    }
  }
github DefinitelyTyped / DefinitelyTyped / bintrees / bintrees-tests.ts View on Github external
import { BinTree, RBTree } from 'bintrees';

let treeA = new RBTree((a:number, b:number) => a - b);

treeA.insert(5);
treeA.insert(3);
treeA.remove(3);

let treeB = new BinTree((a:string, b:string) => a.length - b.length);

treeB.insert('hi');
treeB.insert('there');
treeB.insert('how');
treeB.insert('are');
github mourner / bbtree / bench.js View on Github external
.add('jsbintrees RBTree', function () {
    var bintree = new bintrees.RBTree(compare);
    for (var i = 0; i < N; i++) {
        bintree.insert(data[i]);
    }
    for (var i = 0; i < N; i++) {
        bintree.remove(data[i]);
    }
})
.on('error', function(event) { console.log(event.target.error); })
github mourner / bbtree / bench.js View on Github external
.add('jsbintrees RBTree', function () {
    var tree = new bintrees.RBTree(compare);
    for (var i = 0; i < N; i++) {
        tree.insert(data[i]);
    }
})
.on('error', function(event) { console.log(event.target.error); })
github vdt / matching-engine / lib / order_book.js View on Github external
function OrderBook() {
    this._bid = new Tree(function(a, b) { return a.price - b.price; });
    this._ask = new Tree(function(a, b) { return a.price - b.price; });
    this._by_oid = {};
}
github coinbase / coinbase-pro-trading-toolkit / src / core / HFTFilter.ts View on Github external
clearQueue() {
        this.messagesById = {};
        this.skippedMessages = 0;
        this.tradesSkipped = 0;
        this.messages = new RBTree((a: BaseOrderMessage, b: BaseOrderMessage) => {
            return a.sequence - b.sequence;
        });
    }
github qwertie / btree-typescript / benchmarks.ts View on Github external
measure(set => `Insert ${set.size} pairs in bintrees' RBTree (no values)`, () => {
    let set = new RBTree((a: any, b: any) => a - b);
    for (let k of keys)
      set.insert(k);
    return set;
  });
  //measure(set => `Insert ${set.size} pairs in bintrees' BinTree (no values)`, () => {
github coinbase / coinbase-pro-node / lib / orderbook.js View on Github external
constructor() {
    this._ordersByID = {};
    this._bids = new RBTree((a, b) => a.price.comparedTo(b.price));
    this._asks = new RBTree((a, b) => a.price.comparedTo(b.price));
  }
github coinbase / coinbase-pro-trading-toolkit / src / core / MessageQueue.ts View on Github external
constructor(options: MessageQueueConfig) {
        super({ readableObjectMode: true, writableObjectMode: true });
        this.logger = options.logger || ConsoleLoggerFactory();
        this.productId = options.product;
        this.targetQueueLength = options.targetQueueLength || 10;
        this.lastSequence = -1000;
        this.waitForSnapshot = options.waitForSnapshot;
        this.messages = new RBTree((a: BaseOrderMessage, b: BaseOrderMessage) => {
            return a.sequence - b.sequence;
        });
    }

bintrees

Binary Search Trees

MIT
Latest version published 7 years ago

Package Health Score

67 / 100
Full package analysis

Popular bintrees functions