simple_bloom_filter 0.1.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 50

simple_bloom_filter 🎯 #

A simple Dart implementation of a bloom filter. Bloom filters are a space-efficient probabilistic data structure that is used to test whether an element is a member of a set.

usage #

var bloom = simple_bloom_filter(10000, 3);
bloom.add('hello world');
if (bloom.check('hello world') == true) {
    print('"hello world" PROBABLY exists...');
}

Features #

  • Choose size of bit array
  • Choose number of hash functions

Features to come #

  • Better hash functions
  • Choose false positive probability

0.1.3 #

  • Fix name in README

0.1.2 #

  • Update README
  • Generate dartdoc

0.1.1 #

  • Update description

0.1.0 #

  • Hashes are random numbers
  • Input must be String type

example/simple_bloom_filter_example.dart

import 'package:simple_bloom_filter/simple_bloom_filter.dart';

void main() {
  var bloom = simple_bloom_filter(10000, 3);

  bloom.add('hello world');
  bloom.add(1234567890.toString());
  bloom.add('{"first-name": "Dart", "last-name": "lang"}');

  if (bloom.check('hello world') == true) {
    print('"hello world" PROBABLY exists...');
  }
  else {
    print('"hello world" DEFINITELY does not exist...');
  }
  if (bloom.check(1234567890.toString()) == true) {
    print('"1234567890" PROBABLY exists...');
  }
  else {
    print('"1234567890" DEFINITELY does not exist...');
  }
  if (bloom.check('{"first-name": "Dart", "last-name": "lang"}') == true) {
    print('"{"first-name": "Dart", "last-name": "lang"}" PROBABLY exists...');
  }
  else {
    print('"{"first-name": "Dart", "last-name": "lang"}" DEFINITELY does not exist...');
  }
  if (bloom.check('{"first-name": "Go", "last-name": "lang"}') == true) {
    print('"{"first-name": "Go", "last-name": "lang"}" PROBABLY exists...');
  }
  else {
    print('"{"first-name": "Go", "last-name": "lang"}" DEFINITELY does not exist...');
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  simple_bloom_filter: ^0.1.3

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:simple_bloom_filter/simple_bloom_filter.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

We analyzed this package on Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13

Health issues and suggestions

Document public APIs. (-1 points)

10 out of 10 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/simple_bloom_filter.dart.

Run dartfmt to format lib/simple_bloom_filter.dart.

Format lib/src/simple_bloom_filter_base.dart.

Run dartfmt to format lib/src/simple_bloom_filter_base.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
Dev dependencies
pedantic ^1.8.0
test ^1.6.0