stl library

Support for doing something awesome.

More dartdocs go here.

Classes

Any
A type-safe container for single values of literally any type.
Array<T>
A conceptually strict fixed-size contiguous sequence.
BitAnd<T>
A functor that computes the bitwise AND of two arguments.
BitNot<T>
A functor that computes the bitwise NOT of its argument.
BitOr<T>
A functor that computes the bitwise OR of two arguments.
BitSet
A space-efficient set implementation for managing boolean flags. Mimics C++ std::bitset functionality.
BitXor<T>
A functor that computes the bitwise XOR of two arguments.
Box<T>
A mutable wrapper designed to hold and update values.
CartesianRange<T1, T2>
A view that generates the Cartesian product of two iterables. Mimics C++ std::views::cartesian_product.
ChunkRange<T>
A view that splits an iterable into chunks of a specific size. Mimics C++ std::views::chunk. The last chunk may be smaller than the requested size if the total number of elements is not perfectly divisible by the chunk size.
Circle
Defines a mathematical circle strictly via a radius.
Complex
A high-performance equivalent to C++ <complex>.
Deque<T>
A double-ended queue (deque) that allows for insertion and deletion of elements at both the front and the rear.
Divides<T>
A functor that returns the quotient of two arguments.
DropRange<T>
A view that drops the first count elements of an iterable. Mimics C++ std::views::drop.
Ellipse
Defines a mathematical ellipse strictly via its semi-axes.
EqualTo<T>
A functor that checks if two arguments are equal.
Expected<T, E>
A type that contains either an expected value of type T or an error of type E.
FilterRange<T>
A view that filters elements based on a predicate. Mimics C++ std::views::filter.
ForwardList<T>
A singly-linked list.
Greater<T>
A functor that checks if the first argument is strictly greater than the second.
GreaterEqual<T>
A functor that checks if the first argument is greater than or equal to the second.
HashMap<K, V>
An unordered collection of key-value pairs.
HashSet<T>
An unordered collection that contains no duplicate elements.
JoinRange<T>
A view that flattens an iterable of iterables into a single contiguous iterable. Mimics C++ std::views::join.
Less<T>
A functor that checks if the first argument is strictly less than the second.
LessEqual<T>
A functor that checks if the first argument is less than or equal to the second.
LineSegment
Defines a mathematical line segment strictly via 2 points in 2D space.
LogicalAnd<T>
A functor that computes the logical AND of two arguments.
LogicalNot<T>
A functor that computes the logical NOT of its argument.
LogicalOr<T>
A functor that computes the logical OR of two arguments.
Minus<T>
A functor that returns the difference of two arguments.
Modulus<T>
A functor that returns the remainder of two arguments.
MultiMap<K, V>
An associative collection that stores elements as key-value pairs, sorted by key, and allows multiple elements with the same key.
Multiplies<T>
A functor that returns the product of two arguments.
MultiSet<T>
A collection that contains elements in sorted order, allowing duplicates.
Negate<T>
A functor that returns the negation of its argument.
None<T>
Variant representing a missing value.
NotEqualTo<T>
A functor that checks if two arguments are not equal.
NumberLine<T extends num>
A memory-efficient iterable sequence of numbers. Mimics C++ std::views::iota or Python's range().
Optional<T>
A container for a value that may or may not exist. Using a sealed class ensures exhaustive pattern matching.
Pair<T1, T2>
A class that stores a pair of values.
Plus<T>
A functor that returns the sum of two arguments.
Point<T extends num>
Represents a 2D coordinate in Euclidean space.
Polygon
Defines a mathematical polygon via an ordered collection of vertices.
PriorityQueue<T>
An adapter class that provides a Priority Queue (Heap) data structure.
Queue<T>
An adapter class that provides a First-In, First-Out (FIFO) data structure.
Rectangle
Defines a standard rectangle strictly via dimensions.
Ref<T>
A mutable reference wrapper for binding and managing a value.
RepeatRange<T>
A view that repeats a single value either limits-free (infinitely) or a specific amount of times. Mimics C++ std::views::repeat.
Set<T>
A collection that contains no duplicate elements.
Shape<T extends Shape<T>>
The foundational contract for all 2D entities.
SList<T>
A doubly-linked list.
Some<T>
Variant representing an existing value.
SortedMap<K, V>
A collection that stores elements as key-value pairs, maintaining them in strictly sorted order by key.
SortedSet<T>
A collection that contains no duplicate elements, ensuring strict sorting order.
Stack<T>
An adapter class that provides a Last-In, First-Out (LIFO) data structure.
StdRandom
A deterministic, predictable C++ style pseudo-random number generator.
StringView
A non-owning, zero-allocation reference to a string or a contiguous substring.
TakeRange<T>
A view that yields up to the first count elements of an iterable. Mimics C++ std::views::take.
TransformRange<T, U>
A view that transforms elements from one type to another using a mapping function. Mimics C++ std::views::transform.
Triangle
Defines a mathematical triangle strictly via 3 points in 2D space.
Tuple3<T1, T2, T3>
A tuple of 3 elements.
Tuple4<T1, T2, T3, T4>
A tuple of 4 elements.
Tuple5<T1, T2, T3, T4, T5>
A tuple of 5 elements.
Tuple6<T1, T2, T3, T4, T5, T6>
A tuple of 6 elements.
Tuple7<T1, T2, T3, T4, T5, T6, T7>
A tuple of 7 elements.
Var<T>
A simple mutable wrapper for holding and updating a value.
Variant2<T0, T1>
A type-safe discriminated union holding either T0 or T1.
Variant2Item0<T0, T1>
Represents the first alternative of Variant2.
Variant2Item1<T0, T1>
Represents the second alternative of Variant2.
Variant3<T0, T1, T2>
A type-safe discriminated union holding either T0, T1, or T2.
Variant3Item0<T0, T1, T2>
Represents the first alternative of Variant3.
Variant3Item1<T0, T1, T2>
Represents the second alternative of Variant3.
Variant3Item2<T0, T1, T2>
Represents the third alternative of Variant3.
Vector<T extends Comparable>
A C++ style Vector collection backed by a Dart List.
ZipRange<T1, T2>
A view that iterates over two iterables in parallel, yielding Pairs. Mimics C++ std::views::zip. The iteration stops when the shortest iterable is exhausted.

