ordered_set
8.0.1, released 4 months ago by blue-fire.xyz
Ordered Set that keeps elements sorted and allows duplicates by priority.
What it does
It stores items in order according to a comparator or a mapper function, permitting multiple items with the same priority. The set implements Iterable, so you can iterate in order with O(n) complexity.
AI-written summary of version 8.0.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need a sorted collection that accepts duplicate priorities
- You want fast iteration over ordered elements
- You need to query subsets by type or cache query results
Skip it when
- You only need a unique sorted set—use Dart's SplayTreeSet instead
- You require persistence or async operations
Strengths
- Allows duplicate priorities
- Simple API with static constructors
- Iterable implementation for easy traversal
- Supports query registration and caching
Weaknesses
- No built‑in persistence or async support
- Not a full data‑structure library (no tree traversal APIs)
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
import 'package:ordered_set/ordered_set.dart';
void main() {
final items = OrderedSet.simple<num, int>();
items.add(2);
items.add(1);
print(items.toList()); // [1, 2]
}Alternatives
Packages that do the same job and could replace ordered_set.
- fast_immutable_collections
Fast immutable lists, sets, maps, and multimaps for Dart
91Compare - more
A collection of utility extensions and specialized data structures for Dart.
90Compare - weak_map
A map whose keys are weakly held, and cache functions for memoization.
80Compare - data
Time and space efficient data structures and algorithms for vectors, matrices, and math.
72Compare
Works with
Packages commonly used together with ordered_set: ones it builds on, ones built on it, and its own family.