btree 0.1.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 0

btree

This package provides an in-memory B-Tree implementation, useful as a an ordered, mutable data structure.

It has a flatter structure than an equivalent red-black or other binary tree, which in some cases yields better memory usage and/or performance.

The API is based on BTree implementation for Go

Build Status Coverage Status

Usage

A simple usage example:

library btree.example;

import 'package:btree/btree.dart';

main() {
  final btree = new BTree<int>(3);
  for (var i = 0; i < 10; i++) {
    btree.replaceOrInsert(i);
  }
  print('len:       ${btree.length}');
  // len:       10
  print('get3:      ${btree[3]}');
  // get3:      3
  print('get100:    ${btree[100]}');
  // get100:    null
  print('del4:      ${btree.remove(4)}');
  // del4:      4
  print('del100:    ${btree.remove(100)}');
  // del100:    null
  print('replace5:  ${btree.replaceOrInsert(5)}');
  // replace5:  5
  print('replace100:${btree.replaceOrInsert(100)}');
  // replace100:null
  print('delmin:    ${btree.removeMin()}');
  // delmin:    0
  print('delmax:    ${btree.removeMax()}');
  // delmax:    100
  print('len:       ${btree.length}');
  // len:       8
}

Features and bugs

Please file feature requests and bugs at the issue tracker.

Changelog

0.1.1

  • Turn on strong mode and fix warnings and errors

0.1.0

  • Initial version

example/btree.dart

// Copyright (c) 2015, Kwang Yul Seo. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

library btree.example;

import 'package:btree/btree.dart';

main() {
  final btree = new BTree<int>(3);
  for (var i = 0; i < 10; i++) {
    btree.replaceOrInsert(i);
  }
  print('len:       ${btree.length}');
  // len:       10
  print('get3:      ${btree[3]}');
  // get3:      3
  print('get100:    ${btree[100]}');
  // get100:    null
  print('del4:      ${btree.remove(4)}');
  // del4:      4
  print('del100:    ${btree.remove(100)}');
  // del100:    null
  print('replace5:  ${btree.replaceOrInsert(5)}');
  // replace5:  5
  print('replace100:${btree.replaceOrInsert(100)}');
  // replace100:null
  print('delmin:    ${btree.removeMin()}');
  // delmin:    0
  print('delmax:    ${btree.removeMax()}');
  // delmax:    100
  print('len:       ${btree.length}');
  // len:       8
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  btree: ^0.1.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:btree/btree.dart';
  
Version Uploaded Documentation Archive
0.1.1 Nov 3, 2016 Go to the documentation of btree 0.1.1 Download btree 0.1.1 archive
0.1.0 Nov 22, 2015 Go to the documentation of btree 0.1.0 Download btree 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0 <2.0.0