패키지, 저장소 및 앱 카테고리 검색

패키지 상세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을 통해 반복 가능하며, 하위 목록 생성에 사용할 수 있는 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

}

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.