Extension Types

I16
A 16-bit signed integer primitive.
I32
A 32-bit signed integer primitive.
I64
A 64-bit signed integer primitive.
I8
An 8-bit signed integer primitive.
Int16
A robust, heap-allocated 16-bit signed integer wrapper utilizing dart:typed_data.
Int32
A robust, heap-allocated 32-bit signed integer wrapper utilizing dart:typed_data.
Int64
A robust, heap-allocated 64-bit signed integer wrapper utilizing dart:typed_data.
Int8
A robust, heap-allocated 8-bit signed integer wrapper utilizing dart:typed_data.
U16
A 16-bit unsigned integer primitive.
U32
A 32-bit unsigned integer primitive.
U64
A 64-bit unsigned integer primitive.
U8
An 8-bit unsigned integer primitive.
Uint16
A robust, heap-allocated 16-bit unsigned integer wrapper utilizing dart:typed_data.
Uint32
A robust, heap-allocated 32-bit unsigned integer wrapper utilizing dart:typed_data.
Uint64
A robust, heap-allocated 64-bit unsigned integer wrapper utilizing dart:typed_data.
Uint8
A robust, heap-allocated 8-bit unsigned integer wrapper utilizing dart:typed_data.

Extensions

ComparablePair on Pair<T1, T2>
Adds C++ <utility> relational operators securely without sacrificing generic safety. These operators (<, <=, >, >=, compareTo) automatically unlock when both T1 and T2 happen to extend Comparable.
NumericIterableExtension on Iterable<T>
Extension providing numeric operations on Iterables.
NumericListExtension on List<T>
Extension providing numeric operations on Lists.

Constants

apery → const double
Apéry's constant ζ(3); value of the Riemann zeta function at 3.
catalan → const double
Catalan's constant (G).
e → const double
Euler's number; the base of the natural logarithm (e).
eulerMascheroni → const double
The Euler–Mascheroni constant (γ).
infinity → const double
Positive infinity (IEEE 754).
invPi → const double
Reciprocal of π (1 / π).
khinchin → const double
The Khinchin constant (K₀).
ln10 → const double
Natural logarithm of 10 (ln 10).
ln2 → const double
Natural logarithm of 2 (ln 2).
lnPhi → const double
The natural logarithm of the golden ratio (ln φ).
log10_2 → const double
Base-10 logarithm of 2 (log₁₀ 2).
log10e → const double
Base-10 logarithm of e (log₁₀ e).
log2_10 → const double
Base-2 logarithm of 10 (log₂ 10).
log2e → const double
Base-2 logarithm of e (log₂ e).
maxFinite → const double
The largest finite representable double (≈ 1.798 × 10³⁰⁸).
minPositive → const double
The smallest positive non-zero double (≈ 5 × 10⁻³²⁴).
nan → const double
Not-a-Number sentinel (IEEE 754).
negativeInfinity → const double
Negative infinity (IEEE 754).
phi → const double
The golden ratio (φ), positive root of x² − x − 1 = 0.
pi → const double
The ratio of a circle's circumference to its diameter (π).
sqrt1Over2 → const double
Reciprocal of the square root of 2 (1 / √2 = √2 / 2).
sqrt2 → const double
Square root of 2 (√2).
sqrt3 → const double
Square root of 3 (√3).
sqrt5 → const double
Square root of 5 (√5).
sqrtPi → const double
Square root of π (√π).
tau → const double
The full-circle constant, equal to 2π (τ).
twoDivPi → const double
Two divided by π (2 / π).
twoDivSqrtPi → const double
Two divided by the square root of π (2 / √π).

Functions

