パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v1.0.7

binary_tree

Dart用の自己バランスバイナリーサーチツリー。BSTはIterableとして実装されています。greaterThen、lessThenOrEqual(部分リスト作成)、max、minなど多くの操作があります。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
95
いいね数
28
Pub ポイント
150

パッケージをインストール

flutter pub add binary_tree

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

O(log n) の複雑さで効率的な検索、挿入、削除操作を維持するように設計された、Dart での自己バランスの取れたバイナリーサーチツリーの実装です。Iterable を介した反復処理をサポートし、sublist の作成に使用できる greaterThan、lessThanOrEqual、max、min などの強力なメソッドを提供します。順序付きアクセスや範囲クエリが必要な動的データセットに最適です。パフォーマンスと使いやすさを意識して構築されており、複数のプラットフォームで高速なソート済みデータ管理が必要なアプリケーションに適しています。

用途

  • 動的にソートされたデータを管理する
  • 範囲クエリの実装
  • 効率的な検索と挿入
  • 順序付きコレクションの構築
  • リアルタイムデータ処理のサポート
  • 高速な最小/最大値の取得を有効にする

主な機能

  • 自己バランス構造
  • Iterable 対応
  • 範囲ベースのクエリ(greaterThan、lessThanOrEqual)
  • O(log n) 操作
  • 最小/最大アクセスメソッド
  • クロスプラットフォーム互換性

適している対象

  • 順序付きデータ構造が必要な開発者
  • 頻繁な挿入と検索を行うアプリケーション
  • 並べ替えられた部分集合を必要とするシステム
  • パフォーマンスに重要なデータ処理
  • 複数のプラットフォームでのDartプロジェクト

注意事項

  • シンプルなリストよりもメモリオーバーヘッドが大きい
  • 静的データセットには適していません
  • BSTの概念を理解している必要があります
  • 組み込みコレクションよりも直感的ではない
  • ツリー論理のデバッグにおける潜在的な複雑さ

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Self-Balancing Binary Search Tree for Dart. BST is implemented as Iterable. There are many operations such as greaterThan, lessThanOrEqual (create sublist), max , min etc.

Features

void main() {
  final myNumbers = BinaryTree([10, 8, 16, 4, 9, 13, 25, 2, 6, 12, 26, 14, 18]);
}

Binary tree stores values as a binary search tree.
For more information : Binary Search Tree.

A Self-Balancing AVL type tree is used, which balances the depth of the nodes.
For more information : Self Balancing Binary Search Tree , AVL Tree.

img.png

Usage

Use Case

You can see if you need it by looking at the benchmarks given below. It is generally advantageous in keeping long and sorted datasets. Its advantage is not noticeable on short datasets.

Benchmark scenarios

img_3.png img_1.png img_2.png

Type

Binary Tree objects must be Comparable

All of num , String , Duration etc. are Comparable.

You can define your objects as Comparable.

Comparable Documentation

void main() {
  final myLetters = BinaryTree<String>(["a", "c", "b"]);
  final myDates = BinaryTree<DateTime>([DateTime.now()]);
}
Basic operations
void main() {
  final myNumbers = BinaryTree([ 
    /*initial*/
  ]);
  myNumbers.insert(value);
  myNumbers.remove(value);
  myNumbers.contains(value);
  
}
Iterator

You can create an Iterator by "startsWith" or "endsWith" given element.

f() {
  final myNumbers = BinaryTree([10, 8, 16, 4, 9, 13, 25, 2, 6, 12, 26, 14, 18]);
  final iterator = myNumbers.iteratorFrom(8, greaterThan: true, equal: false); // defaults
  while (iterator.moveNext()) {
    print(iterator.current); // 9 , 10 ... 26
  }
}

You can also define bounds

f() {
  final myNumbers = BinaryTree([10, 8, 16, 4, 9, 13, 25, 2, 6, 12, 26, 14, 18]);
  final iterator = myNumbers.iteratorFrom(8, bound: Bound(13, equal: true));
  while (iterator.moveNext()) {
    print(iterator.current); // 9 , 10 ... 13
  }
}
toList

You can create new lists using range iterators.

f() {
  final myNumbers = BinaryTree([10, 8, 16, 4, 9, 13, 25, 2, 6, 12, 26, 14, 18]);

  myNumbers.lessThan(16);

  /// 14 , 13 , ... 2
  myNumbers.lessThanOrEqual(16);

  /// 16 , 14 , 13 , ... 2
  myNumbers.greaterThan(16);

  ///  25 , 26
  myNumbers.greaterThanOrEqual(16);

  /// 16 , 25 , 26

  /// custom bound
  myNumbers.listFrom(16, bound: Bound(13, equal: true));

  /// 16 , 14 , 13

}

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。