weak_collections 1.6.1 copy "weak_collections: ^1.6.1" to clipboard
weak_collections: ^1.6.1 copied to clipboard

Collection of weak references. WeakHashMap, WeakLinkedHashMap, WeakHashSet, WeakLinkedHashSet, WeakQueue. Weak reference effect achieved through WeakReference and Finalizer.

example/example.dart

import 'package:weak_collections/weak_collections.dart';

void main() {
  Object? o = Object();
  Object o2 = Object();
  WeakHashMap weakMap = WeakHashMap();
  WeakHashSet weakSet = WeakHashSet();
  WeakQueue weakQueue = WeakQueue();
  weakMap[o] = o2;
  weakSet.add(o);
  weakQueue.add(o);
  o = null;
  List lis = [];
  Future(() => '').then((_) {
    lis = List.filled(1020000, () => Object());
    print(weakMap.length);
    Future(() => '').then((_) {
      lis = List.filled(1020000, () => Object());
      print(weakMap.length);
      Future(() => '').then((_) {
        lis = List.filled(1020000, () => Object());
        print(weakMap.length);
        Future(() => '').then((_) {
          for (int i = 0; i < 100; i++) {
            lis = List.filled(1020000, () => Object());
          }
          print(weakMap.length);
          Future(() => '').then((_) {
            lis = List.filled(1020000, () => Object());
            print(weakMap.length);
            Future(() => '').then((_) {
              lis = List.filled(1020000, () => Object());
              print(weakMap.length);
              Future(() => '').then((_) {
                lis = List.filled(1020000, () => Object());
                print(weakMap.length);
                Future(() => '').then((_) {
                  lis = List.filled(1020000, () => Object());
                  print(weakMap.length);
                  Future(() => '').then((_) {
                    lis = List.filled(1020000, () => Object());
                    print(weakMap.length);
                    Future(() => '').then((_) {
                      lis = List.filled(1020000, () => Object());
                      print(weakMap.length);
                    });
                  });
                });
              });
            });
          });
        });
      });
    });
  });
  lis.length;
}
6
likes
160
points
185
downloads

Documentation

API reference

Publisher

verified publisheraymtools.com

Weekly Downloads

Collection of weak references. WeakHashMap, WeakLinkedHashMap, WeakHashSet, WeakLinkedHashSet, WeakQueue. Weak reference effect achieved through WeakReference and Finalizer.

Repository (GitHub)
View/report issues

Topics

#weak #weak-hashmap #weak-hashset #weak-queue #weak-linked-hashmap

License

MIT (license)

Dependencies

meta

More

Packages that depend on weak_collections