binarySearch<T>(List<T> list, T value, {int compare(T, T)?}) bool
Checks if an element equivalent to value appears within the list.
clamp<T extends num>(T v, T lo, T hi) → T
Clamps v between lo and hi.
equalRange<T>(List<T> list, T value, {int compare(T, T)?}) Pair<int, int>
Returns a Pair containing the lowerBound and upperBound of value.
gcd(int a, int b) int
Returns the greatest common divisor of a and b. Uses the highly optimized Euclidean algorithm.
hypot(num x, num y, [num? z]) double
Computes the length of the hypotenuse sqrt(x^2 + y^2).
invoke(Function callable, {List positional = const [], Map<Symbol, dynamic> named = const {}}) → dynamic
Invokes the callable with the provided args.
isPrime(int n) bool
Checks if a given number n is prime.
lcm(int a, int b) int
Returns the least common multiple of a and b.
lerp(num a, num b, num t) double
Computes the linear interpolation between a and b for the parameter t.
lowerBound<T>(List<T> list, T value, {int compare(T, T)?}) int
Returns the index of the first element in the list that is not less than (i.e. greater or equal to) value.
makePair<T1, T2>(T1 first, T2 second) Pair<T1, T2>
A convenience function to create a Pair, mimicking C++ std::make_pair.
makeTuple3<T1, T2, T3>(T1 item1, T2 item2, T3 item3) Tuple3<T1, T2, T3>
A convenience function to create a Tuple3, mimicking C++ std::make_tuple.
makeTuple4<T1, T2, T3, T4>(T1 item1, T2 item2, T3 item3, T4 item4) Tuple4<T1, T2, T3, T4>
A convenience function to create a Tuple4, mimicking C++ std::make_tuple.
makeTuple5<T1, T2, T3, T4, T5>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5) Tuple5<T1, T2, T3, T4, T5>
A convenience function to create a Tuple5, mimicking C++ std::make_tuple.
makeTuple6<T1, T2, T3, T4, T5, T6>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6) Tuple6<T1, T2, T3, T4, T5, T6>
A convenience function to create a Tuple6, mimicking C++ std::make_tuple.
makeTuple7<T1, T2, T3, T4, T5, T6, T7>(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7) Tuple7<T1, T2, T3, T4, T5, T6, T7>
A convenience function to create a Tuple7, mimicking C++ std::make_tuple.
midpoint<T extends num>(T a, T b) → T
Finds the midpoint of two numbers (a + b) / 2 safely without overflow.
nextPermutation<T>(List<T> list, {int compare(T, T)?}) bool
Transforms the list into the next permutation from the set of all permutations that are lexicographically ordered.
partition<T>(List<T> list, bool predicate(T)) int
Reorders the elements in the list in such a way that all elements for which the predicate returns true precede the elements for which it returns false.
prevPermutation<T>(List<T> list, {int compare(T, T)?}) bool
Transforms the list into the previous permutation from the set of all permutations that are lexicographically ordered.
primeFactorization(int n) List<int>
Returns the prime factorization of n as a list of prime factors in ascending order.
reverse<T>(List<T> list) → void
Reverses the order of the elements in the list in-place.
rotate<T>(List<T> list, int n) → void
Rotates the order of the elements in the list in such a way that the element at index n becomes the new first element.
setDifference<T>(Iterable<T> a, Iterable<T> b, {int compare(T, T)?}) List<T>
Constructs a sorted difference of elements from two sorted sequences a and b.
setIntersection<T>(Iterable<T> a, Iterable<T> b, {int compare(T, T)?}) List<T>
Constructs a sorted intersection of elements from two sorted sequences a and b.
setUnion<T>(Iterable<T> a, Iterable<T> b, {int compare(T, T)?}) List<T>
Constructs a sorted union of elements from two sorted sequences a and b.
stablePartition<T>(List<T> list, bool predicate(T)) int
Reorders the elements in the list in such a way that all elements for which the predicate returns true precede the elements for which it returns false.
unique<T>(List<T> list, {bool equals(T, T)?}) int
Eliminates all except the first element from every consecutive group of equivalent elements from the list and returns the new logical length of the collection.
upperBound<T>(List<T> list, T value, {int compare(T, T)?}) int
Returns the index of the first element in the list that is strictly greater than value.

Exceptions / Errors

DomainError
Thrown when a mathematical function is evaluated outside its defined domain.
InvalidArgument
Thrown when an invalid argument is passed to a function.
LengthError
Thrown when an object would exceed its maximum permitted length.
LogicError
Base class for errors that can be detected before the program executes.
OutOfRange
Thrown when an index or value is out of the valid range.
OverflowError
Thrown when a mathematical computation causes an arithmetic overflow.
RuntimeError
Base class for errors that occur during program execution.
StdException
Base class for all STL standard exceptions.
StdRangeError
Thrown when a mathematical computation produces a result that exceeds the representable range.
UnderflowError
Thrown when a mathematical computation causes an arithmetic underflow.